1- import babel from ' @rollup/plugin-babel' ;
2- import commonjs from ' @rollup/plugin-commonjs' ;
3- import dts from ' rollup-plugin-dts' ;
4- import resolve from ' @rollup/plugin-node-resolve' ;
5- import { terser } from ' rollup-plugin-terser' ;
1+ import babel from " @rollup/plugin-babel" ;
2+ import commonjs from " @rollup/plugin-commonjs" ;
3+ import dts from " rollup-plugin-dts" ;
4+ import resolve from " @rollup/plugin-node-resolve" ;
5+ import { terser } from " rollup-plugin-terser" ;
66
7- import pkg from ' ./package.json' ;
8- import { minifyConfig } from ' ./build/minifications' ;
7+ import pkg from " ./package.json" ;
8+ import { minifyConfig } from " ./build/minifications" ;
99
10- const extensions = [ ' .ts' , ' .tsx' , ' .js' ] ;
10+ const extensions = [ " .ts" , " .tsx" , " .js" ] ;
1111
1212const resolverPlugin = resolve ( { extensions } ) ;
1313
1414const babelPlugin = babel ( {
15- babelHelpers : ' bundled' ,
15+ babelHelpers : " bundled" ,
1616 sourceMaps : true ,
1717 extensions,
1818 exclude : / n o d e _ m o d u l e s .* / ,
1919} ) ;
2020
21+ const babelPluginScope = babel ( {
22+ babelHelpers : "bundled" ,
23+ sourceMaps : true ,
24+ extensions,
25+ exclude : / n o d e _ m o d u l e s .* / ,
26+ overrides : [
27+ {
28+ test : ( ) => true ,
29+ plugins : [ [ "effector/babel-plugin" , { reactSsr : true , noDefaults : true } , "scoped" ] ] ,
30+ } ,
31+ ] ,
32+ } ) ;
33+
2134const createTerser = ( { inline } ) =>
2235 terser (
2336 minifyConfig ( {
@@ -26,67 +39,76 @@ const createTerser = ({ inline }) =>
2639 } )
2740 ) ;
2841
29- const input = ' src/index.tsx' ;
42+ const input = " src/index.tsx" ;
3043const external = [
3144 ...Object . keys ( pkg . devDependencies ) ,
3245 ...Object . keys ( pkg . peerDependencies ) ,
46+ "effector-react/scope" ,
47+ "react/jsx-runtime" ,
3348] ;
3449
50+ function createConfigs ( { scope } ) {
51+ return [
52+ {
53+ input,
54+ external,
55+ output : [
56+ {
57+ file : scope ? pkg . exports [ "./scope" ] . require : pkg . exports [ "." ] . require ,
58+ format : "cjs" ,
59+ sourcemap : true ,
60+ } ,
61+ {
62+ file : scope ? pkg . exports [ "./scope" ] . import : pkg . exports [ "." ] . import ,
63+ format : "es" ,
64+ sourcemap : true ,
65+ } ,
66+ ] ,
67+ plugins : [
68+ scope ? babelPluginScope : babelPlugin ,
69+ resolverPlugin ,
70+ commonjs ( ) ,
71+ // createTerser({ inline: true }),
72+ ] ,
73+ } ,
74+ {
75+ input,
76+ external,
77+ output : [
78+ {
79+ file : pkg . types ,
80+ format : "es" ,
81+ } ,
82+ ] ,
83+ plugins : [ resolverPlugin , dts ( ) ] ,
84+ } ,
85+ ] ;
86+ }
87+
3588// eslint-disable-next-line import/no-anonymous-default-export
3689export default [
3790 {
3891 input,
39- external : [ ' effector' , ' atomic-router' , ' effector-react' , ' react' ] ,
92+ external : [ " effector" , " atomic-router" , " effector-react" , " react" ] ,
4093 output : {
41- name : ' atomicRouter' ,
94+ name : " atomicRouter" ,
4295 file : pkg . unpkg ,
43- format : ' umd' ,
96+ format : " umd" ,
4497 sourcemap : true ,
4598 globals : {
46- effector : ' effector' ,
47- ' effector-react' : ' effectorReact' ,
48- ' atomic-router' : ' atomicRouter' ,
49- react : ' React' ,
99+ effector : " effector" ,
100+ " effector-react" : " effectorReact" ,
101+ " atomic-router" : " atomicRouter" ,
102+ react : " React" ,
50103 } ,
51104 } ,
52105 plugins : [
53106 babelPlugin ,
54107 resolverPlugin ,
55108 commonjs ( ) ,
56- createTerser ( { inline : false } ) ,
57- ] ,
58- } ,
59- {
60- input,
61- external,
62- output : [
63- {
64- file : pkg . main ,
65- format : 'cjs' ,
66- sourcemap : true ,
67- } ,
68- {
69- file : pkg . module ,
70- format : 'es' ,
71- sourcemap : true ,
72- } ,
73- ] ,
74- plugins : [
75- babelPlugin ,
76- resolverPlugin ,
77- commonjs ( ) ,
78- createTerser ( { inline : true } ) ,
79- ] ,
80- } ,
81- {
82- input,
83- external,
84- output : [
85- {
86- file : pkg . types ,
87- format : 'es' ,
88- } ,
109+ // createTerser({ inline: false }),
89110 ] ,
90- plugins : [ resolverPlugin , dts ( ) ] ,
91111 } ,
112+ ...createConfigs ( { scope : false } ) ,
113+ ...createConfigs ( { scope : true } ) ,
92114] ;
0 commit comments