Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit b04b4f9

Browse files
author
William Monk
committed
Merge [email protected] upstream
1 parent 2cb3de9 commit b04b4f9

26 files changed

+1742
-1074
lines changed

Diff for: bin/react-scripts-ts.js

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
'use strict';
1010

11+
// Makes the script crash on unhandled rejections instead of silently
12+
// ignoring them. In the future, promise rejections that are not handled will
13+
// terminate the Node.js process with a non-zero exit code.
14+
process.on('unhandledRejection', err => {
15+
throw err;
16+
});
17+
1118
const spawn = require('react-dev-utils/crossSpawn');
1219
const args = process.argv.slice(2);
1320

Diff for: config/env.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ dotenvFiles.forEach(dotenvFile => {
5050

5151
// We support resolving modules according to `NODE_PATH`.
5252
// This lets you use absolute paths in imports inside large monorepos:
53-
// https://github.com/facebookincubator/create-react-app/issues/253.
53+
// https://github.com/facebook/create-react-app/issues/253.
5454
// It works similar to `NODE_PATH` in Node itself:
5555
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
5656
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
5757
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
58-
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
58+
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
5959
// We also resolve them to make sure all tools using them work consistently.
6060
const appDirectory = fs.realpathSync(process.cwd());
6161
process.env.NODE_PATH = (process.env.NODE_PATH || '')
@@ -89,13 +89,10 @@ function getClientEnvironment(publicUrl) {
8989
);
9090
// Stringify all values so we can feed into Webpack DefinePlugin
9191
const stringified = {
92-
'process.env': Object.keys(raw).reduce(
93-
(env, key) => {
94-
env[key] = JSON.stringify(raw[key]);
95-
return env;
96-
},
97-
{}
98-
),
92+
'process.env': Object.keys(raw).reduce((env, key) => {
93+
env[key] = JSON.stringify(raw[key]);
94+
return env;
95+
}, {}),
9996
};
10097

10198
return { raw, stringified };

Diff for: config/jest/babelTransform.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ const babelJest = require('babel-jest');
1212
module.exports = babelJest.createTransformer({
1313
presets: [require.resolve('babel-preset-react-app')],
1414
babelrc: false,
15+
configFile: false,
1516
});

Diff for: config/jest/fileTransform.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ const path = require('path');
1515

1616
module.exports = {
1717
process(src, filename) {
18-
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
18+
const assetFilename = JSON.stringify(path.basename(filename));
19+
20+
if (filename.match(/\.svg$/)) {
21+
return `module.exports = {
22+
__esModule: true,
23+
default: ${assetFilename},
24+
ReactComponent: () => ${assetFilename},
25+
};`;
26+
}
27+
28+
return `module.exports = ${assetFilename};`;
1929
},
2030
};

Diff for: config/paths.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ const fs = require('fs');
1313
const url = require('url');
1414

1515
// Make sure any symlinks in the project folder are resolved:
16-
// https://github.com/facebookincubator/create-react-app/issues/637
16+
// https://github.com/facebook/create-react-app/issues/637
1717
const appDirectory = fs.realpathSync(process.cwd());
1818
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
1919

2020
const envPublicUrl = process.env.PUBLIC_URL;
2121

22-
function ensureSlash(path, needsSlash) {
23-
const hasSlash = path.endsWith('/');
22+
function ensureSlash(inputPath, needsSlash) {
23+
const hasSlash = inputPath.endsWith('/');
2424
if (hasSlash && !needsSlash) {
25-
return path.substr(path, path.length - 1);
25+
return inputPath.substr(0, inputPath.length - 1);
2626
} else if (!hasSlash && needsSlash) {
27-
return `${path}/`;
27+
return `${inputPath}/`;
2828
} else {
29-
return path;
29+
return inputPath;
3030
}
3131
}
3232

@@ -41,14 +41,15 @@ const getPublicUrl = appPackageJson =>
4141
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
4242
function getServedPath(appPackageJson) {
4343
const publicUrl = getPublicUrl(appPackageJson);
44-
const servedUrl = envPublicUrl ||
45-
(publicUrl ? url.parse(publicUrl).pathname : '/');
44+
const servedUrl =
45+
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
4646
return ensureSlash(servedUrl, true);
4747
}
4848

4949
// config after eject: we're in ./config/
5050
module.exports = {
5151
dotenv: resolveApp('.env'),
52+
appPath: resolveApp('.'),
5253
appBuild: resolveApp('build'),
5354
appPublic: resolveApp('public'),
5455
appHtml: resolveApp('public/index.html'),
@@ -57,6 +58,7 @@ module.exports = {
5758
appSrc: resolveApp('src'),
5859
yarnLockFile: resolveApp('yarn.lock'),
5960
testsSetup: resolveApp('src/setupTests.ts'),
61+
proxySetup: resolveApp('src/setupProxy.js'),
6062
appNodeModules: resolveApp('node_modules'),
6163
appTsConfig: resolveApp('tsconfig.json'),
6264
appTsProdConfig: resolveApp('tsconfig.prod.json'),
@@ -80,6 +82,7 @@ module.exports = {
8082
appSrc: resolveApp('src'),
8183
yarnLockFile: resolveApp('yarn.lock'),
8284
testsSetup: resolveApp('src/setupTests.ts'),
85+
proxySetup: resolveApp('src/setupProxy.js'),
8386
appNodeModules: resolveApp('node_modules'),
8487
appTsConfig: resolveApp('tsconfig.json'),
8588
appTsProdConfig: resolveApp('tsconfig.prod.json'),
@@ -94,7 +97,8 @@ module.exports = {
9497

9598
const ownPackageJson = require('../package.json');
9699
const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
97-
const reactScriptsLinked = fs.existsSync(reactScriptsPath) &&
100+
const reactScriptsLinked =
101+
fs.existsSync(reactScriptsPath) &&
98102
fs.lstatSync(reactScriptsPath).isSymbolicLink();
99103

100104
// config before publish: we're in ./packages/react-scripts/config/
@@ -113,6 +117,7 @@ if (
113117
appSrc: resolveOwn('template/src'),
114118
yarnLockFile: resolveOwn('template/yarn.lock'),
115119
testsSetup: resolveOwn('template/src/setupTests.ts'),
120+
proxySetup: resolveOwn('template/src/setupProxy.js'),
116121
appNodeModules: resolveOwn('node_modules'),
117122
appTsConfig: resolveOwn('template/tsconfig.json'),
118123
appTsProdConfig: resolveOwn('template/tsconfig.prod.json'),

0 commit comments

Comments
 (0)