mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-25 10:08:29 +00:00
fix(kit,schema): set esbuild target for experimental decorators (#31089)
This commit is contained in:
parent
7b5ba53cb6
commit
aac000061b
@ -200,7 +200,6 @@ export async function _generateTypes (nuxt: Nuxt) {
|
|||||||
/* Decorator support */
|
/* Decorator support */
|
||||||
...useDecorators
|
...useDecorators
|
||||||
? {
|
? {
|
||||||
useDefineForClassFields: false,
|
|
||||||
experimentalDecorators: false,
|
experimentalDecorators: false,
|
||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
|
@ -9,6 +9,19 @@ export default defineResolvers({
|
|||||||
* @type {import('esbuild').TransformOptions}
|
* @type {import('esbuild').TransformOptions}
|
||||||
*/
|
*/
|
||||||
options: {
|
options: {
|
||||||
|
target: {
|
||||||
|
$resolve: async (val, get) => {
|
||||||
|
if (typeof val === 'string') {
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
// https://github.com/vitejs/vite-plugin-vue/issues/528
|
||||||
|
const useDecorators = await get('experimental').then(r => r?.decorators === true)
|
||||||
|
if (useDecorators) {
|
||||||
|
return 'es2024'
|
||||||
|
}
|
||||||
|
return 'esnext'
|
||||||
|
},
|
||||||
|
},
|
||||||
jsxFactory: 'h',
|
jsxFactory: 'h',
|
||||||
jsxFragment: 'Fragment',
|
jsxFragment: 'Fragment',
|
||||||
tsconfigRaw: {
|
tsconfigRaw: {
|
||||||
@ -19,12 +32,12 @@ export default defineResolvers({
|
|||||||
if (!useDecorators) {
|
if (!useDecorators) {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
return defu(val, {
|
// Force experimentalDecorators to false if decorators are enabled
|
||||||
|
return defu({
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
useDefineForClassFields: false,
|
|
||||||
experimentalDecorators: false,
|
experimentalDecorators: false,
|
||||||
},
|
},
|
||||||
} satisfies TransformOptions['tsconfigRaw'])
|
} satisfies TransformOptions['tsconfigRaw'], val)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user