@@ -19,6 +19,8 @@ import commonjs from 'rollup-plugin-commonjs'
19
19
import replace from 'rollup-plugin-replace'
20
20
//$off
21
21
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
22
+ //$off
23
+ import analyze from 'rollup-plugin-visualizer'
22
24
23
25
import graphPlugin from './moduleGraphGenerator'
24
26
import { dir , getSourcemapPathTransform } from './utils'
@@ -130,7 +132,7 @@ const minifyConfig = ({beautify}: {beautify: boolean}) => ({
130
132
warnings : true ,
131
133
} )
132
134
133
- const getPlugins = ( ) => ( {
135
+ const getPlugins = ( name : string ) => ( {
134
136
babel : babel ( {
135
137
runtimeHelpers : false ,
136
138
exclude : / ( \. r e | n o d e _ m o d u l e s .* ) / ,
@@ -141,6 +143,10 @@ const getPlugins = () => ({
141
143
commonjs : commonjs ( { } ) ,
142
144
resolve : resolve ( { } ) ,
143
145
sizeSnapshot : sizeSnapshot ( ) ,
146
+ analyzer : analyze ( {
147
+ filename : `stats/${ name } .html` ,
148
+ sourcemap : true
149
+ } ) ,
144
150
terser : terser (
145
151
minifyConfig ( {
146
152
beautify : ! ! process . env . PRETTIFY ,
@@ -152,7 +158,7 @@ const getPlugins = () => ({
152
158
} )
153
159
154
160
export async function rollupBabel ( name : string , plugin : * ) {
155
- const plugins = getPlugins ( )
161
+ const plugins = getPlugins ( name )
156
162
const terserConfig = minifyConfig ( {
157
163
beautify : true ,
158
164
} )
@@ -185,7 +191,7 @@ export async function rollupEffector() {
185
191
await Promise . all ( [ cjsAndEs ( ) , umd ( ) ] )
186
192
187
193
async function cjsAndEs ( ) {
188
- const plugins = getPlugins ( )
194
+ const plugins = getPlugins ( name )
189
195
const build = await rollup ( {
190
196
input : ( dir ( `packages/${ name } /index.js` ) : string ) ,
191
197
external : [
@@ -203,6 +209,7 @@ export async function rollupEffector() {
203
209
plugins . graph ,
204
210
plugins . sizeSnapshot ,
205
211
plugins . terser ,
212
+ plugins . analyzer ,
206
213
] ,
207
214
} )
208
215
@@ -224,7 +231,7 @@ export async function rollupEffector() {
224
231
] )
225
232
}
226
233
async function umd ( ) {
227
- const plugins = getPlugins ( )
234
+ const plugins = getPlugins ( ` ${ name } .umd` )
228
235
//$off
229
236
const build = await rollup ( {
230
237
input : String ( dir ( `packages/${ name } /index.js` ) ) ,
@@ -233,8 +240,9 @@ export async function rollupEffector() {
233
240
plugins . babel ,
234
241
plugins . replace ,
235
242
plugins . commonjs ,
236
- // plugins.terser,
237
243
plugins . sizeSnapshot ,
244
+ plugins . terser ,
245
+ plugins . analyzer ,
238
246
] ,
239
247
external : [ 'react' , 'effector' ] ,
240
248
} )
@@ -254,7 +262,7 @@ export async function rollupEffectorForms() {
254
262
await Promise . all ( [ cjsAndEs ( ) , umd ( ) ] )
255
263
256
264
async function cjsAndEs ( ) {
257
- const plugins = getPlugins ( )
265
+ const plugins = getPlugins ( name )
258
266
const build = await rollup ( {
259
267
input : ( dir ( `packages/${ name } /index.js` ) : string ) ,
260
268
external : [
@@ -271,6 +279,7 @@ export async function rollupEffectorForms() {
271
279
plugins . babel ,
272
280
plugins . sizeSnapshot ,
273
281
plugins . terser ,
282
+ plugins . analyzer ,
274
283
] ,
275
284
} )
276
285
@@ -292,7 +301,7 @@ export async function rollupEffectorForms() {
292
301
] )
293
302
}
294
303
async function umd ( ) {
295
- const plugins = getPlugins ( )
304
+ const plugins = getPlugins ( ` ${ name } .umd` )
296
305
//$off
297
306
const build = await rollup ( {
298
307
input : String ( dir ( `packages/${ name } /index.js` ) ) ,
@@ -303,6 +312,7 @@ export async function rollupEffectorForms() {
303
312
plugins . commonjs ,
304
313
plugins . sizeSnapshot ,
305
314
plugins . terser ,
315
+ plugins . analyzer ,
306
316
] ,
307
317
external : [ 'react' , 'effector' ] ,
308
318
} )
@@ -322,7 +332,7 @@ export async function rollupEffectorReact() {
322
332
await Promise . all ( [ cjsAndEs ( ) , umd ( ) ] )
323
333
324
334
async function cjsAndEs ( ) {
325
- const plugins = getPlugins ( )
335
+ const plugins = getPlugins ( name )
326
336
const build = await rollup ( {
327
337
input : ( dir ( `packages/${ name } /index.js` ) : string ) ,
328
338
external : [
@@ -339,6 +349,7 @@ export async function rollupEffectorReact() {
339
349
plugins . babel ,
340
350
plugins . sizeSnapshot ,
341
351
plugins . terser ,
352
+ plugins . analyzer ,
342
353
] ,
343
354
} )
344
355
@@ -360,7 +371,7 @@ export async function rollupEffectorReact() {
360
371
] )
361
372
}
362
373
async function umd ( ) {
363
- const plugins = getPlugins ( )
374
+ const plugins = getPlugins ( ` ${ name } .umd` )
364
375
//$off
365
376
const build = await rollup ( {
366
377
input : String ( dir ( `packages/${ name } /index.js` ) ) ,
@@ -371,6 +382,7 @@ export async function rollupEffectorReact() {
371
382
plugins . commonjs ,
372
383
plugins . sizeSnapshot ,
373
384
plugins . terser ,
385
+ plugins . analyzer ,
374
386
] ,
375
387
external : [ 'react' , 'effector' ] ,
376
388
} )
@@ -408,7 +420,7 @@ export async function rollupEffectorVue() {
408
420
await Promise . all ( [ cjsAndEs ( ) , umd ( ) ] )
409
421
410
422
async function cjsAndEs ( ) {
411
- const plugins = getPlugins ( )
423
+ const plugins = getPlugins ( name )
412
424
const build = await rollup ( {
413
425
input : ( dir ( `packages/${ name } /index.js` ) : string ) ,
414
426
external : [
@@ -425,6 +437,7 @@ export async function rollupEffectorVue() {
425
437
plugins . babel ,
426
438
plugins . sizeSnapshot ,
427
439
plugins . terser ,
440
+ plugins . analyzer ,
428
441
] ,
429
442
} )
430
443
await Promise . all ( [
@@ -445,7 +458,7 @@ export async function rollupEffectorVue() {
445
458
] )
446
459
}
447
460
async function umd ( ) {
448
- const plugins = getPlugins ( )
461
+ const plugins = getPlugins ( ` ${ name } .umd` )
449
462
//$off
450
463
const build = await rollup ( {
451
464
input : String ( dir ( `packages/${ name } /index.js` ) ) ,
@@ -456,6 +469,7 @@ export async function rollupEffectorVue() {
456
469
plugins . commonjs ,
457
470
plugins . sizeSnapshot ,
458
471
plugins . terser ,
472
+ plugins . analyzer ,
459
473
] ,
460
474
external : [ 'vue' , 'effector' ] ,
461
475
} )
0 commit comments