@@ -4,26 +4,44 @@ import commonjs from '@rollup/plugin-commonjs'
44import nodeResolve from '@rollup/plugin-node-resolve'
55import replace from '@rollup/plugin-replace'
66import { terser } from 'rollup-plugin-terser'
7- import { unpkg } from './package.json'
7+ import { dependencies , exports , optionalDependencies , peerDependencies , unpkg } from './package.json'
88
9- export default {
10- external : [ '@cdoublev/animate' , 'react' , 'prop-types' ] ,
11- input : 'src/index.js' ,
12- output : {
13- file : unpkg ,
14- format : 'umd' ,
15- globals : {
16- '@cdoublev/animate' : 'animate' ,
17- 'prop-types' : 'PropTypes' ,
18- 'react' : 'React' ,
9+ export default process . env . NODE_ENV === 'cjs'
10+ ? {
11+ input : 'src/index.js' ,
12+ external : new RegExp ( `^(${
13+ Object . keys ( {
14+ ...dependencies ,
15+ ...optionalDependencies ,
16+ ...peerDependencies ,
17+ } ) . join ( '|' ) } )`) ,
18+ output : {
19+ file : exports [ '.' ] . require ,
20+ format : 'cjs' ,
1921 } ,
20- name : 'ReactUtils' ,
21- } ,
22- plugins : [
23- replace ( { 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) } ) ,
24- nodeResolve ( ) ,
25- babel ( { babelHelpers : 'bundled' } ) ,
26- commonjs ( ) ,
27- terser ( ) ,
28- ] ,
29- }
22+ plugins : [
23+ babel ( { babelHelpers : 'runtime' } ) ,
24+ commonjs ( ) ,
25+ ] ,
26+ }
27+ : {
28+ external : [ '@cdoublev/animate' , 'react' , 'prop-types' ] ,
29+ input : 'src/index.js' ,
30+ output : {
31+ file : unpkg ,
32+ format : 'umd' ,
33+ globals : {
34+ '@cdoublev/animate' : 'animate' ,
35+ 'prop-types' : 'PropTypes' ,
36+ 'react' : 'React' ,
37+ } ,
38+ name : 'ReactUtils' ,
39+ } ,
40+ plugins : [
41+ replace ( { 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) } ) ,
42+ nodeResolve ( ) ,
43+ babel ( { babelHelpers : 'bundled' } ) ,
44+ commonjs ( ) ,
45+ terser ( ) ,
46+ ] ,
47+ }
0 commit comments