Skip to content

[pull] master from facebook:master #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"browser": true,
"commonjs": true,
"node": true,
"es6": true
"es6": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 2018
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Integration Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
job:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['10', '12', '14']
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', './yarn.lock') }}
- name: Install packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile --prefer-offline
- name: Run integration tests
run: yarn test:integration
2 changes: 1 addition & 1 deletion docusaurus/docs/using-the-public-folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The `public` folder is useful as a workaround for a number of less common cases:

- You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest).
- You have thousands of images and need to dynamically reference their paths.
- You want to include a small script like [`pace.js`](https://github.hubspot.com/pace/docs/welcome/) outside of the bundled code.
- You want to include a small script like [`pace.js`](https://github.com/CodeByZach/pace) outside of the bundled code.
- Some libraries may be incompatible with webpack and you have no other option but to include it as a `<script>` tag.

Note that if you add a `<script>` that declares global variables, you should read the topic [Using Global Variables](using-global-variables.md) in the next section which explains how to reference them.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"screencast": "node ./tasks/screencast.js",
"screencast:error": "svg-term --cast jyu19xGl88FQ3poMY8Hbmfw8y --out screencast-error.svg --window --at 12000 --no-cursor",
"alex": "alex .",
"test:integration": "jest test/integration",
"test": "cd packages/react-scripts && node bin/react-scripts.js test",
"format": "prettier --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
"compile:lockfile": "node tasks/compile-lockfile.js"
Expand Down
30 changes: 15 additions & 15 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
"test.js"
],
"dependencies": {
"@babel/core": "7.12.3",
"@babel/plugin-proposal-class-properties": "7.12.1",
"@babel/plugin-proposal-decorators": "7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1",
"@babel/plugin-proposal-numeric-separator": "7.12.1",
"@babel/plugin-proposal-optional-chaining": "7.12.1",
"@babel/plugin-transform-flow-strip-types": "7.12.1",
"@babel/plugin-transform-react-display-name": "7.12.1",
"@babel/plugin-transform-runtime": "7.12.1",
"@babel/preset-env": "7.12.1",
"@babel/preset-react": "7.12.1",
"@babel/preset-typescript": "7.12.1",
"@babel/runtime": "7.12.1",
"babel-plugin-macros": "2.8.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24"
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
"@babel/plugin-transform-flow-strip-types": "^7.12.1",
"@babel/plugin-transform-react-display-name": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@babel/runtime": "^7.12.1",
"babel-plugin-macros": "^2.8.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24"
}
}
8 changes: 7 additions & 1 deletion packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ function init() {
}

function createApp(name, verbose, version, template, useNpm, usePnp) {
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10');
const unsupportedNodeVersion = !semver.satisfies(
// Coerce strings with metadata (i.e. `15.0.0-nightly`).
semver.coerce(process.version),
'>=10'
);

if (unsupportedNodeVersion) {
console.log(
chalk.yellow(
Expand Down Expand Up @@ -387,6 +392,7 @@ function install(root, useYarn, usePnp, dependencies, verbose, isOnline) {
command = 'npm';
args = [
'install',
'--no-audit', // https://github.com/facebook/create-react-app/issues/11174
'--save',
'--save-exact',
'--loglevel',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This config also ships with optional Jest rules for ESLint (based on [`eslint-pl
You'll first need to add the ESLint plugin for Jest (if you don't already have it installed).

```sh
npm install --save-dev eslint-plugin-jest@^24.0.0 eslint-plugin-testing-library&^3.9.0
npm install --save-dev eslint-plugin-jest@^24.0.0 eslint-plugin-testing-library@^3.9.0
```

You can then enable these rules by adding the Jest config to the `extends` array in your ESLint config.
Expand Down
14 changes: 13 additions & 1 deletion packages/react-dev-utils/formatWebpackMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ function isLikelyASyntaxError(message) {

// Cleans up webpack error messages.
function formatMessage(message) {
let lines = message.split('\n');
let lines = [];

if (typeof message === 'string') {
lines = message.split('\n');
} else if ('message' in message) {
lines = message['message'].split('\n');
} else if (Array.isArray(message)) {
message.forEach(message => {
if ('message' in message) {
lines = message['message'].split('\n');
}
});
}

// Strip webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"webpackHotDevClient.js"
],
"dependencies": {
"@babel/code-frame": "7.10.4",
"@babel/code-frame": "^7.10.4",
"address": "1.1.2",
"browserslist": "4.14.2",
"chalk": "2.4.2",
Expand All @@ -65,7 +65,7 @@
"global-modules": "2.0.0",
"globby": "11.0.1",
"gzip-size": "5.1.1",
"immer": "8.0.1",
"immer": "8.0.4",
"is-root": "2.1.0",
"loader-utils": "2.0.0",
"open": "^7.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"lib/index.js"
],
"devDependencies": {
"@babel/code-frame": "7.10.4",
"@babel/core": "7.12.3",
"@babel/code-frame": "^7.10.4",
"@babel/core": "^7.12.3",
"anser": "1.4.10",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-loader": "^8.1.0",
"babel-preset-react-app": "^10.0.0",
"chalk": "2.4.2",
"chokidar": "^3.4.3",
Expand Down
9 changes: 8 additions & 1 deletion packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ module.exports = function (webpackEnv) {
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
// Handle node_modules packages that contain sourcemaps
shouldUseSourceMap && {
enforce: 'pre',
exclude: /@babel(?:\/|\\{1,2})runtime/,
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
use: 'source-map-loader',
},
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
Expand Down Expand Up @@ -605,7 +612,7 @@ module.exports = function (webpackEnv) {
// Make sure to add the new loader(s) before the "file" loader.
],
},
],
].filter(Boolean),
},
plugins: [
// Generates an `index.html` file with the <script> injected.
Expand Down
7 changes: 4 additions & 3 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
},
"types": "./lib/react-app.d.ts",
"dependencies": {
"@babel/core": "7.12.3",
"@babel/core": "^7.12.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"@svgr/webpack": "5.5.0",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
Expand Down Expand Up @@ -65,7 +65,7 @@
"mini-css-extract-plugin": "0.11.3",
"optimize-css-assets-webpack-plugin": "5.0.4",
"pnp-webpack-plugin": "1.6.4",
"postcss": "8.2.4",
"postcss": "8.3.5",
"postcss-flexbugs-fixes": "5.0.2",
"postcss-loader": "4.2.0",
"postcss-normalize": "9.0.0",
Expand All @@ -79,6 +79,7 @@
"resolve-url-loader": "^3.1.2",
"sass-loader": "^10.0.5",
"semver": "7.3.2",
"source-map-loader": "^1.1.2",
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
Expand Down
18 changes: 11 additions & 7 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,17 @@ function build(previousFileSizes) {
process.env.CI.toLowerCase() !== 'false') &&
messages.warnings.length
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(messages.warnings.join('\n\n')));
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
const filteredWarnings = messages.warnings.filter(w => !/Failed to parse source map/.test(w));
if (filteredWarnings.length) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(new Error(filteredWarnings.join('\n\n')));
}
}

const resolveArgs = {
Expand Down
7 changes: 6 additions & 1 deletion packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ module.exports = function (
} else {
command = 'npm';
remove = 'uninstall';
args = ['install', '--save', verbose && '--verbose'].filter(e => e);
args = [
'install',
'--no-audit', // https://github.com/facebook/create-react-app/issues/11174
'--save',
verbose && '--verbose',
].filter(e => e);
}

// Install additional template dependencies, if present.
Expand Down
9 changes: 6 additions & 3 deletions packages/react-scripts/scripts/utils/verifyPackageTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const fs = require('fs');
const semver = require('semver');
const path = require('path');

const isESLintPluginEnabled = process.env.DISABLE_ESLINT_PLUGIN !== 'true';

// We assume that having wrong versions of these
// in the tree will likely break your setup.
// This is a relatively low-effort way to find common issues.
Expand All @@ -21,14 +23,15 @@ function verifyPackageTree() {
// These are packages most likely to break in practice.
// See https://github.com/facebook/create-react-app/issues/1795 for reasons why.
// I have not included Babel here because plugins typically don't import Babel (so it's not affected).
'babel-eslint',
'babel-jest',
'babel-loader',
'eslint',
'jest',
'webpack',
'webpack-dev-server',
];
isESLintPluginEnabled && 'babel-eslint',
isESLintPluginEnabled && 'eslint',
].filter(Boolean);

// Inlined from semver-regex, MIT license.
// Don't want to make this a dependency after ejecting.
const getSemverRegex = () =>
Expand Down
Loading