diff --git a/packages/babel-plugin-named-asset-import/index.js b/packages/babel-plugin-named-asset-import/index.js index 6fd919bc676..f1989e5ee06 100644 --- a/packages/babel-plugin-named-asset-import/index.js +++ b/packages/babel-plugin-named-asset-import/index.js @@ -7,7 +7,12 @@ function namedAssetImportPlugin({ types: t }) { return { visitor: { - ImportDeclaration(path, { opts: { loaderMap } }) { + ImportDeclaration( + path, + { + opts: { loaderMap }, + } + ) { const sourcePath = path.node.source.value; const ext = extname(sourcePath).substr(1); diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index 68aae411f12..968e57c3932 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -43,7 +43,7 @@ function printFileSizesAfterBuild( name: path.basename(asset.name), size: size, sizeLabel: - filesize(size) + (difference ? ' (' + difference + ')' : '') + filesize(size) + (difference ? ' (' + difference + ')' : ''), }; }) ) diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index a16954c91ed..9ce24fd11a0 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -84,7 +84,8 @@ class ModuleScopePlugin { } else { callback(); } - }); + } + ); } } diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js index cb02af89237..2099a57ec35 100644 --- a/packages/react-dev-utils/clearConsole.js +++ b/packages/react-dev-utils/clearConsole.js @@ -8,7 +8,9 @@ 'use strict'; function clearConsole() { - process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'); + process.stdout.write( + process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H' + ); } module.exports = clearConsole; diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index f9eda7752b4..8df45464977 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -58,7 +58,9 @@ function getProcessCommand(processId, processDirectory) { function getDirectoryOfProcessById(processId) { return execSync( - 'lsof -p ' + processId + ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'', + 'lsof -p ' + + processId + + ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'', execOptions ).trim(); } diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 3f43528ccd8..f2257677150 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -225,7 +225,7 @@ module.exports = { { loader: require.resolve('thread-loader'), options: { - poolTimeout: Infinity // keep workers alive for more effective watch mode + poolTimeout: Infinity, // keep workers alive for more effective watch mode }, }, { @@ -266,7 +266,7 @@ module.exports = { { loader: require.resolve('thread-loader'), options: { - poolTimeout: Infinity // keep workers alive for more effective watch mode + poolTimeout: Infinity, // keep workers alive for more effective watch mode }, }, { @@ -331,7 +331,7 @@ module.exports = { }, // The GraphQL loader preprocesses GraphQL queries in .graphql files. { - test: /\.(graphql)$/, + test: /\.(graphql|gql)$/, loader: 'graphql-tag/loader', }, // "file" loader makes sure those assets get served by WebpackDevServer. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 4d04909a8b4..206d7900fbb 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -365,7 +365,7 @@ module.exports = { }, // The GraphQL loader preprocesses GraphQL queries in .graphql files. { - test: /\.(graphql)$/, + test: /\.(graphql|gql)$/, loader: 'graphql-tag/loader', }, // "file" loader makes sure assets end up in the `build` folder. diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index ff3d383219d..505f23f68c7 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -11,40 +11,43 @@ import url from 'url'; const matchCSS = (doc, regexes) => { if (process.env.E2E_FILE) { - const elements = doc.getElementsByTagName('link'); - let href = ""; - for (const elem of elements) { - if (elem.rel === 'stylesheet') { - href = elem.href; - } + const elements = doc.getElementsByTagName('link'); + let href = ''; + for (const elem of elements) { + if (elem.rel === 'stylesheet') { + href = elem.href; } - resourceLoader( - { url: url.parse(href) }, - (_, textContent) => { - for (const regex of regexes) { - expect(textContent).to.match(regex); - } - } - ); - + } + resourceLoader({ url: url.parse(href) }, (_, textContent) => { + for (const regex of regexes) { + expect(textContent).to.match(regex); + } + }); } else { for (let i = 0; i < regexes.length; ++i) { - expect(doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '')).to.match(regexes[i]); + expect( + doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '') + ).to.match(regexes[i]); } } -} +}; describe('Integration', () => { describe('Webpack plugins', () => { it('css inclusion', async () => { const doc = await initDOM('css-inclusion'); - matchCSS(doc, [/html\{/, /#feature-css-inclusion\{background:.+;color:.+}/]); + matchCSS(doc, [ + /html\{/, + /#feature-css-inclusion\{background:.+;color:.+}/, + ]); }); it('css modules inclusion', async () => { const doc = await initDOM('css-modules-inclusion'); - matchCSS(doc, [/.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, - /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/]); + matchCSS(doc, [ + /.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, + /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/, + ]); }); it('scss inclusion', async () => { @@ -54,9 +57,10 @@ describe('Integration', () => { it('scss modules inclusion', async () => { const doc = await initDOM('scss-modules-inclusion'); - matchCSS(doc, [/.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/]); - + matchCSS(doc, [ + /.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, + /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/, + ]); }); it('sass inclusion', async () => { @@ -66,8 +70,10 @@ describe('Integration', () => { it('sass modules inclusion', async () => { const doc = await initDOM('sass-modules-inclusion'); - matchCSS(doc, [/.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/]); + matchCSS(doc, [ + /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, + /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, + ]); }); it('graphql files inclusion', async () => { diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index f5e3d5911b1..73c844a8aaf 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -28,7 +28,10 @@ class BuiltEmitter extends Component { } render() { - const { props: { feature }, handleReady } = this; + const { + props: { feature }, + handleReady, + } = this; return (
{JSON.stringify(A)}
); + +export const GQLExtension = () => ( ++ {JSON.stringify(B)} +
+); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.test.js index 914ce241bdd..56c28ac062d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.test.js @@ -7,11 +7,15 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import GraphQLInclusion from './GraphQLInclusion'; +import { GraphLExtension, GQLExtension } from './GraphQLInclusion'; describe('graphql files inclusion', () => { - it('renders without crashing', () => { + it('renders without crashing with GraphLExtension', () => { const div = document.createElement('div'); ReactDOM.render(