@@ -9,7 +9,6 @@ import { rollup, watch } from 'rollup';
9
9
import commonjs from 'rollup-plugin-commonjs' ;
10
10
import babel from 'rollup-plugin-babel' ;
11
11
import nodeResolve from 'rollup-plugin-node-resolve' ;
12
- import buble from 'rollup-plugin-buble' ;
13
12
import { terser } from 'rollup-plugin-terser' ;
14
13
import postcss from 'rollup-plugin-postcss' ;
15
14
import alias from 'rollup-plugin-strict-alias' ;
@@ -152,7 +151,7 @@ export default async function microbundle(options) {
152
151
for ( let i = 0 ; i < entries . length ; i ++ ) {
153
152
for ( let j = 0 ; j < formats . length ; j ++ ) {
154
153
steps . push (
155
- createConfig ( options , entries [ i ] , formats [ j ] , i === 0 && j === 0 ) ,
154
+ await createConfig ( options , entries [ i ] , formats [ j ] , i === 0 && j === 0 ) ,
156
155
) ;
157
156
}
158
157
}
@@ -226,7 +225,7 @@ export default async function microbundle(options) {
226
225
) ;
227
226
}
228
227
229
- function createConfig ( options , entry , format , writeMeta ) {
228
+ async function createConfig ( options , entry , format , writeMeta ) {
230
229
let { pkg } = options ;
231
230
232
231
let external = [ 'dns' , 'fs' , 'path' , 'url' ] . concat (
@@ -377,26 +376,46 @@ function createConfig(options, entry, format, writeMeta) {
377
376
} ,
378
377
} ) ,
379
378
! useTypescript && flow ( { all : true , pretty : true } ) ,
380
- // Only used for async await
381
- babel ( {
382
- // We mainly use bublé to transpile JS and only use babel to
383
- // transpile down `async/await`. To prevent conflicts with user
384
- // supplied configurations we set this option to false. Note
385
- // that we never supported using custom babel configs anyway.
386
- babelrc : false ,
387
- exclude : 'node_modules/**' ,
388
- plugins : [
389
- require . resolve ( '@babel/plugin-syntax-jsx' ) ,
390
- [
391
- require . resolve ( 'babel-plugin-transform-async-to-promises' ) ,
392
- { inlineHelpers : true , externalHelpers : true } ,
393
- ] ,
394
- [
395
- require . resolve ( '@babel/plugin-proposal-class-properties' ) ,
396
- { loose : true } ,
397
- ] ,
398
- ] ,
399
- } ) ,
379
+ babel (
380
+ ( await isFile ( '.babelrc' ) ) || ( await isFile ( '.babelrc.js' ) )
381
+ ? {
382
+ // Babelrc exists, allow project to configure babel
383
+ exclude : 'node_modules/**' ,
384
+ }
385
+ : {
386
+ // No babelrc exists, use default config
387
+ exclude : 'node_modules/**' ,
388
+ presets : [
389
+ [ '@babel/preset-react' , { pragma : options . jsx } ] ,
390
+ [
391
+ '@babel/preset-env' ,
392
+ {
393
+ loose : true ,
394
+ exclude : [
395
+ // Disabling preset-env async/await support so we can use
396
+ // plugin-transform-async-to-promises
397
+ 'transform-async-to-generator' ,
398
+ 'transform-regenerator' ,
399
+ ] ,
400
+ } ,
401
+ ] ,
402
+ ] ,
403
+ plugins : [
404
+ [
405
+ require . resolve (
406
+ 'babel-plugin-transform-async-to-promises' ,
407
+ ) ,
408
+ { inlineHelpers : true , externalHelpers : true } ,
409
+ ] ,
410
+ [
411
+ require . resolve (
412
+ '@babel/plugin-proposal-class-properties' ,
413
+ ) ,
414
+ { loose : true } ,
415
+ ] ,
416
+ ] ,
417
+ } ,
418
+ ) ,
400
419
{
401
420
// Custom plugin that removes shebang from code because newer
402
421
// versions of bublé bundle their own private version of `acorn`
@@ -419,15 +438,6 @@ function createConfig(options, entry, format, writeMeta) {
419
438
} ;
420
439
} ,
421
440
} ,
422
- buble ( {
423
- exclude : 'node_modules/**' ,
424
- jsx : options . jsx || 'h' ,
425
- objectAssign : options . assign || 'Object.assign' ,
426
- transforms : {
427
- dangerousForOf : true ,
428
- dangerousTaggedTemplateString : true ,
429
- } ,
430
- } ) ,
431
441
// We should upstream this to rollup
432
442
// format==='cjs' && replace({
433
443
// [`module.exports = ${rollupName};`]: '',
0 commit comments