diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts
index 5571d031245f6d..3c592cec499de5 100644
--- a/packages/vite/src/node/optimizer/scan.ts
+++ b/packages/vite/src/node/optimizer/scan.ts
@@ -246,9 +246,8 @@ function globEntries(pattern: string | string[], config: ResolvedConfig) {
})
}
-const scriptModuleRE =
- /(
+
+
+
+{{ items }}
diff --git a/playground/optimize-deps/index.html b/playground/optimize-deps/index.html
index 8c5719075650ce..a07e6a17798154 100644
--- a/playground/optimize-deps/index.html
+++ b/playground/optimize-deps/index.html
@@ -165,6 +165,7 @@
Pre bundle css require
)
import './index.astro'
+ import './generics.vue'
// All these imports should end up resolved to the same URL (same ?v= injected on them)
import { add as addFromDirectAbsolutePath } from '/node_modules/@vitejs/test-dep-non-optimized/index.js'
diff --git a/playground/optimize-deps/vite.config.js b/playground/optimize-deps/vite.config.js
index 7eb4c5b10c3101..04ba79b5a2e38d 100644
--- a/playground/optimize-deps/vite.config.js
+++ b/playground/optimize-deps/vite.config.js
@@ -121,6 +121,11 @@ export default defineComponent({
`.trim(),
}
}
+
+ // fallback to empty module for other vue files
+ if (id.endsWith('.vue')) {
+ return { code: `export default {}` }
+ }
},
}
}