diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts
index 5a6c55ea0a5746..2b87ccdcbcad54 100644
--- a/packages/vite/src/node/optimizer/scan.ts
+++ b/packages/vite/src/node/optimizer/scan.ts
@@ -379,14 +379,18 @@ function esbuildScanPlugin(
// avoid matching windows volume
filter: /^[\w@][^:]/
},
- async ({ path: id, importer }) => {
+ async ({ path: id, importer, pluginData }) => {
if (moduleListContains(exclude, id)) {
return externalUnlessEntry({ path: id })
}
if (depImports[id]) {
return externalUnlessEntry({ path: id })
}
- const resolved = await resolve(id, importer)
+ const resolved = await resolve(id, importer, {
+ custom: {
+ depScan: { loader: pluginData?.htmlType?.loader }
+ }
+ })
if (resolved) {
if (shouldExternalizeDep(resolved, id)) {
return externalUnlessEntry({ path: id })
diff --git a/playground/vue/TsImport.vue b/playground/vue/TsImport.vue
index 2b65011a160d23..7858c8cfa674d2 100644
--- a/playground/vue/TsImport.vue
+++ b/playground/vue/TsImport.vue
@@ -1,8 +1,10 @@
Ts Import
{{ foo }}
+ {{ foo2 }}
diff --git a/playground/vue/__tests__/vue.spec.ts b/playground/vue/__tests__/vue.spec.ts
index 3b6e2cc15555b1..4a55bdfe80802f 100644
--- a/playground/vue/__tests__/vue.spec.ts
+++ b/playground/vue/__tests__/vue.spec.ts
@@ -25,6 +25,7 @@ test('template/script latest syntax support', async () => {
test('import ts with .js extension with lang="ts"', async () => {
expect(await page.textContent('.ts-import')).toBe('success')
+ expect(await page.textContent('.ts-import2')).toBe('success')
})
test('should remove comments in prod', async () => {
diff --git a/playground/vue/vite.config.ts b/playground/vue/vite.config.ts
index f99a68ce8b6b10..c1561ce2c2bd47 100644
--- a/playground/vue/vite.config.ts
+++ b/playground/vue/vite.config.ts
@@ -5,7 +5,8 @@ import { vueI18nPlugin } from './CustomBlockPlugin'
export default defineConfig({
resolve: {
alias: {
- '/@': __dirname
+ '/@': __dirname,
+ '@': __dirname
}
},
plugins: [