@@ -90,7 +90,7 @@ export async function createSFCModule(source : string, filename : AbstractPath,
90
90
91
91
const component = { } ;
92
92
93
- const { delimiters, moduleCache, compiledCache, getResource, addStyle, log, additionalBabelPlugins = [ ] , customBlockHandler } = options ;
93
+ const { delimiters, moduleCache, compiledCache, getResource, addStyle, log, additionalBabelPlugins = { } , customBlockHandler } = options ;
94
94
95
95
// vue-loader next: https://github.com/vuejs/vue-loader/blob/next/src/index.ts#L91
96
96
const { descriptor, errors } = sfc_parse ( source , {
@@ -140,16 +140,15 @@ export async function createSFCModule(source : string, filename : AbstractPath,
140
140
141
141
// TBD: handle <script setup src="...
142
142
143
+ const babelParserPlugins : babel_ParserPlugin [ ] = [ ] ;
143
144
144
- const [ depsList , transformedScriptSource ] = await withCache ( compiledCache , [ componentHash , descriptor . script ?. content , descriptor . scriptSetup ?. content ] , async ( { preventCache } ) => {
145
-
146
- const babelParserPlugins : babel_ParserPlugin [ ] = [ ] ;
145
+ const [ depsList , transformedScriptSource ] = await withCache ( compiledCache , [ componentHash , descriptor . script ?. content , descriptor . scriptSetup ?. content , JSON . stringify ( babelParserPlugins ) , Object . keys ( additionalBabelPlugins ) ] , async ( { preventCache } ) => {
147
146
148
147
// src: https://github.com/vuejs/vue-next/blob/15baaf14f025f6b1d46174c9713a2ec517741d0d/packages/compiler-sfc/src/compileScript.ts#L43
149
148
const scriptBlock = sfc_compileScript ( descriptor , {
150
149
isProd,
151
150
id : scopeId ,
152
- babelParserPlugins,
151
+ babelParserPlugins, // [...babelParserDefaultPlugins, 'jsx'] + babelParserPlugins // babelParserDefaultPlugins = [ 'bigInt', 'optionalChaining', 'nullishCoalescingOperator' ]
153
152
// doc: https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md#inline-template-mode
154
153
// vue-loader next : https://github.com/vuejs/vue-loader/blob/12aaf2ea77add8654c50c8751bad135f1881e53f/src/resolveScript.ts#L59
155
154
inlineTemplate : false ,
@@ -174,7 +173,7 @@ export async function createSFCModule(source : string, filename : AbstractPath,
174
173
// if: https://github.com/babel/babel/blob/main/packages/babel-parser/typings/babel-parser.d.ts#L24
175
174
plugins : [
176
175
// see https://github.com/vuejs/vue-next/blob/15baaf14f025f6b1d46174c9713a2ec517741d0d/packages/compiler-sfc/src/compileScript.ts#L63
177
- ...vue_babelParserDefaultPlugins ,
176
+ ...vue_babelParserDefaultPlugins , // [ 'bigInt', 'optionalChaining', 'nullishCoalescingOperator' ]
178
177
'jsx' ,
179
178
...babelParserPlugins
180
179
] ,
@@ -207,7 +206,7 @@ export async function createSFCModule(source : string, filename : AbstractPath,
207
206
jsx ,
208
207
pluginProposalOptionalChaining ,
209
208
pluginProposalNullishCoalescingOperator ,
210
- ...additionalBabelPlugins ,
209
+ ...Object . values ( additionalBabelPlugins ) ,
211
210
] ,
212
211
babelrc : false ,
213
212
configFile : false ,
0 commit comments