@@ -30,40 +30,26 @@ import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_rep
30
30
31
31
const util = require ( './rollup.shared' ) ;
32
32
33
- const nodePlugins = function ( ) {
34
- return [
35
- typescriptPlugin ( {
36
- typescript,
37
- tsconfigOverride : {
38
- compilerOptions : {
39
- target : 'es2017'
40
- }
41
- } ,
42
- cacheDir : tmp . dirSync ( ) ,
43
- abortOnError : true ,
44
- transformers : [ util . removeAssertTransformer ]
45
- } ) ,
46
- json ( { preferConst : true } )
47
- ] ;
48
- } ;
33
+ const nodePlugins = [
34
+ typescriptPlugin ( {
35
+ typescript,
36
+ cacheDir : tmp . dirSync ( ) ,
37
+ abortOnError : true ,
38
+ transformers : [ util . removeAssertTransformer ]
39
+ } ) ,
40
+ json ( { preferConst : true } )
41
+ ] ;
49
42
50
- const browserPlugins = function ( ) {
51
- return [
52
- typescriptPlugin ( {
53
- typescript,
54
- tsconfigOverride : {
55
- compilerOptions : {
56
- target : 'es2017'
57
- }
58
- } ,
59
- cacheDir : tmp . dirSync ( ) ,
60
- abortOnError : true ,
61
- transformers : [ util . removeAssertAndPrefixInternalTransformer ]
62
- } ) ,
63
- json ( { preferConst : true } ) ,
64
- terser ( util . manglePrivatePropertiesOptions )
65
- ] ;
66
- } ;
43
+ const browserPlugins = [
44
+ typescriptPlugin ( {
45
+ typescript,
46
+ cacheDir : tmp . dirSync ( ) ,
47
+ abortOnError : true ,
48
+ transformers : [ util . removeAssertAndPrefixInternalTransformer ]
49
+ } ) ,
50
+ json ( { preferConst : true } ) ,
51
+ terser ( util . manglePrivatePropertiesOptions )
52
+ ] ;
67
53
68
54
const allBuilds = [
69
55
// Intermediate Node ESM build without build target reporting
@@ -78,7 +64,7 @@ const allBuilds = [
78
64
} ,
79
65
plugins : [
80
66
alias ( util . generateAliasConfig ( 'node_lite' ) ) ,
81
- ...nodePlugins ( ) ,
67
+ ...nodePlugins ,
82
68
replace ( {
83
69
'__RUNTIME_ENV__' : 'node'
84
70
} )
@@ -89,7 +75,31 @@ const allBuilds = [
89
75
} ,
90
76
onwarn : util . onwarn
91
77
} ,
92
- // TODO: Node CJS build
78
+ // Node CJS build
79
+ {
80
+ input : path . resolve ( './lite' , pkg [ 'main-esm' ] ) ,
81
+ output : {
82
+ file : path . resolve ( './lite' , pkg . main ) ,
83
+ format : 'cjs' ,
84
+ sourcemap : true
85
+ } ,
86
+ plugins : [
87
+ typescriptPlugin ( {
88
+ typescript,
89
+ compilerOptions : {
90
+ allowJs : true ,
91
+ } ,
92
+ include : [ 'dist/lite/*.js' ]
93
+ } ) ,
94
+ json ( ) ,
95
+ sourcemaps ( ) ,
96
+ replace ( generateBuildTargetReplaceConfig ( 'cjs' , 2017 ) )
97
+ ] ,
98
+ external : util . resolveNodeExterns ,
99
+ treeshake : {
100
+ moduleSideEffects : false
101
+ }
102
+ } ,
93
103
// Node ESM build
94
104
{
95
105
input : path . resolve ( './lite' , pkg [ 'main-esm' ] ) ,
@@ -119,7 +129,7 @@ const allBuilds = [
119
129
} ,
120
130
plugins : [
121
131
alias ( util . generateAliasConfig ( 'browser_lite' ) ) ,
122
- ...browserPlugins ( ) ,
132
+ ...browserPlugins ,
123
133
// setting it to empty string because browser is the default env
124
134
replace ( {
125
135
'__RUNTIME_ENV__' : ''
@@ -178,7 +188,7 @@ const allBuilds = [
178
188
} ,
179
189
plugins : [
180
190
alias ( util . generateAliasConfig ( 'rn_lite' ) ) ,
181
- ...browserPlugins ( ) ,
191
+ ...browserPlugins ,
182
192
replace ( {
183
193
...generateBuildTargetReplaceConfig ( 'esm' , 2017 ) ,
184
194
'__RUNTIME_ENV__' : 'rn'
0 commit comments