Skip to content

Commit 89aed63

Browse files
committed
chore: updates
1 parent dc22555 commit 89aed63

File tree

5 files changed

+15
-77
lines changed

5 files changed

+15
-77
lines changed

packages/babel-preset-react-app/create.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ module.exports = function(api, opts, env) {
5454
// We should be able to provide a babelconfig for every build.
5555
// Does this mean we should move this to webpack or specify some BABEL_ENV?
5656
var isModern = validateBoolOption('modern', opts.modern, false);
57+
var shouldBuildModern = validateBoolOption(
58+
'shouldBuildModernAndLegacy',
59+
opts.shouldBuildModernAndLegacy,
60+
true
61+
);
5762

5863
var absoluteRuntimePath = undefined;
5964
if (useAbsoluteRuntime) {
@@ -89,13 +94,17 @@ module.exports = function(api, opts, env) {
8994
{
9095
// We want Create React App to be IE 9 compatible until React itself
9196
// no longer works with IE 9
92-
targets: isModern ? modernTargets : legacyTargets,
97+
targets: shouldBuildModern
98+
? isModern
99+
? modernTargets
100+
: legacyTargets
101+
: undefined,
93102
// Users cannot override this behavior because this Babel
94103
// configuration is highly tuned for ES5 support
95104
ignoreBrowserslistConfig: true,
96105
// If users import all core-js they're probably not concerned with
97106
// bundle size. We shouldn't rely on magic to try and shrink it.
98-
useBuiltIns: isModern ? 'entry' : false,
107+
useBuiltIns: !isModern || !shouldBuildModern ? false : 'entry',
99108
// Do not transform modules to CJS
100109
modules: false,
101110
// Exclude transforms that make all code slower

packages/create-react-app/createReactApp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const program = new commander.Command(packageJson.name)
7777
)
7878
.option('--use-npm')
7979
.option('--use-pnp')
80+
.option('--modern')
8081
.option('--typescript')
8182
.allowUnknownOption()
8283
.on('--help', () => {

packages/react-scripts/config/webpack.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ const getClientEnvironment = require('./env');
3131
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
3232
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
3333
const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
34-
// const HtmlWebpackEsmodulesPlugin = require('react-dev-utils/html-webpack-esmodules-plugin');
34+
const HtmlWebpackEsmodulesPlugin = require('react-dev-utils/html-webpack-esmodules-plugin');
3535
// @remove-on-eject-begin
3636
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
3737
// @remove-on-eject-end
38-
const HtmlWebpackEsmodulesPlugin = require('./webpack/html-webpack-esmodules-plugin');
3938

4039
// Source maps are resource heavy and can cause out of memory issue for large source files.
4140
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
@@ -365,7 +364,7 @@ module.exports = function(
365364
presets: [
366365
[
367366
require.resolve('babel-preset-react-app'),
368-
{ modern: isModernOutput },
367+
{ modern: isModernOutput, shouldBuildModernAndLegacy },
369368
],
370369
],
371370
// Make sure we have a unique cache identifier, erring on the

packages/react-scripts/config/webpack/html-webpack-esmodules-plugin.js

Lines changed: 0 additions & 71 deletions
This file was deleted.

packages/react-scripts/scripts/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
6363
// Process CLI arguments
6464
const argv = process.argv.slice(2);
6565
const writeStatsJson = argv.indexOf('--stats') !== -1;
66-
const buildModern = argv.indexOf('--legacy') === -1;
66+
const buildModern = argv.indexOf('--modern') !== -1;
6767

6868
// Generate configuration
6969
const modernConfig = configFactory('production', {

0 commit comments

Comments
 (0)