Skip to content

Commit

Permalink
fix: enable experimentalDecorators during scan
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Jul 13, 2023
1 parent 846bd09 commit cbb24c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 15 additions & 2 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ async function prepareEsbuildScanner(

const plugin = esbuildScanPlugin(config, container, deps, missing, entries)

const { plugins = [], ...esbuildOptions } =
config.optimizeDeps?.esbuildOptions ?? {}
const {
plugins = [],
tsconfigRaw,
...esbuildOptions
} = config.optimizeDeps?.esbuildOptions ?? {}

return await esbuild.context({
absWorkingDir: process.cwd(),
Expand All @@ -219,6 +222,16 @@ async function prepareEsbuildScanner(
format: 'esm',
logLevel: 'silent',
plugins: [...plugins, plugin],
tsconfigRaw:
typeof tsconfigRaw === 'string'
? tsconfigRaw
: {
...tsconfigRaw,
compilerOptions: {
experimentalDecorators: true,
...tsconfigRaw?.compilerOptions,
},
},
...esbuildOptions,
})
}
Expand Down
5 changes: 4 additions & 1 deletion playground/tsconfig-json/src/decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ function first() {

export class Foo {
@first()
method() {}
// @ts-expect-error we intentionally not enable `experimentalDecorators` to test esbuild compat
method(@first test: string) {
return test
}
}
1 change: 1 addition & 0 deletions playground/tsconfig-json/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-nocheck
import '../nested/main'
import '../nested-with-extends/main'
import './decorator'

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import { MainTypeOnlyClass } from './not-used-type'
Expand Down

0 comments on commit cbb24c4

Please sign in to comment.