Commit a171d930 authored by Dan Abramov's avatar Dan Abramov
Browse files

Reformat source code with Prettier 1.5.2

parent 29c8733e
Showing with 191 additions and 126 deletions
+191 -126
...@@ -74,10 +74,14 @@ const program = new commander.Command(packageJson.name) ...@@ -74,10 +74,14 @@ const program = new commander.Command(packageJson.name)
); );
console.log(` - a specific npm version: ${chalk.green('0.8.2')}`); console.log(` - a specific npm version: ${chalk.green('0.8.2')}`);
console.log( console.log(
` - a custom fork published on npm: ${chalk.green('my-react-scripts')}` ` - a custom fork published on npm: ${chalk.green(
'my-react-scripts'
)}`
); );
console.log( console.log(
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}` ` - a .tgz archive: ${chalk.green(
'https://mysite.com/my-react-scripts-0.8.2.tgz'
)}`
); );
console.log( console.log(
` It is not needed unless you specifically want to use a fork.` ` It is not needed unless you specifically want to use a fork.`
...@@ -87,7 +91,9 @@ const program = new commander.Command(packageJson.name) ...@@ -87,7 +91,9 @@ const program = new commander.Command(packageJson.name)
` If you have any problems, do not hesitate to file an issue:` ` If you have any problems, do not hesitate to file an issue:`
); );
console.log( console.log(
` ${chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new')}` ` ${chalk.cyan(
'https://github.com/facebookincubator/create-react-app/issues/new'
)}`
); );
console.log(); console.log();
}) })
...@@ -258,15 +264,19 @@ function run( ...@@ -258,15 +264,19 @@ function run(
console.log('Installing packages. This might take a couple of minutes.'); console.log('Installing packages. This might take a couple of minutes.');
getPackageName(packageToInstall) getPackageName(packageToInstall)
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({ .then(packageName =>
isOnline: isOnline, checkIfOnline(useYarn).then(isOnline => ({
packageName: packageName, isOnline: isOnline,
}))) packageName: packageName,
}))
)
.then(info => { .then(info => {
const isOnline = info.isOnline; const isOnline = info.isOnline;
const packageName = info.packageName; const packageName = info.packageName;
console.log( console.log(
`Installing ${chalk.cyan('react')}, ${chalk.cyan('react-dom')}, and ${chalk.cyan(packageName)}...` `Installing ${chalk.cyan('react')}, ${chalk.cyan(
'react-dom'
)}, and ${chalk.cyan(packageName)}...`
); );
console.log(); console.log();
...@@ -334,7 +344,9 @@ function run( ...@@ -334,7 +344,9 @@ function run(
if (!remainingFiles.length) { if (!remainingFiles.length) {
// Delete target folder if empty // Delete target folder if empty
console.log( console.log(
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(path.resolve(root, '..'))}` `Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(
path.resolve(root, '..')
)}`
); );
process.chdir(path.resolve(root, '..')); process.chdir(path.resolve(root, '..'));
fs.removeSync(path.join(root)); fs.removeSync(path.join(root));
...@@ -422,7 +434,9 @@ function getPackageName(installPackage) { ...@@ -422,7 +434,9 @@ function getPackageName(installPackage) {
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/ /^.+\/(.+?)(?:-\d+.+)?\.tgz$/
)[1]; )[1];
console.log( console.log(
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"` `Based on the filename, assuming it is "${chalk.cyan(
assumedProjectName
)}"`
); );
return Promise.resolve(assumedProjectName); return Promise.resolve(assumedProjectName);
}); });
...@@ -485,7 +499,9 @@ function checkAppName(appName) { ...@@ -485,7 +499,9 @@ function checkAppName(appName) {
const validationResult = validateProjectName(appName); const validationResult = validateProjectName(appName);
if (!validationResult.validForNewPackages) { if (!validationResult.validForNewPackages) {
console.error( console.error(
`Could not create a project called ${chalk.red(`"${appName}"`)} because of npm naming restrictions:` `Could not create a project called ${chalk.red(
`"${appName}"`
)} because of npm naming restrictions:`
); );
printValidationResults(validationResult.errors); printValidationResults(validationResult.errors);
printValidationResults(validationResult.warnings); printValidationResults(validationResult.warnings);
...@@ -497,7 +513,9 @@ function checkAppName(appName) { ...@@ -497,7 +513,9 @@ function checkAppName(appName) {
if (dependencies.indexOf(appName) >= 0) { if (dependencies.indexOf(appName) >= 0) {
console.error( console.error(
chalk.red( chalk.red(
`We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` + `We cannot create a project called ${chalk.green(
appName
)} because a dependency with the same name exists.\n` +
`Due to the way npm works, the following names are not allowed:\n\n` `Due to the way npm works, the following names are not allowed:\n\n`
) + ) +
chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) + chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) +
...@@ -519,7 +537,9 @@ function makeCaretRange(dependencies, name) { ...@@ -519,7 +537,9 @@ function makeCaretRange(dependencies, name) {
if (!semver.validRange(patchedVersion)) { if (!semver.validRange(patchedVersion)) {
console.error( console.error(
`Unable to patch ${name} dependency version because version ${chalk.red(version)} will become invalid ${chalk.red(patchedVersion)}` `Unable to patch ${name} dependency version because version ${chalk.red(
version
)} will become invalid ${chalk.red(patchedVersion)}`
); );
patchedVersion = version; patchedVersion = version;
} }
......
...@@ -236,7 +236,8 @@ module.exports = { ...@@ -236,7 +236,8 @@ module.exports = {
{ {
object: 'System', object: 'System',
property: 'import', property: 'import',
message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', message:
'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
}, },
], ],
......
...@@ -119,15 +119,12 @@ function measureFileSizesBeforeBuild(buildFolder) { ...@@ -119,15 +119,12 @@ function measureFileSizesBeforeBuild(buildFolder) {
if (!err && fileNames) { if (!err && fileNames) {
sizes = fileNames sizes = fileNames
.filter(fileName => /\.(js|css)$/.test(fileName)) .filter(fileName => /\.(js|css)$/.test(fileName))
.reduce( .reduce((memo, fileName) => {
(memo, fileName) => { var contents = fs.readFileSync(fileName);
var contents = fs.readFileSync(fileName); var key = removeFileNameHash(buildFolder, fileName);
var key = removeFileNameHash(buildFolder, fileName); memo[key] = gzipSize(contents);
memo[key] = gzipSize(contents); return memo;
return memo; }, {});
},
{}
);
} }
resolve({ resolve({
root: buildFolder, root: buildFolder,
......
...@@ -37,10 +37,7 @@ class ModuleScopePlugin { ...@@ -37,10 +37,7 @@ class ModuleScopePlugin {
// Maybe an indexOf === 0 would be better? // Maybe an indexOf === 0 would be better?
const relative = path.relative(appSrc, request.context.issuer); const relative = path.relative(appSrc, request.context.issuer);
// If it's not in src/ or a subdirectory, not our request! // If it's not in src/ or a subdirectory, not our request!
if ( if (relative.startsWith('../') || relative.startsWith('..\\')) {
relative.startsWith('../') ||
relative.startsWith('..\\')
) {
return callback(); return callback();
} }
// Find path from src to the requested file // Find path from src to the requested file
...@@ -58,9 +55,19 @@ class ModuleScopePlugin { ...@@ -58,9 +55,19 @@ class ModuleScopePlugin {
) { ) {
callback( callback(
new Error( new Error(
`You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` + `You attempted to import ${chalk.cyan(
`Relative imports outside of ${chalk.cyan('src/')} are not supported. ` + request.__innerRequest_request
`You can either move it inside ${chalk.cyan('src/')}, or add a symlink to it from project's ${chalk.cyan('node_modules/')}.` )} which falls outside of the project ${chalk.cyan(
'src/'
)} directory. ` +
`Relative imports outside of ${chalk.cyan(
'src/'
)} are not supported. ` +
`You can either move it inside ${chalk.cyan(
'src/'
)}, or add a symlink to it from project's ${chalk.cyan(
'node_modules/'
)}.`
), ),
request request
); );
......
...@@ -37,18 +37,20 @@ if (isSmokeTest) { ...@@ -37,18 +37,20 @@ if (isSmokeTest) {
} }
function prepareUrls(protocol, host, port) { function prepareUrls(protocol, host, port) {
const formatUrl = hostname => url.format({ const formatUrl = hostname =>
protocol, url.format({
hostname, protocol,
port, hostname,
pathname: '/', port,
}); pathname: '/',
const prettyPrintUrl = hostname => url.format({ });
protocol, const prettyPrintUrl = hostname =>
hostname, url.format({
port: chalk.bold(port), protocol,
pathname: '/', hostname,
}); port: chalk.bold(port),
pathname: '/',
});
const isUnspecifiedHost = host === '0.0.0.0' || host === '::'; const isUnspecifiedHost = host === '0.0.0.0' || host === '::';
let prettyHost, lanUrlForConfig, lanUrlForTerminal; let prettyHost, lanUrlForConfig, lanUrlForTerminal;
...@@ -317,9 +319,11 @@ function prepareProxy(proxy, appPublicFolder) { ...@@ -317,9 +319,11 @@ function prepareProxy(proxy, appPublicFolder) {
// However API calls like `fetch()` won’t generally accept text/html. // However API calls like `fetch()` won’t generally accept text/html.
// If this heuristic doesn’t work well for you, use a custom `proxy` object. // If this heuristic doesn’t work well for you, use a custom `proxy` object.
context: function(pathname, req) { context: function(pathname, req) {
return mayProxy(pathname) && return (
mayProxy(pathname) &&
req.headers.accept && req.headers.accept &&
req.headers.accept.indexOf('text/html') === -1; req.headers.accept.indexOf('text/html') === -1
);
}, },
onProxyReq: proxyReq => { onProxyReq: proxyReq => {
// Browers may send Origin headers even with same-origin // Browers may send Origin headers even with same-origin
...@@ -375,39 +379,40 @@ function prepareProxy(proxy, appPublicFolder) { ...@@ -375,39 +379,40 @@ function prepareProxy(proxy, appPublicFolder) {
function choosePort(host, defaultPort) { function choosePort(host, defaultPort) {
return detect(defaultPort, host).then( return detect(defaultPort, host).then(
port => new Promise(resolve => { port =>
if (port === defaultPort) { new Promise(resolve => {
return resolve(port); if (port === defaultPort) {
} return resolve(port);
const message = process.platform !== 'win32' && }
defaultPort < 1024 && const message =
!isRoot() process.platform !== 'win32' && defaultPort < 1024 && !isRoot()
? `Admin permissions are required to run a server on a port below 1024.` ? `Admin permissions are required to run a server on a port below 1024.`
: `Something is already running on port ${defaultPort}.`; : `Something is already running on port ${defaultPort}.`;
if (isInteractive) { if (isInteractive) {
clearConsole(); clearConsole();
const existingProcess = getProcessForPort(defaultPort); const existingProcess = getProcessForPort(defaultPort);
const question = { const question = {
type: 'confirm', type: 'confirm',
name: 'shouldChangePort', name: 'shouldChangePort',
message: chalk.yellow( message:
message + chalk.yellow(
`${existingProcess ? ` Probably:\n ${existingProcess}` : ''}` message +
) + '\n\nWould you like to run the app on another port instead?', `${existingProcess ? ` Probably:\n ${existingProcess}` : ''}`
default: true, ) + '\n\nWould you like to run the app on another port instead?',
}; default: true,
inquirer.prompt(question).then(answer => { };
if (answer.shouldChangePort) { inquirer.prompt(question).then(answer => {
resolve(port); if (answer.shouldChangePort) {
} else { resolve(port);
resolve(null); } else {
} resolve(null);
}); }
} else { });
console.log(chalk.red(message)); } else {
resolve(null); console.log(chalk.red(message));
} resolve(null);
}), }
}),
err => { err => {
throw new Error( throw new Error(
chalk.red(`Could not find an open port at ${chalk.bold(host)}.`) + chalk.red(`Could not find an open port at ${chalk.bold(host)}.`) +
......
...@@ -69,7 +69,8 @@ function ansiHTML(txt) { ...@@ -69,7 +69,8 @@ function ansiHTML(txt) {
var open = false; var open = false;
for (var index = 0; index < arr.length; ++index) { for (var index = 0; index < arr.length; ++index) {
var c = arr[index]; var c = arr[index];
var content = c.content, fg = c.fg; var content = c.content,
fg = c.fg;
var contentParts = content.split('\n'); var contentParts = content.split('\n');
for (var _index = 0; _index < contentParts.length; ++_index) { for (var _index = 0; _index < contentParts.length; ++_index) {
......
...@@ -82,7 +82,8 @@ function formatter(results) { ...@@ -82,7 +82,8 @@ function formatter(results) {
// it here because we always show at most one error, and // it here because we always show at most one error, and
// we can only be sure it's an ESLint error before exiting // we can only be sure it's an ESLint error before exiting
// this function. // this function.
output += 'Search for the ' + output +=
'Search for the ' +
chalk.underline(chalk.red('keywords')) + chalk.underline(chalk.red('keywords')) +
' to learn more about each error.'; ' to learn more about each error.';
} }
......
...@@ -30,10 +30,13 @@ function isTerminalEditor(editor) { ...@@ -30,10 +30,13 @@ function isTerminalEditor(editor) {
// of the app every time // of the app every time
const COMMON_EDITORS_OSX = { const COMMON_EDITORS_OSX = {
'/Applications/Atom.app/Contents/MacOS/Atom': 'atom', '/Applications/Atom.app/Contents/MacOS/Atom': 'atom',
'/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta':
'/Applications/Atom Beta.app/Contents/MacOS/Atom Beta',
'/Applications/Brackets.app/Contents/MacOS/Brackets': 'brackets', '/Applications/Brackets.app/Contents/MacOS/Brackets': 'brackets',
'/Applications/Sublime Text.app/Contents/MacOS/Sublime Text': '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text':
'/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl',
'/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2':
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code', '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code',
}; };
......
...@@ -68,7 +68,8 @@ function startBrowserProcess(browser, url) { ...@@ -68,7 +68,8 @@ function startBrowserProcess(browser, url) {
// requested a different browser, we can try opening // requested a different browser, we can try opening
// Chrome with AppleScript. This lets us reuse an // Chrome with AppleScript. This lets us reuse an
// existing tab when possible instead of creating a new one. // existing tab when possible instead of creating a new one.
const shouldTryOpenChromeWithAppleScript = process.platform === 'darwin' && const shouldTryOpenChromeWithAppleScript =
process.platform === 'darwin' &&
(typeof browser !== 'string' || browser === OSX_CHROME); (typeof browser !== 'string' || browser === OSX_CHROME);
if (shouldTryOpenChromeWithAppleScript) { if (shouldTryOpenChromeWithAppleScript) {
......
...@@ -23,10 +23,14 @@ function printHostingInstructions( ...@@ -23,10 +23,14 @@ function printHostingInstructions(
if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) { if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) {
// "homepage": "http://user.github.io/project" // "homepage": "http://user.github.io/project"
console.log( console.log(
`The project was built assuming it is hosted at ${chalk.green(publicPathname)}.` `The project was built assuming it is hosted at ${chalk.green(
publicPathname
)}.`
); );
console.log( console.log(
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` `You can control this with the ${chalk.green(
'homepage'
)} field in your ${chalk.cyan('package.json')}.`
); );
console.log(); console.log();
console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
...@@ -48,10 +52,14 @@ function printHostingInstructions( ...@@ -48,10 +52,14 @@ function printHostingInstructions(
console.log(` ${chalk.yellow('"scripts"')}: {`); console.log(` ${chalk.yellow('"scripts"')}: {`);
console.log(` ${chalk.dim('// ...')}`); console.log(` ${chalk.dim('// ...')}`);
console.log( console.log(
` ${chalk.yellow('"predeploy"')}: ${chalk.yellow('"npm run build",')}` ` ${chalk.yellow('"predeploy"')}: ${chalk.yellow(
'"npm run build",'
)}`
); );
console.log( console.log(
` ${chalk.yellow('"deploy"')}: ${chalk.yellow('"gh-pages -d build"')}` ` ${chalk.yellow('"deploy"')}: ${chalk.yellow(
'"gh-pages -d build"'
)}`
); );
console.log(' }'); console.log(' }');
console.log(); console.log();
...@@ -63,10 +71,14 @@ function printHostingInstructions( ...@@ -63,10 +71,14 @@ function printHostingInstructions(
} else if (publicPath !== '/') { } else if (publicPath !== '/') {
// "homepage": "http://mywebsite.com/project" // "homepage": "http://mywebsite.com/project"
console.log( console.log(
`The project was built assuming it is hosted at ${chalk.green(publicPath)}.` `The project was built assuming it is hosted at ${chalk.green(
publicPath
)}.`
); );
console.log( console.log(
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` `You can control this with the ${chalk.green(
'homepage'
)} field in your ${chalk.cyan('package.json')}.`
); );
console.log(); console.log();
console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
...@@ -75,10 +87,14 @@ function printHostingInstructions( ...@@ -75,10 +87,14 @@ function printHostingInstructions(
if (publicUrl) { if (publicUrl) {
// "homepage": "http://mywebsite.com" // "homepage": "http://mywebsite.com"
console.log( console.log(
`The project was built assuming it is hosted at ${chalk.green(publicUrl)}.` `The project was built assuming it is hosted at ${chalk.green(
publicUrl
)}.`
); );
console.log( console.log(
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` `You can control this with the ${chalk.green(
'homepage'
)} field in your ${chalk.cyan('package.json')}.`
); );
console.log(); console.log();
} else { } else {
...@@ -87,12 +103,16 @@ function printHostingInstructions( ...@@ -87,12 +103,16 @@ function printHostingInstructions(
'The project was built assuming it is hosted at the server root.' 'The project was built assuming it is hosted at the server root.'
); );
console.log( console.log(
`To override this, specify the ${chalk.green('homepage')} in your ${chalk.cyan('package.json')}.` `To override this, specify the ${chalk.green(
'homepage'
)} in your ${chalk.cyan('package.json')}.`
); );
console.log('For example, add this to build it for GitHub Pages:'); console.log('For example, add this to build it for GitHub Pages:');
console.log(); console.log();
console.log( console.log(
` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green('"http://myname.github.io/myapp"')}${chalk.cyan(',')}` ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green(
'"http://myname.github.io/myapp"'
)}${chalk.cyan(',')}`
); );
console.log(); console.log();
} }
......
...@@ -81,14 +81,16 @@ function addOverlayDivTo(iframe) { ...@@ -81,14 +81,16 @@ function addOverlayDivTo(iframe) {
} }
function overlayHeaderStyle() { function overlayHeaderStyle() {
return 'font-size: 2em;' + return (
'font-size: 2em;' +
'font-family: sans-serif;' + 'font-family: sans-serif;' +
'color: rgb(206, 17, 38);' + 'color: rgb(206, 17, 38);' +
'white-space: pre-wrap;' + 'white-space: pre-wrap;' +
'margin: 0 2rem 0.75rem 0px;' + 'margin: 0 2rem 0.75rem 0px;' +
'flex: 0 0 auto;' + 'flex: 0 0 auto;' +
'max-height: 35%;' + 'max-height: 35%;' +
'overflow: auto;'; 'overflow: auto;'
);
} }
var overlayIframe = null; var overlayIframe = null;
...@@ -127,7 +129,8 @@ function ensureOverlayDivExists(onOverlayDivReady) { ...@@ -127,7 +129,8 @@ function ensureOverlayDivExists(onOverlayDivReady) {
function showErrorOverlay(message) { function showErrorOverlay(message) {
ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) { ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) {
// TODO: unify this with our runtime overlay // TODO: unify this with our runtime overlay
overlayDiv.innerHTML = '<div style="' + overlayDiv.innerHTML =
'<div style="' +
overlayHeaderStyle() + overlayHeaderStyle() +
'">Failed to compile</div>' + '">Failed to compile</div>' +
'<pre style="' + '<pre style="' +
......
...@@ -14,7 +14,8 @@ import { resolve } from 'path'; ...@@ -14,7 +14,8 @@ import { resolve } from 'path';
test('basic error; 0 context', async () => { test('basic error; 0 context', async () => {
expect.assertions(1); expect.assertions(1);
const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)\n at http://localhost:3000/static/js/bundle.js:30091:25\n at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:29901:12)\n at http://localhost:3000/static/js/bundle.js:30090:11\n at CallbackQueue.notifyAll (http://localhost:3000/static/js/bundle.js:13256:22)\n at ReactReconcileTransaction.close (http://localhost:3000/static/js/bundle.js:35124:26)\n at ReactReconcileTransaction.closeAll (http://localhost:3000/static/js/bundle.js:7390:25)\n at ReactReconcileTransaction.perform (http://localhost:3000/static/js/bundle.js:7337:16)\n at batchedMountComponentIntoNode (http://localhost:3000/static/js/bundle.js:14204:15)\n at ReactDefaultBatchingStrategyTransaction.perform (http://localhost:3000/static/js/bundle.js:7324:20)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:33900:26)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:2181:27)\n at Object._renderNewRootComponent (http://localhost:3000/static/js/bundle.js:14398:18)\n at Object._renderSubtreeIntoContainer (http://localhost:3000/static/js/bundle.js:14479:32)\n at Object.render (http://localhost:3000/static/js/bundle.js:14500:23)\n at Object.friendlySyntaxErrorLabel (http://localhost:3000/static/js/bundle.js:17287:20)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at fn (http://localhost:3000/static/js/bundle.js:84:20)\n at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:41219:18)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at validateFormat (http://localhost:3000/static/js/bundle.js:709:39)\n at http://localhost:3000/static/js/bundle.js:712:10'; const error =
'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)\n at http://localhost:3000/static/js/bundle.js:30091:25\n at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:29901:12)\n at http://localhost:3000/static/js/bundle.js:30090:11\n at CallbackQueue.notifyAll (http://localhost:3000/static/js/bundle.js:13256:22)\n at ReactReconcileTransaction.close (http://localhost:3000/static/js/bundle.js:35124:26)\n at ReactReconcileTransaction.closeAll (http://localhost:3000/static/js/bundle.js:7390:25)\n at ReactReconcileTransaction.perform (http://localhost:3000/static/js/bundle.js:7337:16)\n at batchedMountComponentIntoNode (http://localhost:3000/static/js/bundle.js:14204:15)\n at ReactDefaultBatchingStrategyTransaction.perform (http://localhost:3000/static/js/bundle.js:7324:20)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:33900:26)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:2181:27)\n at Object._renderNewRootComponent (http://localhost:3000/static/js/bundle.js:14398:18)\n at Object._renderSubtreeIntoContainer (http://localhost:3000/static/js/bundle.js:14479:32)\n at Object.render (http://localhost:3000/static/js/bundle.js:14500:23)\n at Object.friendlySyntaxErrorLabel (http://localhost:3000/static/js/bundle.js:17287:20)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at fn (http://localhost:3000/static/js/bundle.js:84:20)\n at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:41219:18)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at validateFormat (http://localhost:3000/static/js/bundle.js:709:39)\n at http://localhost:3000/static/js/bundle.js:712:10';
fetch.mockResponseOnce( fetch.mockResponseOnce(
fs fs
...@@ -38,7 +39,8 @@ test('basic error; 0 context', async () => { ...@@ -38,7 +39,8 @@ test('basic error; 0 context', async () => {
test('default context (3)', async () => { test('default context (3)', async () => {
expect.assertions(1); expect.assertions(1);
const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)'; const error =
'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)';
fetch.mockResponseOnce( fetch.mockResponseOnce(
fs fs
...@@ -62,7 +64,8 @@ test('default context (3)', async () => { ...@@ -62,7 +64,8 @@ test('default context (3)', async () => {
test('bad comes back same', async () => { test('bad comes back same', async () => {
expect.assertions(2); expect.assertions(2);
const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (A:1:2)'; const error =
'TypeError: document.body.missing is not a function\n at App.componentDidMount (A:1:2)';
const orig = parse(error); const orig = parse(error);
expect(orig).toEqual([ expect(orig).toEqual([
{ {
......
...@@ -242,8 +242,8 @@ function createFrame( ...@@ -242,8 +242,8 @@ function createFrame(
let needsHidden = false; let needsHidden = false;
const isInternalUrl = isInternalFile(sourceFileName, fileName); const isInternalUrl = isInternalFile(sourceFileName, fileName);
const isThrownIntentionally = !isBultinErrorName(errorName); const isThrownIntentionally = !isBultinErrorName(errorName);
const shouldCollapse = isInternalUrl && const shouldCollapse =
(isThrownIntentionally || omits.hasReachedAppCode); isInternalUrl && (isThrownIntentionally || omits.hasReachedAppCode);
if (!isInternalUrl) { if (!isInternalUrl) {
omits.hasReachedAppCode = true; omits.hasReachedAppCode = true;
...@@ -281,9 +281,8 @@ function createFrame( ...@@ -281,9 +281,8 @@ function createFrame(
let onSourceClick = null; let onSourceClick = null;
if (sourceFileName) { if (sourceFileName) {
// e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1"
const isInternalWebpackBootstrapCode = sourceFileName const isInternalWebpackBootstrapCode =
.trim() sourceFileName.trim().indexOf(' ') !== -1;
.indexOf(' ') !== -1;
if (!isInternalWebpackBootstrapCode) { if (!isInternalWebpackBootstrapCode) {
onSourceClick = () => { onSourceClick = () => {
// Keep this in sync with react-error-overlay/middleware.js // Keep this in sync with react-error-overlay/middleware.js
...@@ -312,7 +311,10 @@ function createFrame( ...@@ -312,7 +311,10 @@ function createFrame(
let hasSource = false; let hasSource = false;
if (!shouldCollapse) { if (!shouldCollapse) {
if ( if (
compiled && scriptLines && scriptLines.length !== 0 && lineNumber != null compiled &&
scriptLines &&
scriptLines.length !== 0 &&
lineNumber != null
) { ) {
elem.appendChild( elem.appendChild(
createCode( createCode(
......
...@@ -60,9 +60,8 @@ function createOverlay( ...@@ -60,9 +60,8 @@ function createOverlay(
applyStyles(header, headerStyle); applyStyles(header, headerStyle);
// Make message prettier // Make message prettier
let finalMessage = message.match(/^\w*:/) || !name let finalMessage =
? message message.match(/^\w*:/) || !name ? message : name + ': ' + message;
: name + ': ' + message;
finalMessage = finalMessage finalMessage = finalMessage
// TODO: maybe remove this prefix from fbjs? // TODO: maybe remove this prefix from fbjs?
......
...@@ -9,13 +9,15 @@ ...@@ -9,13 +9,15 @@
/* @flow */ /* @flow */
function isInternalFile(sourceFileName: ?string, fileName: ?string) { function isInternalFile(sourceFileName: ?string, fileName: ?string) {
return sourceFileName == null || return (
sourceFileName == null ||
sourceFileName === '' || sourceFileName === '' ||
sourceFileName.indexOf('/~/') !== -1 || sourceFileName.indexOf('/~/') !== -1 ||
sourceFileName.indexOf('/node_modules/') !== -1 || sourceFileName.indexOf('/node_modules/') !== -1 ||
sourceFileName.trim().indexOf(' ') !== -1 || sourceFileName.trim().indexOf(' ') !== -1 ||
fileName == null || fileName == null ||
fileName === ''; fileName === ''
);
} }
export { isInternalFile }; export { isInternalFile };
...@@ -15,7 +15,8 @@ import path from 'path'; ...@@ -15,7 +15,8 @@ import path from 'path';
function count(search: string, string: string): number { function count(search: string, string: string): number {
// Count starts at -1 becuse a do-while loop always runs at least once // Count starts at -1 becuse a do-while loop always runs at least once
let count = -1, index = -1; let count = -1,
index = -1;
do { do {
// First call or the while case evaluated true, meaning we have to make // First call or the while case evaluated true, meaning we have to make
// count 0 or we found a character // count 0 or we found a character
......
...@@ -88,13 +88,10 @@ function getClientEnvironment(publicUrl) { ...@@ -88,13 +88,10 @@ function getClientEnvironment(publicUrl) {
); );
// Stringify all values so we can feed into Webpack DefinePlugin // Stringify all values so we can feed into Webpack DefinePlugin
const stringified = { const stringified = {
'process.env': Object.keys(raw).reduce( 'process.env': Object.keys(raw).reduce((env, key) => {
(env, key) => { env[key] = JSON.stringify(raw[key]);
env[key] = JSON.stringify(raw[key]); return env;
return env; }, {}),
},
{}
),
}; };
return { raw, stringified }; return { raw, stringified };
......
...@@ -43,8 +43,8 @@ const getPublicUrl = appPackageJson => ...@@ -43,8 +43,8 @@ const getPublicUrl = appPackageJson =>
// like /todos/42/static/js/bundle.7289d.js. We have to know the root. // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
function getServedPath(appPackageJson) { function getServedPath(appPackageJson) {
const publicUrl = getPublicUrl(appPackageJson); const publicUrl = getPublicUrl(appPackageJson);
const servedUrl = envPublicUrl || const servedUrl =
(publicUrl ? url.parse(publicUrl).pathname : '/'); envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
return ensureSlash(servedUrl, true); return ensureSlash(servedUrl, true);
} }
...@@ -89,7 +89,8 @@ module.exports = { ...@@ -89,7 +89,8 @@ module.exports = {
const ownPackageJson = require('../package.json'); const ownPackageJson = require('../package.json');
const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`); const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
const reactScriptsLinked = fs.existsSync(reactScriptsPath) && const reactScriptsLinked =
fs.existsSync(reactScriptsPath) &&
fs.lstatSync(reactScriptsPath).isSymbolicLink(); fs.lstatSync(reactScriptsPath).isSymbolicLink();
// config before publish: we're in ./packages/react-scripts/config/ // config before publish: we're in ./packages/react-scripts/config/
......
...@@ -36,8 +36,8 @@ module.exports = function(proxy, allowedHost) { ...@@ -36,8 +36,8 @@ module.exports = function(proxy, allowedHost) {
// So we will disable the host check normally, but enable it if you have // So we will disable the host check normally, but enable it if you have
// specified the `proxy` setting. Finally, we let you override it if you // specified the `proxy` setting. Finally, we let you override it if you
// really know what you're doing with a special environment variable. // really know what you're doing with a special environment variable.
disableHostCheck: !proxy || disableHostCheck:
process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true', !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
// Enable gzip compression of generated files. // Enable gzip compression of generated files.
compress: true, compress: true,
// Silence WebpackDevServer's own logs since they're generally not useful. // Silence WebpackDevServer's own logs since they're generally not useful.
......
...@@ -50,9 +50,10 @@ describe('Integration', () => { ...@@ -50,9 +50,10 @@ describe('Integration', () => {
it('PUBLIC_URL', async () => { it('PUBLIC_URL', async () => {
const doc = await initDOM('public-url'); const doc = await initDOM('public-url');
const prefix = process.env.NODE_ENV === 'development' const prefix =
? '' process.env.NODE_ENV === 'development'
: 'http://www.example.org/spa'; ? ''
: 'http://www.example.org/spa';
expect(doc.getElementById('feature-public-url').textContent).to.equal( expect(doc.getElementById('feature-public-url').textContent).to.equal(
`${prefix}.` `${prefix}.`
); );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment