@@ -250,44 +250,44 @@ self.addEventListener('message', async event => {
250250 lastConfig = stringifiedConfig ;
251251 }
252252
253- const flattenedPresets = flatten ( config . presets || [ ] ) ;
254- const flattenedPlugins = flatten ( config . plugins || [ ] ) ;
253+ const codeSandboxFlattenedPresets = flatten ( config . presets || [ ] ) ;
254+ const codeSandboxFlattenedPlugins = flatten ( config . plugins || [ ] ) ;
255255
256256 if ( ! disableCodeSandboxPlugins ) {
257257 if (
258- flattenedPresets . indexOf ( 'env' ) > - 1 &&
258+ codeSandboxFlattenedPresets . indexOf ( 'env' ) > - 1 &&
259259 Object . keys ( Babel . availablePresets ) . indexOf ( 'env' ) === - 1 &&
260260 version !== 7
261261 ) {
262262 Babel . registerPreset ( 'env' , Babel . availablePresets . latest ) ;
263263 }
264264
265265 if (
266- flattenedPresets . indexOf ( 'env' ) > - 1 &&
266+ codeSandboxFlattenedPresets . indexOf ( 'env' ) > - 1 &&
267267 Object . keys ( Babel . availablePresets ) . indexOf ( 'env' ) === - 1 &&
268268 version === 7
269269 ) {
270270 Babel . registerPreset ( 'env' , Babel . availablePresets . es2015 ) ;
271271 }
272272
273273 if (
274- flattenedPlugins . indexOf ( 'transform-vue-jsx' ) > - 1 &&
274+ codeSandboxFlattenedPlugins . indexOf ( 'transform-vue-jsx' ) > - 1 &&
275275 Object . keys ( Babel . availablePlugins ) . indexOf ( 'transform-vue-jsx' ) === - 1
276276 ) {
277277 const vuePlugin = await import ( /* webpackChunkName: 'babel-plugin-transform-vue-jsx' */ 'babel-plugin-transform-vue-jsx' ) ;
278278 Babel . registerPlugin ( 'transform-vue-jsx' , vuePlugin ) ;
279279 }
280280
281281 if (
282- flattenedPlugins . indexOf ( 'jsx-pragmatic' ) > - 1 &&
282+ codeSandboxFlattenedPlugins . indexOf ( 'jsx-pragmatic' ) > - 1 &&
283283 Object . keys ( Babel . availablePlugins ) . indexOf ( 'jsx-pragmatic' ) === - 1
284284 ) {
285285 const pragmaticPlugin = await import ( /* webpackChunkName: 'babel-plugin-jsx-pragmatic' */ 'babel-plugin-jsx-pragmatic' ) ;
286286 Babel . registerPlugin ( 'jsx-pragmatic' , pragmaticPlugin ) ;
287287 }
288288
289289 if (
290- flattenedPlugins . indexOf ( 'transform-cx-jsx' ) > - 1 &&
290+ codeSandboxFlattenedPlugins . indexOf ( 'transform-cx-jsx' ) > - 1 &&
291291 Object . keys ( Babel . availablePlugins ) . indexOf ( 'transform-cx-jsx' ) === - 1
292292 ) {
293293 const cxJsxPlugin = await import ( /* webpackChunkName: 'transform-cx-jsx' */ 'babel-plugin-transform-cx-jsx' ) ;
@@ -297,56 +297,60 @@ self.addEventListener('message', async event => {
297297
298298 try {
299299 await Promise . all (
300- flattenedPlugins . filter ( p => typeof p === 'string' ) . map ( async p => {
301- const normalizedName = p
302- . replace ( 'babel-plugin-' , '' )
303- . replace ( '@babel/plugin-' , '' ) ;
304- if (
305- ! Babel . availablePlugins [ normalizedName ] &&
306- ! Babel . availablePlugins [ p ]
307- ) {
308- try {
309- await installPlugin (
310- Babel ,
311- BrowserFS . BFSRequire ,
312- p ,
313- path ,
314- ! Babel . version . startsWith ( '6' )
315- ) ;
316- } catch ( e ) {
317- throw new Error (
318- `Could not find/install babel plugin '${ p } ': ${ e . message } `
319- ) ;
300+ codeSandboxFlattenedPlugins
301+ . filter ( p => typeof p === 'string' )
302+ . map ( async p => {
303+ const normalizedName = p
304+ . replace ( 'babel-plugin-' , '' )
305+ . replace ( '@babel/plugin-' , '' ) ;
306+ if (
307+ ! Babel . availablePlugins [ normalizedName ] &&
308+ ! Babel . availablePlugins [ p ]
309+ ) {
310+ try {
311+ await installPlugin (
312+ Babel ,
313+ BrowserFS . BFSRequire ,
314+ p ,
315+ path ,
316+ ! Babel . version . startsWith ( '6' )
317+ ) ;
318+ } catch ( e ) {
319+ throw new Error (
320+ `Could not find/install babel plugin '${ p } ': ${ e . message } `
321+ ) ;
322+ }
320323 }
321- }
322- } )
324+ } )
323325 ) ;
324326
325327 await Promise . all (
326- flattenedPresets . filter ( p => typeof p === 'string' ) . map ( async p => {
327- const normalizedName = p
328- . replace ( 'babel-preset-' , '' )
329- . replace ( '@babel/preset-' , '' ) ;
330-
331- if (
332- ! Babel . availablePresets [ normalizedName ] &&
333- ! Babel . availablePresets [ p ]
334- ) {
335- try {
336- await installPreset (
337- Babel ,
338- BrowserFS . BFSRequire ,
339- p ,
340- path ,
341- ! Babel . version . startsWith ( '6' )
342- ) ;
343- } catch ( e ) {
344- throw new Error (
345- `Could not find/install babel preset '${ p } ': ${ e . message } `
346- ) ;
328+ codeSandboxFlattenedPresets
329+ . filter ( p => typeof p === 'string' )
330+ . map ( async p => {
331+ const normalizedName = p
332+ . replace ( 'babel-preset-' , '' )
333+ . replace ( '@babel/preset-' , '' ) ;
334+
335+ if (
336+ ! Babel . availablePresets [ normalizedName ] &&
337+ ! Babel . availablePresets [ p ]
338+ ) {
339+ try {
340+ await installPreset (
341+ Babel ,
342+ BrowserFS . BFSRequire ,
343+ p ,
344+ path ,
345+ ! Babel . version . startsWith ( '6' )
346+ ) ;
347+ } catch ( e ) {
348+ throw new Error (
349+ `Could not find/install babel preset '${ p } ': ${ e . message } `
350+ ) ;
351+ }
347352 }
348- }
349- } )
353+ } )
350354 ) ;
351355
352356 const plugins = [ ...( config . plugins || [ ] ) ] ;
0 commit comments