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" ;
6
6
7
- import pkg from ' ./package.json' ;
8
- import { minifyConfig } from ' ./build/minifications' ;
7
+ import pkg from " ./package.json" ;
8
+ import { minifyConfig } from " ./build/minifications" ;
9
9
10
- const extensions = [ ' .ts' , ' .tsx' , ' .js' ] ;
10
+ const extensions = [ " .ts" , " .tsx" , " .js" ] ;
11
11
12
12
const resolverPlugin = resolve ( { extensions } ) ;
13
13
14
14
const babelPlugin = babel ( {
15
- babelHelpers : ' bundled' ,
15
+ babelHelpers : " bundled" ,
16
16
sourceMaps : true ,
17
17
extensions,
18
18
exclude : / n o d e _ m o d u l e s .* / ,
19
19
} ) ;
20
20
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
+
21
34
const createTerser = ( { inline } ) =>
22
35
terser (
23
36
minifyConfig ( {
@@ -26,67 +39,76 @@ const createTerser = ({ inline }) =>
26
39
} )
27
40
) ;
28
41
29
- const input = ' src/index.tsx' ;
42
+ const input = " src/index.tsx" ;
30
43
const external = [
31
44
...Object . keys ( pkg . devDependencies ) ,
32
45
...Object . keys ( pkg . peerDependencies ) ,
46
+ "effector-react/scope" ,
47
+ "react/jsx-runtime" ,
33
48
] ;
34
49
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
+
35
88
// eslint-disable-next-line import/no-anonymous-default-export
36
89
export default [
37
90
{
38
91
input,
39
- external : [ ' effector' , ' atomic-router' , ' effector-react' , ' react' ] ,
92
+ external : [ " effector" , " atomic-router" , " effector-react" , " react" ] ,
40
93
output : {
41
- name : ' atomicRouter' ,
94
+ name : " atomicRouter" ,
42
95
file : pkg . unpkg ,
43
- format : ' umd' ,
96
+ format : " umd" ,
44
97
sourcemap : true ,
45
98
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" ,
50
103
} ,
51
104
} ,
52
105
plugins : [
53
106
babelPlugin ,
54
107
resolverPlugin ,
55
108
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 }),
89
110
] ,
90
- plugins : [ resolverPlugin , dts ( ) ] ,
91
111
} ,
112
+ ...createConfigs ( { scope : false } ) ,
113
+ ...createConfigs ( { scope : true } ) ,
92
114
] ;
0 commit comments