diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index 157c8d28db1083..6f609991ecc7fb 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -277,6 +277,8 @@ function esbuildScanPlugin( let loader: Loader = 'js' if (lang === 'ts' || lang === 'tsx' || lang === 'jsx') { loader = lang + } else if (path.endsWith('.astro')) { + loader = 'ts' } const srcMatch = openTag.match(srcRE) if (srcMatch) { diff --git a/playground/optimize-deps/index.astro b/playground/optimize-deps/index.astro new file mode 100644 index 00000000000000..95790f5bf3a0d5 --- /dev/null +++ b/playground/optimize-deps/index.astro @@ -0,0 +1,4 @@ + diff --git a/playground/optimize-deps/index.html b/playground/optimize-deps/index.html index d11383bfcb3e04..3cd619f9ce9236 100644 --- a/playground/optimize-deps/index.html +++ b/playground/optimize-deps/index.html @@ -119,6 +119,8 @@

Reused variable names

import { parse } from 'node:url' text('.url', parse('https://vitejs.dev').hostname) + + import './index.astro'