Consolidate build process with GCC (#11483)
* Consolidate build process with GCC * Record sizes * Refactor header and footer wrapping It is easier to understand if we just explicitly type them out.
Dan Abramov committed
Nov 8, 2017 at 22:37 UTC
c83596df65b1df3f95154689a5cc0712b7b4de5d
7 files changed
+452
-456
package.json
+2
-2
@@ -83,13 +83,13 @@
83
"rollup-plugin-commonjs": "^8.2.6",
84
"rollup-plugin-inject": "^2.0.0",
85
"rollup-plugin-node-resolve": "^2.0.0",
86
+ "rollup-plugin-prettier": "^0.3.0",
87
"rollup-plugin-replace": "^1.1.1",
87
- "rollup-plugin-uglify": "^1.0.1",
88
+ "rollup-plugin-strip-banner": "^0.2.0",
89
"run-sequence": "^1.1.4",
90
"through2": "^2.0.0",
91
"tmp": "~0.0.28",
92
"typescript": "~1.8.10",
92
- "uglify-js": "^2.5.0",
93
"yargs": "^6.3.0"
94
},
95
"devEngines": {
scripts/circleci/check_modules.sh
+1
-1
@@ -5,7 +5,7 @@ set -e
5
# Make sure we don't introduce accidental @providesModule annotations.
6
EXPECTED='packages/react-cs-renderer/src/ReactNativeCSTypes.js
7
packages/react-native-renderer/src/ReactNativeTypes.js
8
-scripts/rollup/header.js'
8
+scripts/rollup/wrappers.js'
9
ACTUAL=$(git grep -l @providesModule -- './*.js' ':!scripts/rollup/shims/*.js')
10
11
if [ "$EXPECTED" != "$ACTUAL" ]; then
scripts/rollup/build.js
+93
-295
@@ -2,10 +2,12 @@
2
3
const rollup = require('rollup').rollup;
4
const babel = require('rollup-plugin-babel');
5
+const closure = require('rollup-plugin-closure-compiler-js');
6
const commonjs = require('rollup-plugin-commonjs');
7
const alias = require('rollup-plugin-alias');
7
-const uglify = require('rollup-plugin-uglify');
8
+const prettier = require('rollup-plugin-prettier');
9
const replace = require('rollup-plugin-replace');
10
+const stripBanner = require('rollup-plugin-strip-banner');
11
const chalk = require('chalk');
12
const join = require('path').join;
13
const resolve = require('path').resolve;
@@ -23,8 +25,7 @@ const syncReactNative = require('./sync').syncReactNative;
25
const syncReactNativeRT = require('./sync').syncReactNativeRT;
26
const syncReactNativeCS = require('./sync').syncReactNativeCS;
27
const Packaging = require('./packaging');
26
-const Header = require('./header');
27
-const closure = require('rollup-plugin-closure-compiler-js');
28
+const Wrappers = require('./wrappers');
29
30
const UMD_DEV = Bundles.bundleTypes.UMD_DEV;
31
const UMD_PROD = Bundles.bundleTypes.UMD_PROD;
@@ -35,9 +36,6 @@ const FB_PROD = Bundles.bundleTypes.FB_PROD;
36
const RN_DEV = Bundles.bundleTypes.RN_DEV;
37
const RN_PROD = Bundles.bundleTypes.RN_PROD;
38
38
-const RECONCILER = Bundles.moduleTypes.RECONCILER;
39
-
40
-const reactVersion = require('../../package.json').version;
39
const requestedBundleTypes = (argv.type || '')
40
.split(',')
41
.map(type => type.toUpperCase());
@@ -51,134 +49,16 @@ const errorCodeOpts = {
49
errorMapFilePath: 'scripts/error-codes/codes.json',
50
};
51
54
-function getHeaderSanityCheck(bundleType, globalName) {
55
- switch (bundleType) {
56
- case FB_DEV:
57
- case FB_PROD:
58
- case RN_DEV:
59
- case RN_PROD:
60
- let hasteFinalName = globalName;
61
- switch (bundleType) {
62
- case FB_DEV:
63
- case RN_DEV:
64
- hasteFinalName += '-dev';
65
- break;
66
- case FB_PROD:
67
- case RN_PROD:
68
- hasteFinalName += '-prod';
69
- break;
70
- }
71
- return hasteFinalName;
72
- case UMD_DEV:
73
- case UMD_PROD:
74
- return reactVersion;
75
- default:
76
- return null;
77
- }
78
-}
79
-
80
-function getBanner(bundleType, globalName, filename, moduleType) {
81
- if (moduleType === RECONCILER) {
82
- // Standalone reconciler is only used by third-party renderers.
83
- // It is handled separately.
84
- return getReconcilerBanner(bundleType, filename);
85
- }
86
-
87
- switch (bundleType) {
88
- // UMDs are not wrapped in conditions.
89
- case UMD_DEV:
90
- case UMD_PROD:
91
- return Header.getHeader(filename, reactVersion);
92
- // CommonJS DEV bundle is guarded to help weak dead code elimination.
93
- case NODE_DEV:
94
- let banner = Header.getHeader(filename, reactVersion);
95
- // Wrap the contents of the if-DEV check with an IIFE.
96
- // Block-level function definitions can cause problems for strict mode.
97
- banner += `'use strict';\n\n\nif (process.env.NODE_ENV !== "production") {\n(function() {\n`;
98
- return banner;
99
- case NODE_PROD:
100
- return Header.getHeader(filename, reactVersion);
101
- // All FB and RN bundles need Haste headers.
102
- // DEV bundle is guarded to help weak dead code elimination.
103
- case FB_DEV:
104
- case FB_PROD:
105
- case RN_DEV:
106
- case RN_PROD:
107
- const isDev = bundleType === FB_DEV || bundleType === RN_DEV;
108
- const hasteFinalName = globalName + (isDev ? '-dev' : '-prod');
109
- // Wrap the contents of the if-DEV check with an IIFE.
110
- // Block-level function definitions can cause problems for strict mode.
111
- return (
112
- Header.getProvidesHeader(hasteFinalName) +
113
- (isDev ? `\n\n'use strict';\n\n\nif (__DEV__) {\n(function() {\n` : '')
114
- );
115
- default:
116
- throw new Error('Unknown type.');
117
- }
118
-}
119
-
120
-function getFooter(bundleType, filename, moduleType) {
121
- if (moduleType === RECONCILER) {
122
- // Standalone reconciler is only used by third-party renderers.
123
- // It is handled separately.
124
- return getReconcilerFooter(bundleType);
125
- }
126
-
127
- // Only need a footer if getBanner() has an opening brace.
128
- switch (bundleType) {
129
- // Non-UMD DEV bundles need conditions to help weak dead code elimination.
130
- case NODE_DEV:
131
- case FB_DEV:
132
- case RN_DEV:
133
- return '\n})();\n}\n';
134
- default:
135
- return '';
136
- }
137
-}
138
-
139
-// TODO: this is extremely gross.
140
-// But it only affects the "experimental" standalone reconciler build.
141
-// The goal is to avoid having any shared state between renderers sharing it on npm.
142
-// Ideally we should just remove shared state in all Fiber modules and then lint against it.
143
-// But for now, we store the exported function in a variable, and then put the rest of the code
144
-// into a closure that makes all module-level state private to each call.
145
-const RECONCILER_WRAPPER_INTRO = `var $$$reconciler;\nmodule.exports = function(config) {\n`;
146
-const RECONCILER_WRAPPER_OUTRO = `return ($$$reconciler || ($$$reconciler = module.exports))(config);\n};\n`;
147
-
148
-function getReconcilerBanner(bundleType, filename) {
149
- let banner = `${Header.getHeader(
150
- filename,
151
- reactVersion
152
- )}\n\n'use strict';\n\n\n`;
153
- switch (bundleType) {
154
- case NODE_DEV:
155
- banner += `if (process.env.NODE_ENV !== "production") {\n${
156
- RECONCILER_WRAPPER_INTRO
157
- }`;
158
- break;
159
- case NODE_PROD:
160
- banner += RECONCILER_WRAPPER_INTRO;
161
- break;
162
- default:
163
- throw new Error(
164
- 'Standalone reconciler does not support ' + bundleType + ' builds.'
165
- );
166
- }
167
- return banner;
168
-}
169
-
170
-function getReconcilerFooter(bundleType) {
171
- switch (bundleType) {
172
- case NODE_DEV:
173
- return `\n${RECONCILER_WRAPPER_OUTRO}\n}`;
174
- case NODE_PROD:
175
- return `\n${RECONCILER_WRAPPER_OUTRO}`;
176
- default:
177
- throw new Error(
178
- 'Standalone reconciler does not support ' + bundleType + ' builds.'
179
- );
180
- }
181
-}
52
+const closureOptions = {
53
+ compilationLevel: 'SIMPLE',
54
+ languageIn: 'ECMASCRIPT5_STRICT',
55
+ languageOut: 'ECMASCRIPT5_STRICT',
56
+ env: 'CUSTOM',
57
+ warningLevel: 'QUIET',
58
+ applyInputSourceMaps: false,
59
+ useTypesForOptimization: false,
60
+ processCommonJsModules: false,
61
+};
62
63
function getBabelConfig(updateBabelOptions, bundleType, filename) {
64
let options = {
@@ -261,7 +141,6 @@ function getRollupOutputOptions(
141
return Object.assign(
142
{},
143
{
264
- banner: getBanner(bundleType, globalName, filename, moduleType),
144
destDir: 'build/',
145
file:
146
'build/' +
@@ -270,7 +149,6 @@ function getRollupOutputOptions(
149
filename,
150
globalName
151
),
273
- footer: getFooter(bundleType, filename, moduleType),
152
format,
153
globals,
154
interop: false,
@@ -280,13 +158,6 @@ function getRollupOutputOptions(
158
);
159
}
160
283
-function stripEnvVariables(production) {
284
- return {
285
- __DEV__: production ? 'false' : 'true',
286
- 'process.env.NODE_ENV': production ? "'production'" : "'development'",
287
- };
288
-}
289
-
161
function getFormat(bundleType) {
162
switch (bundleType) {
163
case UMD_DEV:
@@ -323,86 +194,21 @@ function getFilename(name, globalName, bundleType) {
194
}
195
}
196
326
-function getUglifyConfig(configs) {
327
- var mangle = configs.mangle;
328
- var preserveVersionHeader = configs.preserveVersionHeader;
329
- var removeComments = configs.removeComments;
330
- var headerSanityCheck = configs.headerSanityCheck;
331
- return {
332
- warnings: false,
333
- compress: {
334
- screw_ie8: true,
335
- dead_code: true,
336
- unused: true,
337
- drop_debugger: true,
338
- // we have a string literal <script> that we don't want to evaluate
339
- // for FB prod bundles (where we disable mangling)
340
- evaluate: mangle,
341
- booleans: true,
342
- // Our www inline transform combined with Jest resetModules is confused
343
- // in some rare cases unless we keep all requires at the top:
344
- hoist_funs: mangle,
345
- },
346
- output: {
347
- beautify: !mangle,
348
- comments(node, comment) {
349
- if (preserveVersionHeader && comment.pos === 0 && comment.col === 0) {
350
- // Keep the very first comment (the bundle header) in prod bundles.
351
- if (
352
- headerSanityCheck &&
353
- comment.value.indexOf(headerSanityCheck) === -1
354
- ) {
355
- // Sanity check: this doesn't look like the bundle header!
356
- throw new Error(
357
- 'Expected the first comment to be the file header but got: ' +
358
- comment.value
359
- );
360
- }
361
- return true;
362
- }
363
- return !removeComments;
364
- },
365
- },
366
- mangle: mangle
367
- ? {
368
- toplevel: true,
369
- screw_ie8: true,
370
- }
371
- : false,
372
- };
373
-}
374
-
375
-// FB uses require('React') instead of require('react').
376
-// We can't set up a forwarding module due to case sensitivity issues.
377
-function rewriteFBReactImport() {
378
- return {
379
- transformBundle(source) {
380
- return source.replace(/require\(['"]react['"]\)/g, "require('React')");
381
- },
382
- };
383
-}
384
-
385
-// Strip 'use strict' directives in individual modules
386
-// because we always emit them in the file headers.
387
-// The whole bundle is strict.
388
-function stripUseStrict() {
389
- return {
390
- transform(source) {
391
- return source.replace(/['"]use strict['"']/g, '');
392
- },
393
- };
394
-}
395
-
396
-// Plugin that writes to the error code file so that by the time it is picked
397
-// up by Babel, the errors are already extracted.
398
-function writeErrorCodes() {
399
- const flush = extractErrorCodes(errorCodeOpts);
400
- return {
401
- transform(source) {
402
- flush(source);
403
- return source;
404
- },
405
- };
197
+function isProductionBundleType(bundleType) {
198
+ switch (bundleType) {
199
+ case UMD_DEV:
200
+ case NODE_DEV:
201
+ case FB_DEV:
202
+ case RN_DEV:
203
+ return false;
204
+ case UMD_PROD:
205
+ case NODE_PROD:
206
+ case FB_PROD:
207
+ case RN_PROD:
208
+ return true;
209
+ default:
210
+ throw new Error(`Unknown type: ${bundleType}`);
211
+ }
212
}
213
214
function getPlugins(
@@ -416,88 +222,81 @@ function getPlugins(
222
modulesToStub,
223
featureFlags
224
) {
225
+ const findAndRecordErrorCodes = extractErrorCodes(errorCodeOpts);
226
const shims = Modules.getShims(bundleType, entry, featureFlags);
420
- const plugins = [
227
+ const isProduction = isProductionBundleType(bundleType);
228
+ const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD;
229
+ const isFBBundle = bundleType === FB_DEV || bundleType === FB_PROD;
230
+ const isRNBundle = bundleType === RN_DEV || bundleType === RN_PROD;
231
+ const shouldStayReadable = isFBBundle || isRNBundle;
232
+ return [
233
// Extract error codes from invariant() messages into a file.
422
- shouldExtractErrors && writeErrorCodes(),
234
+ shouldExtractErrors && {
235
+ transform(source) {
236
+ findAndRecordErrorCodes(source);
237
+ return source;
238
+ },
239
+ },
240
// Shim some modules for www custom behavior and optimizations.
241
alias(shims),
242
// Use Node resolution mechanism.
243
resolvePlugin({
244
skip: externals,
245
}),
246
+ // Remove license headers from individual modules
247
+ stripBanner({
248
+ exclude: 'node_modules/**/*',
249
+ }),
250
// Compile to ES5.
251
babel(getBabelConfig(updateBabelOptions, bundleType)),
431
- stripUseStrict(),
432
- ].filter(Boolean);
433
-
434
- const headerSanityCheck = getHeaderSanityCheck(bundleType, globalName);
435
- switch (bundleType) {
436
- case UMD_DEV:
437
- case NODE_DEV:
438
- plugins.push(replace(stripEnvVariables(false)), commonjs());
439
- break;
440
- case UMD_PROD:
441
- case NODE_PROD:
442
- plugins.push(
443
- replace(stripEnvVariables(true)),
444
- commonjs(),
445
- closure({
446
- compilationLevel: 'SIMPLE',
447
- languageIn: 'ECMASCRIPT5_STRICT',
448
- languageOut: 'ECMASCRIPT5_STRICT',
449
- env: 'CUSTOM',
450
- warningLevel: 'QUIET',
252
+ // Remove 'use strict' from individual source files.
253
+ {
254
+ transform(source) {
255
+ return source.replace(/['"]use strict['"']/g, '');
256
+ },
257
+ },
258
+ // Turn __DEV__ and process.env checks into constants.
259
+ replace({
260
+ __DEV__: isProduction ? 'false' : 'true',
261
+ 'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
262
+ }),
263
+ // We still need CommonJS for external deps like object-assign.
264
+ commonjs(),
265
+ // www still needs require('React') rather than require('react')
266
+ isFBBundle && {
267
+ transformBundle(source) {
268
+ return source.replace(/require\(['"]react['"]\)/g, "require('React')");
269
+ },
270
+ },
271
+ // Apply dead code elimination and/or minification.
272
+ isProduction &&
273
+ closure(
274
+ Object.assign({}, closureOptions, {
275
// Don't let it create global variables in the browser.
276
// https://github.com/facebook/react/issues/10909
453
- assumeFunctionWrapper: bundleType !== UMD_PROD,
454
- applyInputSourceMaps: false,
455
- useTypesForOptimization: false,
456
- processCommonJsModules: false,
277
+ assumeFunctionWrapper: !isInGlobalScope,
278
+ // Works because `google-closure-compiler-js` is forked in Yarn lockfile.
279
+ // We can remove this if GCC merges my PR:
280
+ // https://github.com/google/closure-compiler/pull/2707
281
+ // and then the compiled version is released via `google-closure-compiler-js`.
282
+ renaming: !shouldStayReadable,
283
})
458
- );
459
- break;
460
- case FB_DEV:
461
- plugins.push(
462
- replace(stripEnvVariables(false)),
463
- commonjs(),
464
- rewriteFBReactImport()
465
- );
466
- break;
467
- case FB_PROD:
468
- plugins.push(
469
- replace(stripEnvVariables(true)),
470
- commonjs(),
471
- uglify(
472
- getUglifyConfig({
473
- mangle: bundleType !== FB_PROD,
474
- preserveVersionHeader: bundleType === UMD_PROD,
475
- // leave comments in for source map debugging purposes
476
- // they will be stripped as part of FB's build process
477
- removeComments: bundleType !== FB_PROD,
478
- headerSanityCheck,
479
- })
480
- ),
481
- rewriteFBReactImport()
482
- );
483
- break;
484
- case RN_DEV:
485
- case RN_PROD:
486
- plugins.push(
487
- replace(stripEnvVariables(bundleType === RN_PROD)),
488
- commonjs(),
489
- uglify(
490
- getUglifyConfig({
491
- mangle: false,
492
- preserveVersionHeader: true,
493
- removeComments: true,
494
- headerSanityCheck,
495
- })
496
- )
497
- );
498
- break;
499
- }
500
- plugins.push(
284
+ ),
285
+ // Add the whitespace back if necessary.
286
+ shouldStayReadable && prettier(),
287
+ // License and haste headers, top-level `if` blocks.
288
+ {
289
+ transformBundle(source) {
290
+ return Wrappers.wrapBundle(
291
+ source,
292
+ bundleType,
293
+ globalName,
294
+ filename,
295
+ moduleType
296
+ );
297
+ },
298
+ },
299
+ // Record bundle size.
300
sizes({
301
getSize: (size, gzip) => {
302
const key = `${filename} (${bundleType})`;
@@ -506,9 +305,8 @@ function getPlugins(
305
gzip,
306
};
307
},
509
- })
510
- );
511
- return plugins;
308
+ }),
309
+ ].filter(Boolean);
310
}
311
312
function createBundle(bundle, bundleType) {
scripts/rollup/header.js
deleted
-32
@@ -1,32 +0,0 @@
1
-'use strict';
2
-
3
-function getProvidesHeader(hasteFinalName) {
4
- return `/**
5
- * Copyright (c) 2013-present, Facebook, Inc.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- *
10
- * @noflow
11
- * @providesModule ${hasteFinalName}
12
- * @preventMunge
13
- */
14
-`;
15
-}
16
-
17
-function getHeader(filename, reactVersion) {
18
- return `/** @license React v${reactVersion}
19
- * ${filename}
20
- *
21
- * Copyright (c) 2013-present, Facebook, Inc.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */
26
-`;
27
-}
28
-
29
-module.exports = {
30
- getProvidesHeader,
31
- getHeader,
32
-};
scripts/rollup/results.json
+104
-104
@@ -1,212 +1,212 @@
1
{
2
"bundleSizes": {
3
"react.development.js (UMD_DEV)": {
4
- "size": 57647,
5
- "gzip": 14957
4
+ "size": 54812,
5
+ "gzip": 14834
6
},
7
"react.production.min.js (UMD_PROD)": {
8
- "size": 6676,
9
- "gzip": 2774
8
+ "size": 6577,
9
+ "gzip": 2731
10
},
11
"react.development.js (NODE_DEV)": {
12
- "size": 48028,
13
- "gzip": 12662
12
+ "size": 45180,
13
+ "gzip": 12540
14
},
15
"react.production.min.js (NODE_PROD)": {
16
- "size": 5475,
17
- "gzip": 2351
16
+ "size": 5377,
17
+ "gzip": 2310
18
},
19
"React-dev.js (FB_DEV)": {
20
- "size": 46073,
21
- "gzip": 12047
20
+ "size": 45067,
21
+ "gzip": 12284
22
},
23
"React-prod.js (FB_PROD)": {
24
- "size": 25976,
25
- "gzip": 6831
24
+ "size": 12469,
25
+ "gzip": 3322
26
},
27
"react-dom.development.js (UMD_DEV)": {
28
- "size": 587808,
29
- "gzip": 133625
28
+ "size": 566445,
29
+ "gzip": 132067
30
},
31
"react-dom.production.min.js (UMD_PROD)": {
32
- "size": 94541,
33
- "gzip": 30614
32
+ "size": 94571,
33
+ "gzip": 30628
34
},
35
"react-dom.development.js (NODE_DEV)": {
36
- "size": 568590,
37
- "gzip": 128929
36
+ "size": 547414,
37
+ "gzip": 127145
38
},
39
"react-dom.production.min.js (NODE_PROD)": {
40
- "size": 92717,
41
- "gzip": 29846
40
+ "size": 92747,
41
+ "gzip": 29857
42
},
43
"ReactDOM-dev.js (FB_DEV)": {
44
- "size": 572114,
45
- "gzip": 130091
44
+ "size": 572910,
45
+ "gzip": 131679
46
},
47
"ReactDOM-prod.js (FB_PROD)": {
48
- "size": 418963,
49
- "gzip": 92847
48
+ "size": 270891,
49
+ "gzip": 51323
50
},
51
"react-dom-test-utils.development.js (NODE_DEV)": {
52
- "size": 37878,
53
- "gzip": 10319
52
+ "size": 35991,
53
+ "gzip": 10251
54
},
55
"react-dom-test-utils.production.min.js (NODE_PROD)": {
56
- "size": 10173,
57
- "gzip": 3834
56
+ "size": 10195,
57
+ "gzip": 3840
58
},
59
"ReactTestUtils-dev.js (FB_DEV)": {
60
- "size": 37278,
61
- "gzip": 10187
60
+ "size": 36706,
61
+ "gzip": 10335
62
},
63
"react-dom-unstable-native-dependencies.development.js (UMD_DEV)": {
64
- "size": 66834,
65
- "gzip": 16686
64
+ "size": 63456,
65
+ "gzip": 16551
66
},
67
"react-dom-unstable-native-dependencies.production.min.js (UMD_PROD)": {
68
- "size": 11351,
69
- "gzip": 3902
68
+ "size": 11373,
69
+ "gzip": 3908
70
},
71
"react-dom-unstable-native-dependencies.development.js (NODE_DEV)": {
72
- "size": 62186,
73
- "gzip": 15358
72
+ "size": 58986,
73
+ "gzip": 15262
74
},
75
"react-dom-unstable-native-dependencies.production.min.js (NODE_PROD)": {
76
- "size": 10894,
77
- "gzip": 3773
76
+ "size": 10916,
77
+ "gzip": 3778
78
},
79
"ReactDOMUnstableNativeDependencies-dev.js (FB_DEV)": {
80
- "size": 61619,
81
- "gzip": 15202
80
+ "size": 60056,
81
+ "gzip": 15406
82
},
83
"ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": {
84
- "size": 52151,
85
- "gzip": 12591
84
+ "size": 26610,
85
+ "gzip": 5327
86
},
87
"react-dom-server.browser.development.js (UMD_DEV)": {
88
- "size": 101089,
89
- "gzip": 26192
88
+ "size": 94251,
89
+ "gzip": 25351
90
},
91
"react-dom-server.browser.production.min.js (UMD_PROD)": {
92
- "size": 14718,
93
- "gzip": 5827
92
+ "size": 14740,
93
+ "gzip": 5834
94
},
95
"react-dom-server.browser.development.js (NODE_DEV)": {
96
- "size": 89855,
97
- "gzip": 23451
96
+ "size": 83195,
97
+ "gzip": 22545
98
},
99
"react-dom-server.browser.production.min.js (NODE_PROD)": {
100
- "size": 14193,
101
- "gzip": 5709
100
+ "size": 14215,
101
+ "gzip": 5714
102
},
103
"ReactDOMServer-dev.js (FB_DEV)": {
104
- "size": 89282,
105
- "gzip": 23287
104
+ "size": 86914,
105
+ "gzip": 22797
106
},
107
"ReactDOMServer-prod.js (FB_PROD)": {
108
- "size": 45189,
109
- "gzip": 11995
108
+ "size": 31382,
109
+ "gzip": 8114
110
},
111
"react-dom-server.node.development.js (NODE_DEV)": {
112
- "size": 92021,
113
- "gzip": 23959
112
+ "size": 85177,
113
+ "gzip": 23046
114
},
115
"react-dom-server.node.production.min.js (NODE_PROD)": {
116
- "size": 15018,
117
- "gzip": 6017
116
+ "size": 15040,
117
+ "gzip": 6022
118
},
119
"react-art.development.js (UMD_DEV)": {
120
- "size": 361649,
121
- "gzip": 79069
120
+ "size": 356132,
121
+ "gzip": 78808
122
},
123
"react-art.production.min.js (UMD_PROD)": {
124
- "size": 83540,
125
- "gzip": 25716
124
+ "size": 83550,
125
+ "gzip": 25720
126
},
127
"react-art.development.js (NODE_DEV)": {
128
- "size": 285841,
129
- "gzip": 60122
128
+ "size": 280511,
129
+ "gzip": 59802
130
},
131
"react-art.production.min.js (NODE_PROD)": {
132
- "size": 47425,
133
- "gzip": 14826
132
+ "size": 47447,
133
+ "gzip": 14833
134
},
135
"ReactART-dev.js (FB_DEV)": {
136
- "size": 285290,
137
- "gzip": 60273
136
+ "size": 291930,
137
+ "gzip": 61727
138
},
139
"ReactART-prod.js (FB_PROD)": {
140
- "size": 223089,
141
- "gzip": 45921
140
+ "size": 146916,
141
+ "gzip": 25076
142
},
143
"ReactNativeRenderer-dev.js (RN_DEV)": {
144
- "size": 264179,
145
- "gzip": 45201
144
+ "size": 410167,
145
+ "gzip": 89963
146
},
147
"ReactNativeRenderer-prod.js (RN_PROD)": {
148
- "size": 212604,
149
- "gzip": 36247
148
+ "size": 200640,
149
+ "gzip": 34582
150
},
151
"ReactRTRenderer-dev.js (RN_DEV)": {
152
- "size": 195908,
153
- "gzip": 32822
152
+ "size": 286373,
153
+ "gzip": 60712
154
},
155
"ReactRTRenderer-prod.js (RN_PROD)": {
156
- "size": 153400,
157
- "gzip": 25311
156
+ "size": 137994,
157
+ "gzip": 23151
158
},
159
"ReactCSRenderer-dev.js (RN_DEV)": {
160
- "size": 189445,
161
- "gzip": 31430
160
+ "size": 277226,
161
+ "gzip": 57864
162
},
163
"ReactCSRenderer-prod.js (RN_PROD)": {
164
- "size": 149120,
165
- "gzip": 24267
164
+ "size": 130881,
165
+ "gzip": 21853
166
},
167
"react-test-renderer.development.js (NODE_DEV)": {
168
- "size": 284278,
169
- "gzip": 59193
168
+ "size": 278468,
169
+ "gzip": 58909
170
},
171
"react-test-renderer.production.min.js (NODE_PROD)": {
172
- "size": 46027,
173
- "gzip": 14218
172
+ "size": 46049,
173
+ "gzip": 14225
174
},
175
"ReactTestRenderer-dev.js (FB_DEV)": {
176
- "size": 283739,
177
- "gzip": 59348
176
+ "size": 289988,
177
+ "gzip": 60842
178
},
179
"react-test-renderer-shallow.development.js (NODE_DEV)": {
180
- "size": 10659,
181
- "gzip": 2682
180
+ "size": 9693,
181
+ "gzip": 2634
182
},
183
"react-test-renderer-shallow.production.min.js (NODE_PROD)": {
184
- "size": 4850,
185
- "gzip": 1791
184
+ "size": 4872,
185
+ "gzip": 1800
186
},
187
"ReactShallowRenderer-dev.js (FB_DEV)": {
188
- "size": 10154,
189
- "gzip": 2521
188
+ "size": 9917,
189
+ "gzip": 2596
190
},
191
"react-noop-renderer.development.js (NODE_DEV)": {
192
- "size": 280242,
193
- "gzip": 58186
192
+ "size": 274984,
193
+ "gzip": 57892
194
},
195
"react-reconciler.development.js (NODE_DEV)": {
196
- "size": 265017,
197
- "gzip": 54727
196
+ "size": 260419,
197
+ "gzip": 54546
198
},
199
"react-reconciler.production.min.js (NODE_PROD)": {
200
- "size": 39270,
201
- "gzip": 12270
200
+ "size": 39408,
201
+ "gzip": 12244
202
},
203
"react-call-return.development.js (NODE_DEV)": {
204
- "size": 3050,
205
- "gzip": 980
204
+ "size": 2521,
205
+ "gzip": 929
206
},
207
"react-call-return.production.min.js (NODE_PROD)": {
208
- "size": 875,
209
- "gzip": 505
208
+ "size": 897,
209
+ "gzip": 512
210
}
211
}
212
}
\ No newline at end of file
scripts/rollup/wrappers.js
new
+199
@@ -0,0 +1,199 @@
1
+'use strict';
2
+
3
+const Bundles = require('./bundles');
4
+const reactVersion = require('../../package.json').version;
5
+
6
+const UMD_DEV = Bundles.bundleTypes.UMD_DEV;
7
+const UMD_PROD = Bundles.bundleTypes.UMD_PROD;
8
+const NODE_DEV = Bundles.bundleTypes.NODE_DEV;
9
+const NODE_PROD = Bundles.bundleTypes.NODE_PROD;
10
+const FB_DEV = Bundles.bundleTypes.FB_DEV;
11
+const FB_PROD = Bundles.bundleTypes.FB_PROD;
12
+const RN_DEV = Bundles.bundleTypes.RN_DEV;
13
+const RN_PROD = Bundles.bundleTypes.RN_PROD;
14
+
15
+const RECONCILER = Bundles.moduleTypes.RECONCILER;
16
+
17
+const license = ` * Copyright (c) 2013-present, Facebook, Inc.
18
+ *
19
+ * This source code is licensed under the MIT license found in the
20
+ * LICENSE file in the root directory of this source tree.`;
21
+
22
+const wrappers = {
23
+ /***************** UMD_DEV *****************/
24
+ [UMD_DEV](source, globalName, filename, moduleType) {
25
+ return `/** @license React v${reactVersion}
26
+ * ${filename}
27
+ *
28
+${license}
29
+ */
30
+
31
+'use strict';
32
+
33
+${source}`;
34
+ },
35
+
36
+ /***************** UMD_PROD *****************/
37
+ [UMD_PROD](source, globalName, filename, moduleType) {
38
+ return `/** @license React v${reactVersion}
39
+ * ${filename}
40
+ *
41
+${license}
42
+ */
43
+${source}`;
44
+ },
45
+
46
+ /***************** NODE_DEV *****************/
47
+ [NODE_DEV](source, globalName, filename, moduleType) {
48
+ return `/** @license React v${reactVersion}
49
+ * ${filename}
50
+ *
51
+${license}
52
+ */
53
+
54
+'use strict';
55
+
56
+if (process.env.NODE_ENV !== "production") {
57
+ (function() {
58
+${source}
59
+ })();
60
+}`;
61
+ },
62
+
63
+ /***************** NODE_PROD *****************/
64
+ [NODE_PROD](source, globalName, filename, moduleType) {
65
+ return `/** @license React v${reactVersion}
66
+ * ${filename}
67
+ *
68
+${license}
69
+ */
70
+${source}`;
71
+ },
72
+
73
+ /****************** FB_DEV ******************/
74
+ [FB_DEV](source, globalName, filename, moduleType) {
75
+ return `/**
76
+${license}
77
+ *
78
+ * @noflow
79
+ * @providesModule ${globalName}-dev
80
+ * @preventMunge
81
+ */
82
+
83
+'use strict';
84
+
85
+if (__DEV__) {
86
+ (function() {
87
+${source}
88
+ })();
89
+}`;
90
+ },
91
+
92
+ /****************** FB_PROD ******************/
93
+ [FB_PROD](source, globalName, filename, moduleType) {
94
+ return `/**
95
+${license}
96
+ *
97
+ * @noflow
98
+ * @providesModule ${globalName}-prod
99
+ * @preventMunge
100
+ */
101
+
102
+${source}`;
103
+ },
104
+
105
+ /****************** RN_DEV ******************/
106
+ [RN_DEV](source, globalName, filename, moduleType) {
107
+ return `/**
108
+${license}
109
+ *
110
+ * @noflow
111
+ * @providesModule ${globalName}-dev
112
+ * @preventMunge
113
+ */
114
+
115
+'use strict';
116
+
117
+if (__DEV__) {
118
+ (function() {
119
+${source}
120
+ })();
121
+}`;
122
+ },
123
+
124
+ /****************** RN_DEV ******************/
125
+ [RN_PROD](source, globalName, filename, moduleType) {
126
+ return `/**
127
+${license}
128
+ *
129
+ * @noflow
130
+ * @providesModule ${globalName}-prod
131
+ * @preventMunge
132
+ */
133
+
134
+${source}`;
135
+ },
136
+};
137
+
138
+const reconcilerWrappers = {
139
+ /***************** NODE_DEV (reconciler only) *****************/
140
+ [NODE_DEV](source, globalName, filename, moduleType) {
141
+ return `/** @license React v${reactVersion}
142
+ * ${filename}
143
+ *
144
+${license}
145
+ */
146
+
147
+'use strict';
148
+
149
+if (process.env.NODE_ENV !== "production") {
150
+ // This is a hacky way to ensure third party renderers don't share
151
+ // top-level module state inside the reconciler. Ideally we should
152
+ // remove this hack by putting all top-level state into the closures
153
+ // and then forbidding adding more of it in the reconciler.
154
+ var $$$reconciler;
155
+ module.exports = function(config) {
156
+${source}
157
+ return ($$$reconciler || ($$$reconciler = module.exports))(config);
158
+ };
159
+}`;
160
+ },
161
+
162
+ /***************** NODE_PROD (reconciler only) *****************/
163
+ [NODE_PROD](source, globalName, filename, moduleType) {
164
+ return `/** @license React v${reactVersion}
165
+ * ${filename}
166
+ *
167
+${license}
168
+ */
169
+var $$$reconciler;
170
+module.exports = function(config) {
171
+${source}
172
+ return ($$$reconciler || ($$$reconciler = module.exports))(config);
173
+};`;
174
+ },
175
+};
176
+
177
+function wrapBundle(source, bundleType, globalName, filename, moduleType) {
178
+ if (moduleType === RECONCILER) {
179
+ // Standalone reconciler is only used by third-party renderers.
180
+ // It is handled separately.
181
+ const wrapper = reconcilerWrappers[bundleType];
182
+ if (typeof wrapper !== 'function') {
183
+ throw new Error(
184
+ `Unsupported build type for the reconciler package: ${bundleType}.`
185
+ );
186
+ }
187
+ return wrapper(source, globalName, filename, moduleType);
188
+ }
189
+ // All the other packages.
190
+ const wrapper = wrappers[bundleType];
191
+ if (typeof wrapper !== 'function') {
192
+ throw new Error(`Unsupported build type: ${bundleType}.`);
193
+ }
194
+ return wrapper(source, globalName, filename, moduleType);
195
+}
196
+
197
+module.exports = {
198
+ wrapBundle,
199
+};
yarn.lock
+53
-22
@@ -1437,7 +1437,7 @@ detective@^4.3.1:
1437
acorn "^4.0.3"
1438
defined "^1.0.0"
1439
1440
-diff@^3.2.0:
1440
+diff@3.3.0, diff@^3.2.0:
1441
version "3.3.0"
1442
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"
1443
@@ -1798,6 +1798,13 @@ extglob@^0.3.1:
1798
dependencies:
1799
is-extglob "^1.0.0"
1800
1801
+extract-banner@0.1.2:
1802
+ version "0.1.2"
1803
+ resolved "https://registry.yarnpkg.com/extract-banner/-/extract-banner-0.1.2.tgz#61d1ed5cce3acdadb35f4323910b420364241a7f"
1804
+ dependencies:
1805
+ strip-bom-string "^0.1.2"
1806
+ strip-use-strict "^0.1.0"
1807
+
1808
extsprintf@1.0.2:
1809
version "1.0.2"
1810
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
@@ -2150,8 +2157,8 @@ glogg@^1.0.0:
2157
sparkles "^1.0.0"
2158
2159
google-closure-compiler-js@>20170000:
2153
- version "20170626.0.0"
2154
- resolved "https://registry.yarnpkg.com/google-closure-compiler-js/-/google-closure-compiler-js-20170626.0.0.tgz#5df265b277d1ec6fdea12eed131d1491cd8a8d71"
2160
+ version "20170910.0.1"
2161
+ resolved "https://registry.yarnpkg.com/@gaearon/google-closure-compiler-js/-/google-closure-compiler-js-20170910.0.1.tgz#b0cf7ef408219a19c390375a76bf0a82ccf65eea"
2162
dependencies:
2163
minimist "^1.2.0"
2164
vinyl "^2.0.1"
@@ -3208,6 +3215,18 @@ lru-cache@^4.0.1:
3215
pseudomap "^1.0.2"
3216
yallist "^2.1.2"
3217
3218
+magic-string@0.19.1:
3219
+ version "0.19.1"
3220
+ resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.19.1.tgz#14d768013caf2ec8fdea16a49af82fc377e75201"
3221
+ dependencies:
3222
+ vlq "^0.2.1"
3223
+
3224
+magic-string@0.22.4, magic-string@^0.22.4:
3225
+ version "0.22.4"
3226
+ resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.4.tgz#31039b4e40366395618c1d6cf8193c53917475ff"
3227
+ dependencies:
3228
+ vlq "^0.2.1"
3229
+
3230
magic-string@^0.15.2:
3231
version "0.15.2"
3232
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.15.2.tgz#0681d7388741bbc3addaa65060992624c6c09e9c"
@@ -3220,12 +3239,6 @@ magic-string@^0.16.0:
3239
dependencies:
3240
vlq "^0.2.1"
3241
3223
-magic-string@^0.22.4:
3224
- version "0.22.4"
3225
- resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.4.tgz#31039b4e40366395618c1d6cf8193c53917475ff"
3226
- dependencies:
3227
- vlq "^0.2.1"
3228
-
3242
makeerror@1.0.x:
3243
version "1.0.11"
3244
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
@@ -3671,7 +3684,7 @@ preserve@^0.2.0:
3684
version "0.2.0"
3685
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
3686
3674
-prettier@1.8.1:
3687
+prettier@1.8.1, prettier@^1.0.0:
3688
version "1.8.1"
3689
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.1.tgz#91064d778c08c85ac1cbe6b23195c34310d039f9"
3690
@@ -4104,6 +4117,14 @@ rollup-plugin-node-resolve@^2.0.0:
4117
builtin-modules "^1.1.0"
4118
resolve "^1.1.6"
4119
4120
+rollup-plugin-prettier@^0.3.0:
4121
+ version "0.3.0"
4122
+ resolved "https://registry.yarnpkg.com/rollup-plugin-prettier/-/rollup-plugin-prettier-0.3.0.tgz#1000df8a2914d367b79507c1caa582fdbed8b0f3"
4123
+ dependencies:
4124
+ diff "3.3.0"
4125
+ magic-string "0.22.4"
4126
+ prettier "^1.0.0"
4127
+
4128
rollup-plugin-replace@^1.1.1:
4129
version "1.1.1"
4130
resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-1.1.1.tgz#396315ded050a6ce43b9518a886a3f60efb1ea33"
@@ -4112,11 +4133,20 @@ rollup-plugin-replace@^1.1.1:
4133
minimatch "^3.0.2"
4134
rollup-pluginutils "^1.5.0"
4135
4115
-rollup-plugin-uglify@^1.0.1:
4116
- version "1.0.2"
4117
- resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-1.0.2.tgz#d4aa6f5df13522eae1ba17780c7c4c7096038359"
4136
+rollup-plugin-strip-banner@^0.2.0:
4137
+ version "0.2.0"
4138
+ resolved "https://registry.yarnpkg.com/rollup-plugin-strip-banner/-/rollup-plugin-strip-banner-0.2.0.tgz#d5c86979c7871427f9d7f797e09a493750769fd4"
4139
dependencies:
4119
- uglify-js "^2.6.1"
4140
+ extract-banner "0.1.2"
4141
+ magic-string "0.19.1"
4142
+ rollup-pluginutils "2.0.1"
4143
+
4144
+rollup-pluginutils@2.0.1, rollup-pluginutils@^2.0.1:
4145
+ version "2.0.1"
4146
+ resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz#7ec95b3573f6543a46a6461bd9a7c544525d0fc0"
4147
+ dependencies:
4148
+ estree-walker "^0.3.0"
4149
+ micromatch "^2.3.11"
4150
4151
rollup-pluginutils@^1.2.0, rollup-pluginutils@^1.5.0:
4152
version "1.5.2"
@@ -4125,13 +4155,6 @@ rollup-pluginutils@^1.2.0, rollup-pluginutils@^1.5.0:
4155
estree-walker "^0.2.1"
4156
minimatch "^3.0.2"
4157
4128
-rollup-pluginutils@^2.0.1:
4129
- version "2.0.1"
4130
- resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz#7ec95b3573f6543a46a6461bd9a7c544525d0fc0"
4131
- dependencies:
4132
- estree-walker "^0.3.0"
4133
- micromatch "^2.3.11"
4134
-
4158
rollup@^0.49.3:
4159
version "0.49.3"
4160
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.49.3.tgz#4cce32643dd8cf2154c69ff0e43470067db0adbf"
@@ -4399,6 +4422,10 @@ strip-ansi@^4.0.0:
4422
dependencies:
4423
ansi-regex "^3.0.0"
4424
4425
+strip-bom-string@^0.1.2:
4426
+ version "0.1.2"
4427
+ resolved "https://registry.yarnpkg.com/strip-bom-string/-/strip-bom-string-0.1.2.tgz#9c6e720a313ba9836589518405ccfb88a5f41b9c"
4428
+
4429
strip-bom@3.0.0, strip-bom@^3.0.0:
4430
version "3.0.0"
4431
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
@@ -4417,6 +4444,10 @@ strip-json-comments@~2.0.1:
4444
version "2.0.1"
4445
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
4446
4447
+strip-use-strict@^0.1.0:
4448
+ version "0.1.0"
4449
+ resolved "https://registry.yarnpkg.com/strip-use-strict/-/strip-use-strict-0.1.0.tgz#e30e8fd2206834e41e5eb3f3dc1ea7a4e4258f5f"
4450
+
4451
supports-color@^2.0.0:
4452
version "2.0.0"
4453
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
@@ -4600,7 +4631,7 @@ ua-parser-js@^0.7.9:
4631
version "0.7.17"
4632
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
4633
4603
-uglify-js@^2.5.0, uglify-js@^2.6, uglify-js@^2.6.1:
4634
+uglify-js@^2.6:
4635
version "2.8.22"
4636
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.22.tgz#d54934778a8da14903fa29a326fb24c0ab51a1a0"
4637
dependencies: