Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ea0bdcc
Upgrade jest and related packages from 26.6.0 to 27.1.0
Aug 28, 2021
b813df2
adds the latest yarn.lock.cached file
Aug 28, 2021
85d2f33
runs yarn compile:lockfile
Aug 28, 2021
1e20c1c
resolve conflicts with the main branch
Sep 1, 2021
64ca78f
resolve conflicts with the main branch
Sep 1, 2021
9fb0a07
adds the package-lock : npm ci with npm7
Sep 1, 2021
e8f5111
adds the package-lock : npm ci with npm7
Sep 1, 2021
bcb54da
Revert yarn.lock.cached
Sep 17, 2021
576ca83
update postcss-normalize to 10.0.1 to resolve smoke test failures
Sep 17, 2021
eccb0b9
Swap out babel with swc
Dec 10, 2021
8e1d6fa
Cache clean no longer needed as of Npm v5
Dec 10, 2021
44a7c21
Fix swc browserlists support
Dec 10, 2021
6f9083b
Breaking: Remove support for Flow
Dec 11, 2021
2334298
Update jest to ^27.4.4
Dec 11, 2021
867c019
Remove unmaintained tar-pack updating tar from v2 to v6
Dec 11, 2021
2af14b9
Load tsconfig or jsconfig as base for swc configuration
Dec 11, 2021
d42aed5
Fix swc browserslist
Dec 11, 2021
a8aa254
Revert "Breaking: Remove support for Flow"
Dec 13, 2021
11bf2c9
Add babel back and hide swc under flag
Dec 13, 2021
a1693f0
Fix test command
Dec 13, 2021
239e7db
Add message about experimental feature
Dec 13, 2021
0810052
Fix typo classic
Dec 15, 2021
1267810
Fix typo of runtime classic
Dec 19, 2021
6dab098
Support comments in jsconfig.json
Dec 19, 2021
96f57d9
Merge branch 'main' of https://github.com/facebook/create-react-app
May 20, 2022
15d580d
fix: npm run audit
krreet May 20, 2022
b8deb43
remove unnecessary changes from cra.js
krreet May 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docusaurus/docs/advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ You can adjust various development and production settings by setting environmen
| ESLINT_NO_DEV_ERRORS | ✅ Used | 🚫 Ignored | When set to `true`, ESLint errors are converted to warnings during development. As a result, ESLint output will no longer appear in the error overlay. |
| DISABLE_ESLINT_PLUGIN | ✅ Used | ✅ Used | When set to `true`, [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin) will be completely disabled. |
| DISABLE_NEW_JSX_TRANSFORM | ✅ Used | ✅ Used | When set to `true`, disables the [new JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) introduced in React 17 and backported to React 16.14.0, 15.7.0, and 0.14.10. New projects will use a version of React that supports this by default but you may need to disable it in existing projects if you can't upgrade React. |
| SWC_TRANSFORM | ✅ Used | ✅ Used | When set to `true`, enables [SWC](https://swc.rs/) - We are evaluating and taking feedback on this experimental feature. Note that `Flow` is currently not supported but might be later on [Strip flow types](https://github.com/swc-project/swc/issues/256) React. |
11,466 changes: 5,980 additions & 5,486 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"get-port": "^5.1.1",
"globby": "^11.0.4",
"husky": "^4.3.8",
"jest": "^27.4.3",
"jest": "^27.4.4",
"lerna": "^4.0.0",
"lerna-changelog": "^2.2.0",
"lint-staged": "^12.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-named-asset-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"babel-plugin-tester": "^10.1.0",
"jest": "^27.4.3"
"jest": "^27.4.4"
},
"scripts": {
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/confusing-browser-globals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"index.js"
],
"devDependencies": {
"jest": "^27.4.3"
"jest": "^27.4.4"
}
}
19 changes: 9 additions & 10 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const path = require('path');
const semver = require('semver');
const spawn = require('cross-spawn');
const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
const tar = require('tar');
const zlib = require('zlib');
const url = require('url');
const validateProjectName = require('validate-npm-package-name');

Expand Down Expand Up @@ -667,15 +668,13 @@ function getTemporaryDirectory() {

function extractStream(stream, dest) {
return new Promise((resolve, reject) => {
stream.pipe(
unpack(dest, err => {
if (err) {
reject(err);
} else {
resolve(dest);
}
})
);
stream
.on('error', reject)
.pipe(zlib.createGunzip())
.on('error', reject)
.pipe(tar.extract({ strip: 1, C: dest }))
.on('error', reject)
.on('finish', () => resolve(dest));
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"hyperquest": "^2.1.3",
"prompts": "^2.4.2",
"semver": "^7.3.5",
"tar-pack": "^3.4.1",
"tar": "^6.1.11",
"tmp": "^0.2.1",
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
"cross-env": "^7.0.3",
"jest": "^27.4.3"
"jest": "^27.4.4"
}
}
2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"devDependencies": {
"cross-env": "^7.0.3",
"jest": "^27.4.3"
"jest": "^27.4.4"
},
"scripts": {
"test": "cross-env FORCE_COLOR=true jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"cross-env": "^7.0.3",
"flow-bin": "^0.116.0",
"html-entities": "^2.3.2",
"jest": "^27.4.3",
"jest": "^27.4.4",
"jest-fetch-mock": "^3.0.3",
"object-assign": "^4.1.1",
"promise": "^8.1.0",
Expand Down
157 changes: 157 additions & 0 deletions packages/react-scripts/config/createSwcConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';
const fs = require('fs');
const path = require('path');
const merge = require('lodash.merge');
const JSON5 = require('json5');
const paths = require('./paths');
const hasJsxRuntime = require('./hasJsxRuntime');
const browserslist = require('browserslist');

const targets = browserslist.loadConfig({ path: paths.appPath });

module.exports = function createSwcConfig({
shouldUseSourceMap = true,
isEnvDevelopment = false,
isEnvProduction = false,
shouldUseReactRefresh = false,
} = {}) {
const projectSwcConfig = mapProjectConfigToSwcConfig(getProjectConfig());

const generalOptions = {
jsx: true,
runtime: hasJsxRuntime ? 'automatic' : 'classic',
sourceMaps: shouldUseSourceMap,
refresh: shouldUseReactRefresh,
useBrowserslist: isEnvDevelopment | isEnvProduction,
development: isEnvDevelopment,
};

return {
ecmascript: merge(
{},
projectSwcConfig,
getBaseConfiguration({
...generalOptions,
})
),
typescript: merge(
{},
projectSwcConfig,
getBaseConfiguration({
...generalOptions,
syntax: 'typescript',
})
),
};
};

function getBaseConfiguration({
runtime = 'classic',
syntax = 'ecmascript',
jsx = false,
sourceMaps = false,
refresh = false,
useBrowserslist = false,
development = false,
}) {
return {
sourceMaps,
jsc: {
parser: {
[syntax === 'typescript' ? 'tsx' : 'jsx']: jsx,
syntax,
},
transform: {
react: {
runtime,
refresh,
development,
},
},
},
env: useBrowserslist
? {
targets,
mode: 'entry',
coreJs: 3,
}
: {},
};
}

function mapProjectConfigToSwcConfig(projectConfig = {}) {
const {
compilerOptions: {
target,
importHelpers,
experimentalDecorators,
emitDecoratorMetadata,
baseUrl,
paths,
} = {},
} = projectConfig;
const result = { jsc: { externalHelpers: true, parser: {}, transform: {} } };

if (target != null) {
result.jsc.target = target;
}
if (importHelpers != null) {
result.jsc.externalHelpers = importHelpers;
}
if (experimentalDecorators != null) {
result.jsc.parser.decorators = experimentalDecorators;
}
if (emitDecoratorMetadata != null) {
result.jsc.transform.decoratorMetadata = emitDecoratorMetadata;
}

if (baseUrl != null) {
result.jsc.baseUrl = baseUrl;
if (paths != null) {
result.jsc.paths = paths;
}
}

return result;
}

function getProjectConfig(configPath, loadedPaths = []) {
const configPaths =
configPath != null ? [configPath] : [paths.appTsConfig, paths.appJsConfig];
const [projectConfigPath] = configPaths.filter(p => fs.existsSync(p));
if (projectConfigPath == null) {
return {};
}
if (loadedPaths.includes(projectConfigPath)) {
return {};
}
try {
const projectConfig = JSON5.parse(
fs.readFileSync(projectConfigPath, 'utf-8')
);
if (projectConfig.extends != null) {
const baseConfig = require.resolve(projectConfig.extends, {
paths: [path.dirname(projectConfigPath)],
});
delete projectConfig.extends;
return merge(
getProjectConfig(baseConfig, [...loadedPaths, projectConfigPath]),
projectConfig
);
}
return projectConfig;
} catch (error) {
console.error(
`Error: Failed to load "${projectConfigPath}", error: "${error.message}"`
);
process.exit(1);
}
}
21 changes: 21 additions & 0 deletions packages/react-scripts/config/hasJsxRuntime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';
module.exports = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}

try {
require.resolve('react/jsx-runtime');
return true;
} catch (e) {
return false;
}
})();
14 changes: 1 addition & 13 deletions packages/react-scripts/config/jest/babelTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@
'use strict';

const babelJest = require('babel-jest').default;

const hasJsxRuntime = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}

try {
require.resolve('react/jsx-runtime');
return true;
} catch (e) {
return false;
}
})();
const hasJsxRuntime = require('../hasJsxRuntime');

module.exports = babelJest.createTransformer({
presets: [
Expand Down
15 changes: 14 additions & 1 deletion packages/react-scripts/config/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const path = require('path');
const paths = require('./paths');
const chalk = require('react-dev-utils/chalk');
const resolve = require('resolve');
const JSON5 = require('json5');

/**
* Get additional module paths based on the baseUrl of a compilerOptions object.
Expand Down Expand Up @@ -123,7 +124,19 @@ function getModules() {
// Otherwise we'll check if there is jsconfig.json
// for non TS projects.
} else if (hasJsConfig) {
config = require(paths.appJsConfig);
// Projects using jsconfig.json do not need TypeScript installed, using JSON5
try {
config = JSON5.parse(fs.readFileSync(paths.appJsConfig, 'utf-8'));
} catch (error) {
const errorType = /^JSON5/.test(error.message) ? 'parse' : 'load';
const errorMessge = error.message.replace(/^JSON5/, 'Error');
console.error(
chalk.red(
`Failed to ${errorType} "${paths.appJsConfig}" got error: "${errorMessge}"`
)
);
process.exit(1);
}
}

config = config || {};
Expand Down
Loading