File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -3,36 +3,36 @@ module.exports = () => {
33
44 const rollupConfig = getRollupConfig ( )
55
6- const commonJsIndex = rollupConfig . plugins . findIndex (
7- plugin => plugin . name === 'commonjs' ,
8- )
9-
10- if ( commonJsIndex >= 0 ) {
6+ replace ( rollupConfig . plugins , 'commonjs' , ( ) => {
117 const commonjs = require ( 'rollup-plugin-commonjs' )
128
13- rollupConfig . plugins [ commonJsIndex ] = commonjs ( {
9+ return commonjs ( {
1410 include : 'node_modules/**' ,
1511 namedExports : {
1612 'react-is' : [ 'isValidElementType' ] ,
1713 } ,
1814 } )
19- }
15+ } )
2016
2117 if ( process . env . BUILD_FORMAT !== 'umd' ) {
22- const babelIndex = rollupConfig . plugins . findIndex (
23- plugin => plugin . name === 'babel' ,
24- )
25-
26- if ( babelIndex >= 0 ) {
18+ replace ( rollupConfig . plugins , 'babel' , ( ) => {
2719 const babel = require ( 'rollup-plugin-babel' )
2820
29- rollupConfig . plugins [ babelIndex ] = babel ( {
21+ return babel ( {
3022 exclude : 'node_modules/**' ,
3123 babelrc : true ,
3224 runtimeHelpers : true ,
3325 } )
34- }
26+ } )
3527 }
3628
3729 return rollupConfig
3830}
31+
32+ function replace ( plugins , name , factory ) {
33+ const idx = plugins . findIndex ( plugin => plugin . name === name )
34+
35+ if ( idx >= 0 ) {
36+ plugins [ idx ] = factory ( plugins [ idx ] )
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments