Skip to content

Commit 584fd7b

Browse files
committed
fix: esbuild transform should read tsconfig experimentalDecorators
1 parent 6e2ae46 commit 584fd7b

File tree

1 file changed

+9
-1
lines changed
  • packages/vite/src/node/optimizer

1 file changed

+9
-1
lines changed

packages/vite/src/node/optimizer/scan.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import type { PluginContainer } from '../server/pluginContainer'
3636
import { createPluginContainer } from '../server/pluginContainer'
3737
import { transformGlobImport } from '../plugins/importMetaGlob'
3838
import { cleanUrl } from '../../shared/utils'
39+
import { loadTsconfigJsonForFile } from '../plugins/esbuild'
3940

4041
type ResolveIdOptions = Parameters<PluginContainer['resolveId']>[2]
4142

@@ -1021,7 +1022,14 @@ function rolldownScanPlugin(
10211022
const loader = ext as Loader
10221023

10231024
if (loader !== 'js') {
1024-
contents = (await transform(contents, { loader })).code
1025+
let tsconfigRaw
1026+
const tsconfigResult = await loadTsconfigJsonForFile(
1027+
path.join(config.root, '_dummy.js'),
1028+
)
1029+
if (tsconfigResult.compilerOptions?.experimentalDecorators) {
1030+
tsconfigRaw = { compilerOptions: { experimentalDecorators: true } }
1031+
}
1032+
contents = (await transform(contents, { loader, tsconfigRaw })).code
10251033
}
10261034

10271035
if (contents.includes('import.meta.glob')) {

0 commit comments

Comments
 (0)