1
1
const notifier = require ( 'node-notifier' )
2
2
const relative = require ( 'path' ) . relative
3
3
4
- const babelClientOpts = {
5
- presets : [
6
- '@babel/preset-typescript' ,
7
- [
8
- '@babel/preset-env' ,
9
- {
10
- modules : 'commonjs' ,
11
- targets : {
12
- esmodules : true ,
13
- } ,
14
- loose : true ,
15
- exclude : [ 'transform-typeof-symbol' ] ,
16
- } ,
17
- ] ,
18
- '@babel/preset-react' ,
19
- ] ,
20
- plugins : [
21
- // workaround for @taskr /esnext bug replacing `-import` with `-require(`
22
- // eslint-disable-next-line no-useless-concat
23
- '@babel/plugin-syntax-dynamic-impor' + 't' ,
24
- [ '@babel/plugin-proposal-class-properties' , { loose : true } ] ,
25
- [
26
- '@babel/plugin-transform-runtime' ,
27
- {
28
- corejs : 2 ,
29
- helpers : true ,
30
- regenerator : false ,
31
- useESModules : false ,
32
- } ,
33
- ] ,
34
- ] ,
35
- }
36
-
37
- const babelServerOpts = {
38
- presets : [
39
- '@babel/preset-typescript' ,
40
- [
41
- '@babel/preset-env' ,
42
- {
43
- modules : 'commonjs' ,
44
- targets : {
45
- node : '8.3' ,
46
- } ,
47
- loose : true ,
48
- exclude : [ 'transform-typeof-symbol' ] ,
49
- } ,
50
- ] ,
51
- ] ,
52
- plugins : [
53
- '@babel/plugin-proposal-optional-chaining' ,
54
- '@babel/plugin-proposal-nullish-coalescing-operator' ,
55
- 'babel-plugin-dynamic-import-node' ,
56
- [ '@babel/plugin-proposal-class-properties' , { loose : true } ] ,
57
- ] ,
58
- }
59
-
60
4
// eslint-disable-next-line camelcase
61
5
export async function ncc_arg ( task , opts ) {
62
6
await task
@@ -126,52 +70,47 @@ export async function compile(task) {
126
70
export async function bin ( task , opts ) {
127
71
await task
128
72
. source ( opts . src || 'bin/*' )
129
- . babel ( babelServerOpts , { stripExtension : true } )
73
+ . babel ( 'server' , { stripExtension : true } )
130
74
. target ( 'dist/bin' , { mode : '0755' } )
131
75
notify ( 'Compiled binaries' )
132
76
}
133
77
134
78
export async function cli ( task , opts ) {
135
79
await task
136
80
. source ( opts . src || 'cli/**/*.+(js|ts|tsx)' )
137
- . babel ( babelServerOpts )
81
+ . babel ( 'server' )
138
82
. target ( 'dist/cli' )
139
83
notify ( 'Compiled cli files' )
140
84
}
141
85
142
86
export async function lib ( task , opts ) {
143
87
await task
144
88
. source ( opts . src || 'lib/**/*.+(js|ts|tsx)' )
145
- . babel ( babelServerOpts )
89
+ . babel ( 'server' )
146
90
. target ( 'dist/lib' )
147
91
notify ( 'Compiled lib files' )
148
92
}
149
93
150
94
export async function server ( task , opts ) {
151
- const babelOpts = {
152
- ...babelServerOpts ,
153
- // the /server files may use React
154
- presets : [ ...babelServerOpts . presets , '@babel/preset-react' ] ,
155
- }
156
95
await task
157
96
. source ( opts . src || 'server/**/*.+(js|ts|tsx)' )
158
- . babel ( babelOpts )
97
+ . babel ( 'server' )
159
98
. target ( 'dist/server' )
160
99
notify ( 'Compiled server files' )
161
100
}
162
101
163
102
export async function nextbuild ( task , opts ) {
164
103
await task
165
104
. source ( opts . src || 'build/**/*.+(js|ts|tsx)' )
166
- . babel ( babelServerOpts )
105
+ . babel ( 'server' )
167
106
. target ( 'dist/build' )
168
107
notify ( 'Compiled build files' )
169
108
}
170
109
171
110
export async function client ( task , opts ) {
172
111
await task
173
112
. source ( opts . src || 'client/**/*.+(js|ts|tsx)' )
174
- . babel ( babelClientOpts )
113
+ . babel ( 'client' )
175
114
. target ( 'dist/client' )
176
115
notify ( 'Compiled client files' )
177
116
}
@@ -180,34 +119,29 @@ export async function client(task, opts) {
180
119
export async function nextbuildstatic ( task , opts ) {
181
120
await task
182
121
. source ( opts . src || 'export/**/*.+(js|ts|tsx)' )
183
- . babel ( babelServerOpts )
122
+ . babel ( 'server' )
184
123
. target ( 'dist/export' )
185
124
notify ( 'Compiled export files' )
186
125
}
187
126
188
127
export async function pages_app ( task ) {
189
128
await task
190
129
. source ( 'pages/_app.tsx' )
191
- . babel ( babelClientOpts )
130
+ . babel ( 'client' )
192
131
. target ( 'dist/pages' )
193
132
}
194
133
195
134
export async function pages_error ( task ) {
196
135
await task
197
136
. source ( 'pages/_error.tsx' )
198
- . babel ( babelClientOpts )
137
+ . babel ( 'client' )
199
138
. target ( 'dist/pages' )
200
139
}
201
140
202
141
export async function pages_document ( task ) {
203
- const babelOpts = {
204
- ...babelServerOpts ,
205
- presets : [ ...babelServerOpts . presets , '@babel/preset-react' ] ,
206
- }
207
-
208
142
await task
209
143
. source ( 'pages/_document.tsx' )
210
- . babel ( babelOpts )
144
+ . babel ( 'server' )
211
145
. target ( 'dist/pages' )
212
146
}
213
147
@@ -218,7 +152,7 @@ export async function pages(task, opts) {
218
152
export async function telemetry ( task , opts ) {
219
153
await task
220
154
. source ( opts . src || 'telemetry/**/*.+(js|ts|tsx)' )
221
- . babel ( babelServerOpts )
155
+ . babel ( 'server' )
222
156
. target ( 'dist/telemetry' )
223
157
notify ( 'Compiled telemetry files' )
224
158
}
0 commit comments