Skip to content

Commit 9f02628

Browse files
committed
Don't minify symbols in production builds
This disables symbol renaming in production builds. The original variable and function names are preserved. All other forms of compression applied by Closure (dead code elimination, inlining, etc) are unchanged — the final program is identical to what we were producing before, just in a more readable form. The motivation is to make it easier to debug React issues that only occur in production — the same reason we decided to start shipping sourcemaps in facebook#28827 and facebook#28827. However, because most apps run their own minification step on their npm dependencies, it's not necessary for us to minify the symbols before publishing — it'll be handled the app, if desired. This is the same strategy Meta has used to ship React for years. The React build itself has unminified symbols, but they get minified as part of Meta's regular build pipeline. Even if an app does not minify their npm dependencies, gzip covers most of the cost of symbol renaming anyway. This saves us from having to ship sourcemaps, which means even apps that don't have sourcemaps configured will be able to debug the React build as easily as they would any other npm dependency.
1 parent 0e0b693 commit 9f02628

File tree

98 files changed

+263
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+263
-292
lines changed

dangerfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const SIGNIFICANCE_THRESHOLD = 0.002;
4343
const CRITICAL_ARTIFACT_PATHS = new Set([
4444
// We always report changes to these bundles, even if the change is
4545
// insignificant or non-existent.
46-
'oss-stable/react-dom/cjs/react-dom.production.min.js',
47-
'oss-experimental/react-dom/cjs/react-dom.production.min.js',
46+
'oss-stable/react-dom/cjs/react-dom.production.js',
47+
'oss-experimental/react-dom/cjs/react-dom.production.js',
4848
'facebook-www/ReactDOM-prod.classic.js',
4949
'facebook-www/ReactDOM-prod.modern.js',
5050
]);

fixtures/legacy-jsx-runtimes/lint-runtimes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ async function lint(folder) {
3434

3535
const results = await eslint.lintFiles([
3636
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.development.js',
37-
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.production.min.js',
37+
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.production.js',
3838
__dirname + '/' + folder + '/cjs/react-jsx-runtime.development.js',
39-
__dirname + '/' + folder + '/cjs/react-jsx-runtime.production.min.js',
39+
__dirname + '/' + folder + '/cjs/react-jsx-runtime.production.js',
4040
]);
4141
if (
4242
results.some(result => result.errorCount > 0 || result.warningCount > 0)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/** @license React v0.14.10
2-
* react-jsx-dev-runtime.production.min.js
2+
* react-jsx-dev-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
9+
'use strict';
10+
require('react');
11+
exports.Fragment = 60107;
12+
if ('function' === typeof Symbol && Symbol.for) {
13+
var a = Symbol.for;
14+
exports.Fragment = a('react.fragment');
15+
}
16+
exports.jsxDEV = void 0;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
/** @license React v0.14.10
2-
* react-jsx-runtime.production.min.js
2+
* react-jsx-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=require("react/lib/ReactCurrentOwner"),n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
10-
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
9+
'use strict';
10+
var f = require('react'),
11+
g = 60103;
12+
exports.Fragment = 60107;
13+
if ('function' === typeof Symbol && Symbol.for) {
14+
var h = Symbol.for;
15+
g = h('react.element');
16+
exports.Fragment = h('react.fragment');
17+
}
18+
var m = require('react/lib/ReactCurrentOwner'),
19+
n = Object.prototype.hasOwnProperty,
20+
p = {key: !0, ref: !0, __self: !0, __source: !0};
21+
function q(c, a, k) {
22+
var b,
23+
d = {},
24+
e = null,
25+
l = null;
26+
void 0 !== k && (e = '' + k);
27+
void 0 !== a.key && (e = '' + a.key);
28+
void 0 !== a.ref && (l = a.ref);
29+
for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
30+
if (c && c.defaultProps)
31+
for (b in ((a = c.defaultProps), a)) void 0 === d[b] && (d[b] = a[b]);
32+
return {$$typeof: g, type: c, key: e, ref: l, props: d, _owner: m.current};
33+
}
34+
exports.jsx = q;
35+
exports.jsxs = q;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-dev-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/** @license React v15.7.0
2-
* react-jsx-dev-runtime.production.min.js
2+
* react-jsx-dev-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
9+
'use strict';
10+
require('react');
11+
exports.Fragment = 60107;
12+
if ('function' === typeof Symbol && Symbol.for) {
13+
var a = Symbol.for;
14+
exports.Fragment = a('react.fragment');
15+
}
16+
exports.jsxDEV = void 0;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
/** @license React v15.7.0
2-
* react-jsx-runtime.production.min.js
2+
* react-jsx-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=require("react/lib/ReactCurrentOwner"),n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
10-
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
9+
'use strict';
10+
var f = require('react'),
11+
g = 60103;
12+
exports.Fragment = 60107;
13+
if ('function' === typeof Symbol && Symbol.for) {
14+
var h = Symbol.for;
15+
g = h('react.element');
16+
exports.Fragment = h('react.fragment');
17+
}
18+
var m = require('react/lib/ReactCurrentOwner'),
19+
n = Object.prototype.hasOwnProperty,
20+
p = {key: !0, ref: !0, __self: !0, __source: !0};
21+
function q(c, a, k) {
22+
var b,
23+
d = {},
24+
e = null,
25+
l = null;
26+
void 0 !== k && (e = '' + k);
27+
void 0 !== a.key && (e = '' + a.key);
28+
void 0 !== a.ref && (l = a.ref);
29+
for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
30+
if (c && c.defaultProps)
31+
for (b in ((a = c.defaultProps), a)) void 0 === d[b] && (d[b] = a[b]);
32+
return {$$typeof: g, type: c, key: e, ref: l, props: d, _owner: m.current};
33+
}
34+
exports.jsx = q;
35+
exports.jsxs = q;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-dev-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/** @license React v16.14.0
2-
* react-jsx-dev-runtime.production.min.js
2+
* react-jsx-dev-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
9+
'use strict';
10+
require('react');
11+
exports.Fragment = 60107;
12+
if ('function' === typeof Symbol && Symbol.for) {
13+
var a = Symbol.for;
14+
exports.Fragment = a('react.fragment');
15+
}
16+
exports.jsxDEV = void 0;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
/** @license React v16.14.0
2-
* react-jsx-runtime.production.min.js
2+
* react-jsx-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
10-
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
9+
'use strict';
10+
var f = require('react'),
11+
g = 60103;
12+
exports.Fragment = 60107;
13+
if ('function' === typeof Symbol && Symbol.for) {
14+
var h = Symbol.for;
15+
g = h('react.element');
16+
exports.Fragment = h('react.fragment');
17+
}
18+
var m = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
19+
n = Object.prototype.hasOwnProperty,
20+
p = {key: !0, ref: !0, __self: !0, __source: !0};
21+
function q(c, a, k) {
22+
var b,
23+
d = {},
24+
e = null,
25+
l = null;
26+
void 0 !== k && (e = '' + k);
27+
void 0 !== a.key && (e = '' + a.key);
28+
void 0 !== a.ref && (l = a.ref);
29+
for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
30+
if (c && c.defaultProps)
31+
for (b in ((a = c.defaultProps), a)) void 0 === d[b] && (d[b] = a[b]);
32+
return {$$typeof: g, type: c, key: e, ref: l, props: d, _owner: m.current};
33+
}
34+
exports.jsx = q;
35+
exports.jsxs = q;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-dev-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
/** @license React v17.0.0-rc.3
2-
* react-jsx-dev-runtime.production.min.js
2+
* react-jsx-dev-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';require("object-assign");require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
9+
'use strict';
10+
require('object-assign');
11+
require('react');
12+
exports.Fragment = 60107;
13+
if ('function' === typeof Symbol && Symbol.for) {
14+
var a = Symbol.for;
15+
exports.Fragment = a('react.fragment');
16+
}
17+
exports.jsxDEV = void 0;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
/** @license React v17.0.0-rc.3
2-
* react-jsx-runtime.production.min.js
2+
* react-jsx-runtime.production.js
33
*
44
* Copyright (c) Meta Platforms, Inc. and affiliates.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE file in the root directory of this source tree.
88
*/
9-
'use strict';require("object-assign");var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
10-
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
9+
'use strict';
10+
require('object-assign');
11+
var f = require('react'),
12+
g = 60103;
13+
exports.Fragment = 60107;
14+
if ('function' === typeof Symbol && Symbol.for) {
15+
var h = Symbol.for;
16+
g = h('react.element');
17+
exports.Fragment = h('react.fragment');
18+
}
19+
var m = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
20+
n = Object.prototype.hasOwnProperty,
21+
p = {key: !0, ref: !0, __self: !0, __source: !0};
22+
function q(c, a, k) {
23+
var b,
24+
d = {},
25+
e = null,
26+
l = null;
27+
void 0 !== k && (e = '' + k);
28+
void 0 !== a.key && (e = '' + a.key);
29+
void 0 !== a.ref && (l = a.ref);
30+
for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
31+
if (c && c.defaultProps)
32+
for (b in ((a = c.defaultProps), a)) void 0 === d[b] && (d[b] = a[b]);
33+
return {$$typeof: g, type: c, key: e, ref: l, props: d, _owner: m.current};
34+
}
35+
exports.jsx = q;
36+
exports.jsxs = q;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-dev-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
4+
module.exports = require('./cjs/react-jsx-runtime.production.js');
55
} else {
66
module.exports = require('./cjs/react-jsx-runtime.development.js');
77
}

fixtures/packaging/systemjs-builder/prod/config.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
System.config({
22
paths: {
3-
react:
4-
'../../../../build/oss-experimental/react/umd/react.production.min.js',
3+
react: '../../../../build/oss-experimental/react/umd/react.production.js',
54
'react-dom':
6-
'../../../../build/oss-experimental/react-dom/umd/react-dom.production.min.js',
5+
'../../../../build/oss-experimental/react-dom/umd/react-dom.production.js',
76
schedule:
87
'../../../../build/oss-experimental/scheduler/umd/schedule.development',
98
},

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
"shelljs": "^0.8.5",
9595
"signedsource": "^2.0.0",
9696
"targz": "^1.0.1",
97-
"terser": "^5.30.3",
9897
"through2": "^3.0.1",
9998
"tmp": "^0.1.0",
10099
"typescript": "^3.7.5",

packages/eslint-plugin-react-hooks/npm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TODO: this doesn't make sense for an ESLint rule.
44
// We need to fix our build process to not create bundles for "raw" packages like this.
55
if (process.env.NODE_ENV === 'production') {
6-
module.exports = require('./cjs/eslint-plugin-react-hooks.production.min.js');
6+
module.exports = require('./cjs/eslint-plugin-react-hooks.production.js');
77
} else {
88
module.exports = require('./cjs/eslint-plugin-react-hooks.development.js');
99
}

packages/jest-react/npm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/jest-react.production.min.js');
4+
module.exports = require('./cjs/jest-react.production.js');
55
} else {
66
module.exports = require('./cjs/jest-react.development.js');
77
}

packages/react-art/npm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-art.production.min.js');
4+
module.exports = require('./cjs/react-art.production.js');
55
} else {
66
module.exports = require('./cjs/react-art.development.js');
77
}

packages/react-cache/npm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-cache.production.min.js');
4+
module.exports = require('./cjs/react-cache.production.js');
55
} else {
66
module.exports = require('./cjs/react-cache.development.js');
77
}

packages/react-client/npm/flight.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-client-flight.production.min.js');
4+
module.exports = require('./cjs/react-client-flight.production.js');
55
} else {
66
module.exports = require('./cjs/react-client-flight.development.js');
77
}

0 commit comments

Comments
 (0)