diff --git a/docs/angular/api-node/generators/migrate-to-webpack-5.md b/docs/angular/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index d0edd66e99..0000000000 --- a/docs/angular/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `angular.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/docs/angular/api-react/generators/application.md b/docs/angular/api-react/generators/application.md index e1148d0f29..f22dd9afc0 100644 --- a/docs/angular/api-react/generators/application.md +++ b/docs/angular/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/docs/angular/api-web/executors/build.md b/docs/angular/api-web/executors/build.md index 9f54416caf..5e3eb24599 100644 --- a/docs/angular/api-web/executors/build.md +++ b/docs/angular/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/docs/angular/api-web/generators/migrate-to-webpack-5.md b/docs/angular/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index a69d004756..0000000000 --- a/docs/angular/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `angular.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/docs/map.json b/docs/map.json index b41e1c58ec..b9f4bf727f 100644 --- a/docs/map.json +++ b/docs/map.json @@ -380,11 +380,6 @@ "id": "build", "file": "angular/api-web/executors/build" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "angular/api-web/generators/migrate-to-webpack-5" - }, { "name": "dev-server executor", "id": "dev-server", @@ -703,11 +698,6 @@ "id": "library", "file": "angular/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "angular/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -1668,11 +1658,6 @@ "id": "application", "file": "react/api-web/generators/application" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "react/api-web/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -2002,11 +1987,6 @@ "id": "library", "file": "react/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "react/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -2925,11 +2905,6 @@ "id": "application", "file": "node/api-web/generators/application" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "node/api-web/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -3242,11 +3217,6 @@ "id": "library", "file": "node/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "node/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", diff --git a/docs/node/api-node/generators/migrate-to-webpack-5.md b/docs/node/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index 8f7cdd395c..0000000000 --- a/docs/node/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/docs/node/api-react/generators/application.md b/docs/node/api-react/generators/application.md index 30f46c5a8a..b53065acd5 100644 --- a/docs/node/api-react/generators/application.md +++ b/docs/node/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/docs/node/api-web/executors/build.md b/docs/node/api-web/executors/build.md index c1bd7d075b..a6af9ed465 100644 --- a/docs/node/api-web/executors/build.md +++ b/docs/node/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/docs/node/api-web/generators/migrate-to-webpack-5.md b/docs/node/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index 64ee7507c3..0000000000 --- a/docs/node/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/docs/react/api-node/generators/migrate-to-webpack-5.md b/docs/react/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index 8f7cdd395c..0000000000 --- a/docs/react/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/docs/react/api-react/generators/application.md b/docs/react/api-react/generators/application.md index 30f46c5a8a..b53065acd5 100644 --- a/docs/react/api-react/generators/application.md +++ b/docs/react/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/docs/react/api-web/executors/build.md b/docs/react/api-web/executors/build.md index c1bd7d075b..a6af9ed465 100644 --- a/docs/react/api-web/executors/build.md +++ b/docs/react/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/docs/react/api-web/generators/migrate-to-webpack-5.md b/docs/react/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index 64ee7507c3..0000000000 --- a/docs/react/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/e2e/next/src/next.test.ts b/e2e/next/src/next.test.ts index b5b4744d79..c738755cc8 100644 --- a/e2e/next/src/next.test.ts +++ b/e2e/next/src/next.test.ts @@ -2,7 +2,6 @@ import { stringUtils } from '@nrwl/workspace'; import { checkFilesExist, createFile, - isNotWindows, killPorts, newProject, promisifiedTreeKill, @@ -465,100 +464,6 @@ describe('Next.js Applications', () => { }); }, 120000); - it('webpack4 - should be able to consume a react libs (buildable and non-buildable)', async () => { - if (isNotWindows()) { - const appName = uniq('app'); - const buildableLibName = uniq('lib'); - const nonBuildableLibName = uniq('lib'); - - runCLI(`generate @nrwl/next:app ${appName} --no-interactive`); - runCLI( - `generate @nrwl/react:lib ${nonBuildableLibName} --no-interactive --style=none` - ); - runCLI( - `generate @nrwl/react:lib ${buildableLibName} --no-interactive --style=none --buildable` - ); - - const mainPath = `apps/${appName}/pages/index.tsx`; - updateFile( - mainPath, - ` - import '@${proj}/${nonBuildableLibName}'; - import '@${proj}/${buildableLibName}'; - ${readFile(mainPath)} - ` - ); - // enable webpack 5 - updateFile( - `apps/${appName}/next.config.js`, - ` - // eslint-disable-next-line @typescript-eslint/no-var-requires - const withNx = require('@nrwl/next/plugins/with-nx'); - module.exports = withNx({ - nx: { - // Set this to false if you do not want to use SVGR - // See: https://github.com/gregberge/svgr - svgr: true, - }, - webpack5: false - }); - ` - ); - - // Update non-buildable lib to use css modules to test that next.js can compile it - updateFile( - `libs/${nonBuildableLibName}/src/lib/${nonBuildableLibName}.tsx`, - ` - import styles from './style.module.css'; - export function Test() { - return
Hello
; - } - export default Test; - ` - ); - updateFile( - `libs/${nonBuildableLibName}/src/lib/style.module.css`, - ` - .container {} - ` - ); - - await checkApp(appName, { - checkUnitTest: true, - checkLint: true, - checkE2E: true, - checkWebpack4: true, - }); - } - }, 300000); - - it('webpack4 - should build with a next.config.js file in the dist folder', async () => { - const appName = uniq('app'); - - runCLI(`generate @nrwl/next:app ${appName} --no-interactive --style=css`); - - updateFile( - `apps/${appName}/next.config.js`, - ` - module.exports = { - webpack5: false, - webpack: (c) => { - console.log('NODE_ENV is', process.env.NODE_ENV); - return c; - } - } - ` - ); - // deleting `NODE_ENV` value, so that it's `undefined`, and not `"test"` - // by the time it reaches the build executor. - // this simulates existing behaviour of running a next.js build executor via Nx - delete process.env.NODE_ENV; - const result = runCLI(`build ${appName}`); - - checkFilesExist(`dist/apps/${appName}/next.config.js`); - expect(result).toContain('NODE_ENV is production'); - }, 120000); - it('should allow using a custom server implementation in TypeScript', async () => { const appName = uniq('app'); const port = 4202; @@ -674,13 +579,9 @@ async function checkApp( checkUnitTest: boolean; checkLint: boolean; checkE2E: boolean; - checkWebpack4?: boolean; } ) { const buildResult = runCLI(`build ${appName} --withDeps`); - if (opts.checkWebpack4) { - expect(buildResult).toContain('Using webpack 4'); - } expect(buildResult).toContain(`Compiled successfully`); checkFilesExist(`dist/apps/${appName}/.next/build-manifest.json`); checkFilesExist(`dist/apps/${appName}/public/star.svg`); diff --git a/e2e/node/src/node-webpack-5.test.ts b/e2e/node/src/node-webpack-5.test.ts deleted file mode 100644 index c8bdd477c8..0000000000 --- a/e2e/node/src/node-webpack-5.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { execSync } from 'child_process'; -import { - checkFilesExist, - newProject, - runCLI, - tmpProjPath, - uniq, -} from '@nrwl/e2e/utils'; - -describe('Node Applications', () => { - beforeEach(() => newProject()); - - it('should be able to generate an empty application', async () => { - const appName = uniq('nodeapp'); - - runCLI(`generate @nrwl/node:app ${appName} --linter=eslint`); - runCLI(`generate @nrwl/node:webpack5`); - runCLI(`build ${appName}`); - - checkFilesExist(`dist/apps/${appName}/main.js`); - const result = execSync(`node dist/apps/${appName}/main.js`, { - cwd: tmpProjPath(), - }).toString(); - expect(result).toContain('Hello World!'); - }, 300000); -}); diff --git a/e2e/react/src/react-webpack-5.test.ts b/e2e/react/src/react-webpack-5.test.ts deleted file mode 100644 index da79f63d9f..0000000000 --- a/e2e/react/src/react-webpack-5.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - checkFilesExist, - checkFilesDoNotExist, - isNotWindows, - killPorts, - newProject, - readFile, - runCLI, - runCypressTests, - updateFile, - uniq, -} from '@nrwl/e2e/utils'; - -describe('Webpack 5: React Apps', () => { - it('should successfully build and run E2E tests', async () => { - const appName = uniq('app'); - - newProject(); - runCLI(`generate @nrwl/react:app ${appName} --style css`); - runCLI(`generate @nrwl/web:webpack5`); - - // Make the entry file large to make sure it doesn't split - updateFile( - `apps/${appName}/src/styles.css`, - Array.from({ length: 2000 }) - .map((_, i) => `/* this is a comment */\n.class-${i} { color: red; }`) - .join('\n') - ); - - runCLI(`build ${appName} --prod --output-hashing none`); - - checkFilesExist( - `dist/apps/${appName}/index.html`, - `dist/apps/${appName}/runtime.esm.js`, - `dist/apps/${appName}/main.esm.js`, - `dist/apps/${appName}/styles.css` - ); - - // Should be minified - expect(readFile(`dist/apps/${appName}/styles.css`)).not.toContain( - 'this is a comment' - ); - - checkFilesDoNotExist(`dist/apps/${appName}/styles.js`); - - expect(readFile(`dist/apps/${appName}/index.html`)).toContain( - `` - ); - - if (isNotWindows() && runCypressTests()) { - const e2eResults = runCLI(`e2e ${appName}-e2e --headless --no-watch`); - expect(e2eResults).toContain('All specs passed!'); - expect(await killPorts()).toBeTruthy(); - } - }, 500000); -}); diff --git a/e2e/react/src/react.test.ts b/e2e/react/src/react.test.ts index a8d3bb9ebf..567ea3522d 100644 --- a/e2e/react/src/react.test.ts +++ b/e2e/react/src/react.test.ts @@ -55,20 +55,8 @@ describe('React Applications', () => { runCLI(`generate @nrwl/react:app ${appName} --no-interactive`); - // By default, vendor sourcemaps are off - runCLI(`build ${appName}`); + runCLI(`build ${appName} --sourceMap`); - // Turn vendor sourcemaps on - updateFile(`workspace.json`, (content) => { - const json = JSON.parse(content); - json.projects[appName].targets.build.options.sourceMap = { - scripts: true, - vendor: true, - }; - return JSON.stringify(json, null, 2); - }); - - runCLI(`build ${appName}`); checkFilesExist(`dist/apps/${appName}/vendor.js.map`); }, 250000); diff --git a/e2e/web/src/file-server.test.ts b/e2e/web/src/file-server.test.ts index 2d95e82129..eadbcdc14f 100644 --- a/e2e/web/src/file-server.test.ts +++ b/e2e/web/src/file-server.test.ts @@ -1,13 +1,13 @@ import { killPorts, newProject, + promisifiedTreeKill, readJson, runCLI, runCommandUntil, uniq, updateFile, workspaceConfigName, - promisifiedTreeKill, } from '@nrwl/e2e/utils'; import { serializeJson } from '@nrwl/workspace'; @@ -27,7 +27,7 @@ describe('file-server', () => { `serve ${appName} --port=${port}`, (output) => { return ( - output.indexOf('Built at') > -1 && + output.indexOf('webpack compiled') > -1 && output.indexOf(`localhost:${port}`) > -1 ); } diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/api-node/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/angular/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index d0edd66e99..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/angular/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `angular.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/api-react/generators/application.md b/nx-dev/nx-dev/public/documentation/latest/angular/api-react/generators/application.md index e1148d0f29..f22dd9afc0 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/api-react/generators/application.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/api-web/executors/build.md b/nx-dev/nx-dev/public/documentation/latest/angular/api-web/executors/build.md index 9f54416caf..5e3eb24599 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/api-web/executors/build.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/api-web/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/angular/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index a69d004756..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/angular/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `angular.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-apps.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-apps.md index 08203830c1..24328a2f50 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-apps.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-apps.md @@ -18,16 +18,16 @@ Print the names of all the apps affected by changing the index.ts file: nx affected:apps --files=libs/mylib/src/index.ts ``` -Print the names of all the apps affected by the changes between master and HEAD (e.g., PR): +Print the names of all the apps affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:apps --base=master --head=HEAD +nx affected:apps --base=main --head=HEAD ``` -Print the names of all the apps affected by the last commit on master: +Print the names of all the apps affected by the last commit on main: ```bash -nx affected:apps --base=master~1 --head=master +nx affected:apps --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-build.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-build.md index 46517d5864..036d42a872 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-build.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-build.md @@ -36,16 +36,16 @@ Run build for all the projects affected by changing the index.ts file: nx affected:build --files=libs/mylib/src/index.ts ``` -Run build for all the projects affected by the changes between master and HEAD (e.g., PR): +Run build for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:build --base=master --head=HEAD +nx affected:build --base=main --head=HEAD ``` -Run build for all the projects affected by the last commit on master: +Run build for all the projects affected by the last commit on main: ```bash -nx affected:build --base=master~1 --head=master +nx affected:build --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-dep-graph.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-dep-graph.md index 7195f80103..9d8816e401 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-dep-graph.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-dep-graph.md @@ -18,28 +18,28 @@ Open the dep graph of the workspace in the browser, and highlight the projects a nx affected:dep-graph --files=libs/mylib/src/index.ts ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD +nx affected:dep-graph --base=main --head=HEAD ``` -Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.json +nx affected:dep-graph --base=main --head=HEAD --file=output.json ``` -Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between master and HEAD (e.g., PR): +Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.html +nx affected:dep-graph --base=main --head=HEAD --file=output.html ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on master: +Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on main: ```bash -nx affected:dep-graph --base=master~1 --head=master +nx affected:dep-graph --base=main~1 --head=main ``` Open the dep graph of the workspace in the browser, highlight the projects affected, but exclude project-one and project-two: @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-e2e.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-e2e.md index 667c4d6405..add48a3593 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-e2e.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-e2e.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:e2e --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:e2e --base=master --head=HEAD +nx affected:e2e --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:e2e --base=master~1 --head=master +nx affected:e2e --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-libs.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-libs.md index e57c126261..62864f72bf 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-libs.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-libs.md @@ -18,16 +18,16 @@ Print the names of all the libs affected by changing the index.ts file: nx affected:libs --files=libs/mylib/src/index.ts ``` -Print the names of all the libs affected by the changes between master and HEAD (e.g., PR): +Print the names of all the libs affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:libs --base=master --head=HEAD +nx affected:libs --base=main --head=HEAD ``` -Print the names of all the libs affected by the last commit on master: +Print the names of all the libs affected by the last commit on main: ```bash -nx affected:libs --base=master~1 --head=master +nx affected:libs --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-lint.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-lint.md index 217d85ebc4..1420d81468 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-lint.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-lint.md @@ -36,16 +36,16 @@ Run lint for all the projects affected by changing the index.ts file: nx affected:lint --files=libs/mylib/src/index.ts ``` -Run lint for all the projects affected by the changes between master and HEAD (e.g., PR): +Run lint for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:lint --base=master --head=HEAD +nx affected:lint --base=main --head=HEAD ``` -Run lint for all the projects affected by the last commit on master: +Run lint for all the projects affected by the last commit on main: ```bash -nx affected:lint --base=master~1 --head=master +nx affected:lint --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-test.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-test.md index 62cb96e8c1..a02024d0a8 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-test.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected-test.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:test --base=master --head=HEAD +nx affected:test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:test --base=master~1 --head=master +nx affected:test --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected.md index 76040bd400..d74bc7e40b 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/affected.md @@ -42,16 +42,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected --target=test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected --target=test --base=master --head=HEAD +nx affected --target=test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected --target=test --base=master~1 --head=master +nx affected --target=test --base=main~1 --head=main ``` ## Options @@ -62,7 +62,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-check.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-check.md index a16831d3bf..25e4be0be0 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-check.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-check.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-write.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-write.md index acd812f649..d49e5cab48 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-write.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/format-write.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/cli/print-affected.md b/nx-dev/nx-dev/public/documentation/latest/angular/cli/print-affected.md index 170b607d5a..5627ad6627 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/cli/print-affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/cli/print-affected.md @@ -18,10 +18,10 @@ Print information about affected projects and the dependency graph: nx print-affected ``` -Print information about the projects affected by the changes between master and HEAD (e.g,. PR): +Print information about the projects affected by the changes between main and HEAD (e.g,. PR): ```bash -nx print-affected --base=master --head=HEAD +nx print-affected --base=main --head=HEAD ``` Prints information about the affected projects and a list of tasks to test them: @@ -50,7 +50,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/examples/react-and-angular.md b/nx-dev/nx-dev/public/documentation/latest/angular/examples/react-and-angular.md index d36198d8a0..8417332254 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/examples/react-and-angular.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/examples/react-and-angular.md @@ -405,7 +405,7 @@ If we run `yarn dep-graph`, we will see the following: Nx understands how our applications and libraries depend on each other. This is extremely important! To really improve the collaboration between teams and make sure that they can use each other's work, the following two things must be true: - If the Angular team makes a change to the Angular app itself. Only the Angular app has to be rebuilt and retested. Same is true for the React team. Any tool that requires us to rebuild and retest everything on every PR won't scale beyond a small repository. -- If any of the teams changes the ui library, both the Angular and the React applications should be rebuilt and retested before the PR gets merged into master. This is the only way to guarantee that the PR is safe to merge. +- If any of the teams changes the ui library, both the Angular and the React applications should be rebuilt and retested before the PR gets merged into main. This is the only way to guarantee that the PR is safe to merge. To see how Nx helps with this, let's commit the changes we have made so far. diff --git a/nx-dev/nx-dev/public/documentation/latest/angular/guides/configuration.md b/nx-dev/nx-dev/public/documentation/latest/angular/guides/configuration.md index 5b947236a7..7748577001 100644 --- a/nx-dev/nx-dev/public/documentation/latest/angular/guides/configuration.md +++ b/nx-dev/nx-dev/public/documentation/latest/angular/guides/configuration.md @@ -303,7 +303,7 @@ The `nx.json` file contains extra configuration options mostly related to the pr { "npmScope": "happyorg", "affected": { - "defaultBase": "master" + "defaultBase": "main" }, "tasksRunnerOptions": { "default": { @@ -355,7 +355,7 @@ Tells Nx what prefix to use when generating library imports. Tells Nx which branch and HEAD to use when calculating affected projects. -- `defaultBase` defines the default base branch, defaulted to `master`. +- `defaultBase` defines the default base branch, defaulted to `main`. ### Tasks Runner Options diff --git a/nx-dev/nx-dev/public/documentation/latest/map.json b/nx-dev/nx-dev/public/documentation/latest/map.json index 1c6fbf1f65..3d24390886 100644 --- a/nx-dev/nx-dev/public/documentation/latest/map.json +++ b/nx-dev/nx-dev/public/documentation/latest/map.json @@ -375,11 +375,6 @@ "id": "build", "file": "angular/api-web/executors/build" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "angular/api-web/generators/migrate-to-webpack-5" - }, { "name": "dev-server executor", "id": "dev-server", @@ -698,11 +693,6 @@ "id": "library", "file": "angular/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "angular/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -1658,11 +1648,6 @@ "id": "application", "file": "react/api-web/generators/application" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "react/api-web/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -1992,11 +1977,6 @@ "id": "library", "file": "react/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "react/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -2910,11 +2890,6 @@ "id": "application", "file": "node/api-web/generators/application" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "node/api-web/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", @@ -3227,11 +3202,6 @@ "id": "library", "file": "node/api-node/generators/library" }, - { - "name": "migrate to webpack 5 generator", - "id": "migrate-to-webpack-5", - "file": "node/api-node/generators/migrate-to-webpack-5" - }, { "name": "build executor", "id": "build", diff --git a/nx-dev/nx-dev/public/documentation/latest/node/api-node/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/node/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index 8f7cdd395c..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/node/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/node/api-react/generators/application.md b/nx-dev/nx-dev/public/documentation/latest/node/api-react/generators/application.md index 30f46c5a8a..b53065acd5 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/api-react/generators/application.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/nx-dev/nx-dev/public/documentation/latest/node/api-web/executors/build.md b/nx-dev/nx-dev/public/documentation/latest/node/api-web/executors/build.md index c1bd7d075b..a6af9ed465 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/api-web/executors/build.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/nx-dev/nx-dev/public/documentation/latest/node/api-web/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/node/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index 64ee7507c3..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/node/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-apps.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-apps.md index 08203830c1..24328a2f50 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-apps.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-apps.md @@ -18,16 +18,16 @@ Print the names of all the apps affected by changing the index.ts file: nx affected:apps --files=libs/mylib/src/index.ts ``` -Print the names of all the apps affected by the changes between master and HEAD (e.g., PR): +Print the names of all the apps affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:apps --base=master --head=HEAD +nx affected:apps --base=main --head=HEAD ``` -Print the names of all the apps affected by the last commit on master: +Print the names of all the apps affected by the last commit on main: ```bash -nx affected:apps --base=master~1 --head=master +nx affected:apps --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-build.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-build.md index 46517d5864..036d42a872 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-build.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-build.md @@ -36,16 +36,16 @@ Run build for all the projects affected by changing the index.ts file: nx affected:build --files=libs/mylib/src/index.ts ``` -Run build for all the projects affected by the changes between master and HEAD (e.g., PR): +Run build for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:build --base=master --head=HEAD +nx affected:build --base=main --head=HEAD ``` -Run build for all the projects affected by the last commit on master: +Run build for all the projects affected by the last commit on main: ```bash -nx affected:build --base=master~1 --head=master +nx affected:build --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-dep-graph.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-dep-graph.md index 7195f80103..9d8816e401 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-dep-graph.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-dep-graph.md @@ -18,28 +18,28 @@ Open the dep graph of the workspace in the browser, and highlight the projects a nx affected:dep-graph --files=libs/mylib/src/index.ts ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD +nx affected:dep-graph --base=main --head=HEAD ``` -Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.json +nx affected:dep-graph --base=main --head=HEAD --file=output.json ``` -Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between master and HEAD (e.g., PR): +Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.html +nx affected:dep-graph --base=main --head=HEAD --file=output.html ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on master: +Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on main: ```bash -nx affected:dep-graph --base=master~1 --head=master +nx affected:dep-graph --base=main~1 --head=main ``` Open the dep graph of the workspace in the browser, highlight the projects affected, but exclude project-one and project-two: @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-e2e.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-e2e.md index 667c4d6405..add48a3593 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-e2e.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-e2e.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:e2e --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:e2e --base=master --head=HEAD +nx affected:e2e --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:e2e --base=master~1 --head=master +nx affected:e2e --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-libs.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-libs.md index e57c126261..62864f72bf 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-libs.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-libs.md @@ -18,16 +18,16 @@ Print the names of all the libs affected by changing the index.ts file: nx affected:libs --files=libs/mylib/src/index.ts ``` -Print the names of all the libs affected by the changes between master and HEAD (e.g., PR): +Print the names of all the libs affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:libs --base=master --head=HEAD +nx affected:libs --base=main --head=HEAD ``` -Print the names of all the libs affected by the last commit on master: +Print the names of all the libs affected by the last commit on main: ```bash -nx affected:libs --base=master~1 --head=master +nx affected:libs --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-lint.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-lint.md index 217d85ebc4..1420d81468 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-lint.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-lint.md @@ -36,16 +36,16 @@ Run lint for all the projects affected by changing the index.ts file: nx affected:lint --files=libs/mylib/src/index.ts ``` -Run lint for all the projects affected by the changes between master and HEAD (e.g., PR): +Run lint for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:lint --base=master --head=HEAD +nx affected:lint --base=main --head=HEAD ``` -Run lint for all the projects affected by the last commit on master: +Run lint for all the projects affected by the last commit on main: ```bash -nx affected:lint --base=master~1 --head=master +nx affected:lint --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-test.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-test.md index 62cb96e8c1..a02024d0a8 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-test.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected-test.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:test --base=master --head=HEAD +nx affected:test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:test --base=master~1 --head=master +nx affected:test --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected.md index 76040bd400..d74bc7e40b 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/affected.md @@ -42,16 +42,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected --target=test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected --target=test --base=master --head=HEAD +nx affected --target=test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected --target=test --base=master~1 --head=master +nx affected --target=test --base=main~1 --head=main ``` ## Options @@ -62,7 +62,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/format-check.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/format-check.md index a16831d3bf..25e4be0be0 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/format-check.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/format-check.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/format-write.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/format-write.md index acd812f649..d49e5cab48 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/format-write.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/format-write.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/cli/print-affected.md b/nx-dev/nx-dev/public/documentation/latest/node/cli/print-affected.md index 170b607d5a..5627ad6627 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/cli/print-affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/cli/print-affected.md @@ -18,10 +18,10 @@ Print information about affected projects and the dependency graph: nx print-affected ``` -Print information about the projects affected by the changes between master and HEAD (e.g,. PR): +Print information about the projects affected by the changes between main and HEAD (e.g,. PR): ```bash -nx print-affected --base=master --head=HEAD +nx print-affected --base=main --head=HEAD ``` Prints information about the affected projects and a list of tasks to test them: @@ -50,7 +50,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/node/guides/configuration.md b/nx-dev/nx-dev/public/documentation/latest/node/guides/configuration.md index 7c725cca9f..69c99bfded 100644 --- a/nx-dev/nx-dev/public/documentation/latest/node/guides/configuration.md +++ b/nx-dev/nx-dev/public/documentation/latest/node/guides/configuration.md @@ -337,7 +337,7 @@ The `nx.json` file contains extra configuration options mostly related to the pr { "npmScope": "happyorg", "affected": { - "defaultBase": "master" + "defaultBase": "main" }, "tasksRunnerOptions": { "default": { @@ -379,7 +379,7 @@ Tells Nx what prefix to use when generating library imports. Tells Nx which branch and HEAD to use when calculating affected projects. -- `defaultBase` defines the default base branch, defaulted to `master`. +- `defaultBase` defines the default base branch, defaulted to `main`. ### Tasks Runner Options diff --git a/nx-dev/nx-dev/public/documentation/latest/react/api-node/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/react/api-node/generators/migrate-to-webpack-5.md deleted file mode 100644 index 8f7cdd395c..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/react/api-node/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/node:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/node:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/react/api-react/generators/application.md b/nx-dev/nx-dev/public/documentation/latest/react/api-react/generators/application.md index 30f46c5a8a..b53065acd5 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/api-react/generators/application.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/api-react/generators/application.md @@ -164,7 +164,7 @@ Default: `true` Type: `boolean` -Creates an application with stricter type checking and build optimization options. +Creates an application with strict mode and strict type checking ### style diff --git a/nx-dev/nx-dev/public/documentation/latest/react/api-web/executors/build.md b/nx-dev/nx-dev/public/documentation/latest/react/api-web/executors/build.md index c1bd7d075b..a6af9ed465 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/api-web/executors/build.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/api-web/executors/build.md @@ -210,9 +210,9 @@ Show circular dependency warnings on builds. Default: `true` -Type: `boolean` +Type: `boolean | string ` -Output sourcemaps. +Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment. ### statsJson diff --git a/nx-dev/nx-dev/public/documentation/latest/react/api-web/generators/migrate-to-webpack-5.md b/nx-dev/nx-dev/public/documentation/latest/react/api-web/generators/migrate-to-webpack-5.md deleted file mode 100644 index 64ee7507c3..0000000000 --- a/nx-dev/nx-dev/public/documentation/latest/react/api-web/generators/migrate-to-webpack-5.md +++ /dev/null @@ -1,27 +0,0 @@ -# @nrwl/web:migrate-to-webpack-5 - -Add webpack 5 compatible dependencies to the workspace - -## Usage - -```bash -nx generate migrate-to-webpack-5 ... -``` - -```bash -nx g webpack5 ... # same -``` - -By default, Nx will search for `migrate-to-webpack-5` in the default collection provisioned in `workspace.json`. - -You can specify the collection explicitly as follows: - -```bash -nx g @nrwl/web:migrate-to-webpack-5 ... -``` - -Show what will be generated without writing to disk: - -```bash -nx g migrate-to-webpack-5 ... --dry-run -``` diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-apps.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-apps.md index 08203830c1..24328a2f50 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-apps.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-apps.md @@ -18,16 +18,16 @@ Print the names of all the apps affected by changing the index.ts file: nx affected:apps --files=libs/mylib/src/index.ts ``` -Print the names of all the apps affected by the changes between master and HEAD (e.g., PR): +Print the names of all the apps affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:apps --base=master --head=HEAD +nx affected:apps --base=main --head=HEAD ``` -Print the names of all the apps affected by the last commit on master: +Print the names of all the apps affected by the last commit on main: ```bash -nx affected:apps --base=master~1 --head=master +nx affected:apps --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-build.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-build.md index 46517d5864..036d42a872 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-build.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-build.md @@ -36,16 +36,16 @@ Run build for all the projects affected by changing the index.ts file: nx affected:build --files=libs/mylib/src/index.ts ``` -Run build for all the projects affected by the changes between master and HEAD (e.g., PR): +Run build for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:build --base=master --head=HEAD +nx affected:build --base=main --head=HEAD ``` -Run build for all the projects affected by the last commit on master: +Run build for all the projects affected by the last commit on main: ```bash -nx affected:build --base=master~1 --head=master +nx affected:build --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-dep-graph.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-dep-graph.md index 7195f80103..9d8816e401 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-dep-graph.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-dep-graph.md @@ -18,28 +18,28 @@ Open the dep graph of the workspace in the browser, and highlight the projects a nx affected:dep-graph --files=libs/mylib/src/index.ts ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Open the dep graph of the workspace in the browser, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD +nx affected:dep-graph --base=main --head=HEAD ``` -Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between master and HEAD (e.g., PR): +Save the dep graph of the workspace in a json file, and highlight the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.json +nx affected:dep-graph --base=main --head=HEAD --file=output.json ``` -Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between master and HEAD (e.g., PR): +Generate a static website with dep graph data in an html file, highlighting the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:dep-graph --base=master --head=HEAD --file=output.html +nx affected:dep-graph --base=main --head=HEAD --file=output.html ``` -Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on master: +Open the dep graph of the workspace in the browser, and highlight the projects affected by the last commit on main: ```bash -nx affected:dep-graph --base=master~1 --head=master +nx affected:dep-graph --base=main~1 --head=main ``` Open the dep graph of the workspace in the browser, highlight the projects affected, but exclude project-one and project-two: @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-e2e.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-e2e.md index 667c4d6405..add48a3593 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-e2e.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-e2e.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:e2e --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:e2e --base=master --head=HEAD +nx affected:e2e --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:e2e --base=master~1 --head=master +nx affected:e2e --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-libs.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-libs.md index e57c126261..62864f72bf 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-libs.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-libs.md @@ -18,16 +18,16 @@ Print the names of all the libs affected by changing the index.ts file: nx affected:libs --files=libs/mylib/src/index.ts ``` -Print the names of all the libs affected by the changes between master and HEAD (e.g., PR): +Print the names of all the libs affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:libs --base=master --head=HEAD +nx affected:libs --base=main --head=HEAD ``` -Print the names of all the libs affected by the last commit on master: +Print the names of all the libs affected by the last commit on main: ```bash -nx affected:libs --base=master~1 --head=master +nx affected:libs --base=main~1 --head=main ``` ## Options @@ -38,7 +38,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-lint.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-lint.md index 217d85ebc4..1420d81468 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-lint.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-lint.md @@ -36,16 +36,16 @@ Run lint for all the projects affected by changing the index.ts file: nx affected:lint --files=libs/mylib/src/index.ts ``` -Run lint for all the projects affected by the changes between master and HEAD (e.g., PR): +Run lint for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:lint --base=master --head=HEAD +nx affected:lint --base=main --head=HEAD ``` -Run lint for all the projects affected by the last commit on master: +Run lint for all the projects affected by the last commit on main: ```bash -nx affected:lint --base=master~1 --head=master +nx affected:lint --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-test.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-test.md index 62cb96e8c1..a02024d0a8 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-test.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected-test.md @@ -36,16 +36,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected:test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected:test --base=master --head=HEAD +nx affected:test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected:test --base=master~1 --head=master +nx affected:test --base=main~1 --head=main ``` ## Options @@ -56,7 +56,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected.md index 76040bd400..d74bc7e40b 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/affected.md @@ -42,16 +42,16 @@ Run tests for all the projects affected by changing the index.ts file: nx affected --target=test --files=libs/mylib/src/index.ts ``` -Run tests for all the projects affected by the changes between master and HEAD (e.g., PR): +Run tests for all the projects affected by the changes between main and HEAD (e.g., PR): ```bash -nx affected --target=test --base=master --head=HEAD +nx affected --target=test --base=main --head=HEAD ``` -Run tests for all the projects affected by the last commit on master: +Run tests for all the projects affected by the last commit on main: ```bash -nx affected --target=test --base=master~1 --head=master +nx affected --target=test --base=main~1 --head=main ``` ## Options @@ -62,7 +62,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/format-check.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/format-check.md index a16831d3bf..25e4be0be0 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/format-check.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/format-check.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/format-write.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/format-write.md index acd812f649..d49e5cab48 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/format-write.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/format-write.md @@ -18,7 +18,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/cli/print-affected.md b/nx-dev/nx-dev/public/documentation/latest/react/cli/print-affected.md index 170b607d5a..5627ad6627 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/cli/print-affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/cli/print-affected.md @@ -18,10 +18,10 @@ Print information about affected projects and the dependency graph: nx print-affected ``` -Print information about the projects affected by the changes between master and HEAD (e.g,. PR): +Print information about the projects affected by the changes between main and HEAD (e.g,. PR): ```bash -nx print-affected --base=master --head=HEAD +nx print-affected --base=main --head=HEAD ``` Prints information about the affected projects and a list of tasks to test them: @@ -50,7 +50,7 @@ All projects ### base -Base of the current branch (usually master) +Base of the current branch (usually main) ### configuration diff --git a/nx-dev/nx-dev/public/documentation/latest/react/guides/configuration.md b/nx-dev/nx-dev/public/documentation/latest/react/guides/configuration.md index 5f2eb606d1..f25b92f414 100644 --- a/nx-dev/nx-dev/public/documentation/latest/react/guides/configuration.md +++ b/nx-dev/nx-dev/public/documentation/latest/react/guides/configuration.md @@ -325,7 +325,7 @@ The `nx.json` file contains extra configuration options mostly related to the pr { "npmScope": "happyorg", "affected": { - "defaultBase": "master" + "defaultBase": "main" }, "tasksRunnerOptions": { "default": { @@ -375,7 +375,7 @@ Tells Nx what prefix to use when generating library imports. Tells Nx which branch and HEAD to use when calculating affected projects. -- `defaultBase` defines the default base branch, defaulted to `master`. +- `defaultBase` defines the default base branch, defaulted to `main`. ### Tasks Runner Options diff --git a/nx-dev/nx-dev/public/documentation/latest/shared/affected.md b/nx-dev/nx-dev/public/documentation/latest/shared/affected.md index 20223151f1..fd080534dd 100644 --- a/nx-dev/nx-dev/public/documentation/latest/shared/affected.md +++ b/nx-dev/nx-dev/public/documentation/latest/shared/affected.md @@ -68,10 +68,10 @@ nx affected:dep-graph --files=libs/admin-feature-permissions/src/index.ts In practice, it's easier to use git to determine what files have changed. ```bash -nx affected:dep-graph --base=master --head=HEAD +nx affected:dep-graph --base=main --head=HEAD ``` -The `--base` defaults to `master` and `--head` defaults to `HEAD`, so when running it locally you can usually omit it: +The `--base` defaults to `main` and `--head` defaults to `HEAD`, so when running it locally you can usually omit it: ```bash nx affected:dep-graph @@ -98,11 +98,11 @@ nx affected --target=ANYTARGET # run ANYTARGET for all affected apps and libs ## CI -The SHAs you pass must be defined in the git repository. The `master` and `HEAD` SHAs are what you normally use while developing. Most likely you will want to provision other SHAs in your CI environment. +The SHAs you pass must be defined in the git repository. The `main` and `HEAD` SHAs are what you normally use while developing. Most likely you will want to provision other SHAs in your CI environment. ```bash -nx affected:build --base=origin/master --head=$PR_BRANCH_NAME # where PR_BRANCH_NAME is defined by your CI system -nx affected:build --base=origin/master~1 --head=origin/master # rerun what is affected by the last commit in master +nx affected:build --base= origin/main --head=$PR_BRANCH_NAME # where PR_BRANCH_NAME is defined by your CI system +nx affected:build --base= origin/main~1 --head= origin/main # rerun what is affected by the last commit in main ``` ## When Nx can't Understand Your Repository diff --git a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-azure.md b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-azure.md index 8e8611acd5..02e5ac2e01 100644 --- a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-azure.md +++ b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-azure.md @@ -63,9 +63,9 @@ jobs: vmImage: 'ubuntu-latest' steps: - template: .azure-pipelines/steps/install-node-modules.yml - - script: yarn nx affected --target=test --base=origin/master - - script: yarn nx affected --target=lint --base=origin/master - - script: yarn nx affected --target=build --base=origin/master --prod + - script: yarn nx affected --target=test --base=origin/main + - script: yarn nx affected --target=lint --base=origin/main + - script: yarn nx affected --target=build --base=origin/main --prod ``` the CI time will go down from 45 minutes to 8 minutes. @@ -86,9 +86,9 @@ jobs: IS_PR: $[ eq(variables['Build.Reason'], 'PullRequest') ] steps: - template: .azure-pipelines/steps/install-node-modules.yml - - script: yarn nx affected --target=test --base=origin/master --parallel - - script: yarn nx affected --target=lint --base=origin/master --parallel - - script: yarn nx affected --target=build --base=origin/master --prod --parallel + - script: yarn nx affected --target=test --base=origin/main --parallel + - script: yarn nx affected --target=lint --base=origin/main --parallel + - script: yarn nx affected --target=build --base=origin/main --prod --parallel ``` This helps but it still has a ceiling. At some point, this won't be enough. A single agent is simply insufficient. You need to distribute CI across a grid of machines. @@ -131,8 +131,8 @@ Where `calculate-commands.js` looks like this: ```javascript const execSync = require('child_process').execSync; -const isMaster = process.argv[2] === 'False'; -const baseSha = isMaster ? 'origin/master~1' : 'origin/master'; +const isMain = process.argv[2] === 'False'; +const baseSha = isMain ? 'origin/main~1' : 'origin/main'; // prints an object with keys {lint1: [...], lint2: [...], lint3: [...], test1: [...], .... build3: [...]} console.log( @@ -168,11 +168,11 @@ Let's step through it: The following defines the base sha Nx uses to execute affected commands. ```javascript -const isMaster = process.argv[2] === 'False'; -const baseSha = isMaster ? 'origin/master~1' : 'origin/master'; +const isMain = process.argv[2] === 'False'; +const baseSha = isMain ? 'origin/main~1' : 'origin/main'; ``` -If it is a PR, Nx sees what has changed compared to `origin/master`. If it's master, Nx sees what has changed compared to the previous commit (this can be made more robust by remembering the last successful master run, which can be done by labeling the commit). +If it is a PR, Nx sees what has changed compared to `origin/main`. If it's main, Nx sees what has changed compared to the previous commit (this can be made more robust by remembering the last successful main run, which can be done by labeling the commit). The following prints information about affected project that have the needed target. `print-affected` doesn't run any targets, just prints information about them. diff --git a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-jenkins.md b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-jenkins.md index 11d05346d7..f8b7c20d3e 100644 --- a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-jenkins.md +++ b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-ci-jenkins.md @@ -75,15 +75,15 @@ node { } stage("Test") { - sh 'yarn nx affected --target=test --base=origin/master' + sh 'yarn nx affected --target=test --base= origin/main' } stage("Lint") { - sh 'yarn nx affected --target=lint --base=origin/master' + sh 'yarn nx affected --target=lint --base= origin/main' } stage("Build") { - sh 'yarn nx affected --target=build --base=origin/master --prod' + sh 'yarn nx affected --target=build --base= origin/main --prod' } } } @@ -108,15 +108,15 @@ node { } stage("Test") { - sh 'yarn nx affected --target=test --base=origin/master --parallel' + sh 'yarn nx affected --target=test --base= origin/main --parallel' } stage("Lint") { - sh 'yarn nx affected --target=lint --base=origin/master --parallel' + sh 'yarn nx affected --target=lint --base= origin/main --parallel' } stage("Build") { - sh 'yarn nx affected --target=build --base=origin/master --prod --parallel' + sh 'yarn nx affected --target=build --base= origin/main --prod --parallel' } } } @@ -191,7 +191,7 @@ def distributed(String target, int bins) { } def splitJobs(String target, int bins) { - def String baseSha = env.CHANGE_ID ? 'origin/master' : 'origin/master~1' + def String baseSha = env.CHANGE_ID ? ' origin/main' : ' origin/main~1' def String raw raw = sh(script: "npx nx print-affected --base=${baseSha} --target=${target}", returnStdout: true) def data = readJSON(text: raw) @@ -220,12 +220,12 @@ splitting them into bins via `splitJobs`. Looking at `splitJobs`, the following defines the base sha Nx uses to execute affected commands. ```groovy - def String baseSha = env.CHANGE_ID ? 'origin/master' : 'origin/master~1' + def String baseSha = env.CHANGE_ID ? ' origin/main' : ' origin/main~1' ``` Jenkins will only have a CHANGE_ID if it is a PR. -If it is a PR, Nx sees what has changed compared to `origin/master`. If it's master, Nx sees what has changed compared to the previous commit (this can be made more robust by remembering the last successful master run, which can be done by labeling the commit). +If it is a PR, Nx sees what has changed compared to ` origin/main`. If it's main, Nx sees what has changed compared to the previous commit (this can be made more robust by remembering the last successful main run, which can be done by labeling the commit). The following prints information about affected project that have the needed target. `print-affected` doesn't run any targets, just prints information about them. diff --git a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-nx-enterprise.md b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-nx-enterprise.md index 3ab5a118fc..913d65f148 100644 --- a/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-nx-enterprise.md +++ b/nx-dev/nx-dev/public/documentation/latest/shared/monorepo-nx-enterprise.md @@ -192,7 +192,7 @@ We should utilize `affected:*` commands to build and test projects. Read more ab Monorepo-style development works best when used with trunk-based development. -When using trunk-based development, we have a single main branch (say `master`) where every team submits their code. And -they do it as soon as possible. So if someone works on a large feature, they split it into a few small changes that can be integrated into master in a week. In other words, when using trunk-based development, teams can create branches, but they are short-lived and focus on a specific user story. +When using trunk-based development, we have a single main branch (say `main`) where every team submits their code. And +they do it as soon as possible. So if someone works on a large feature, they split it into a few small changes that can be integrated into main in a week. In other words, when using trunk-based development, teams can create branches, but they are short-lived and focus on a specific user story. -One issue folks often raise in regards to trunk-based development is "things change under you while you are trying to create a release". This can definitely happen, especially when manual testing is involved. To mitigate we can create a release branch where we would cherry-pick commits from `master` to. With this, we can still frequently merge code into `master` and have our release isolated from changes made by other teams. +One issue folks often raise in regards to trunk-based development is "things change under you while you are trying to create a release". This can definitely happen, especially when manual testing is involved. To mitigate we can create a release branch where we would cherry-pick commits from `main` to. With this, we can still frequently merge code into `main` and have our release isolated from changes made by other teams. diff --git a/package.json b/package.json index 4e6ff5699c..14b52851b4 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@angular/service-worker": "^12.2.0", "@angular/upgrade": "^12.2.0", "@babel/helper-create-regexp-features-plugin": "^7.14.5", - "@cypress/webpack-preprocessor": "4.1.5", + "@cypress/webpack-preprocessor": "^5.9.1", "@nestjs/common": "^7.0.0", "@nestjs/core": "^7.0.0", "@nestjs/platform-express": "^7.0.0", @@ -93,6 +93,7 @@ "@tailwindcss/typography": "^0.4.1", "@testing-library/react": "11.2.6", "@testing-library/react-hooks": "7.0.1", + "@types/css-minimizer-webpack-plugin": "^3.0.2", "@types/cytoscape": "^3.14.12", "@types/eslint": "^7.2.2", "@types/express": "4.17.0", @@ -121,12 +122,12 @@ "chalk": "4.1.0", "chokidar": "^3.5.1", "circular-dependency-plugin": "5.2.0", - "clean-css": "4.2.1", "commitizen": "^4.0.3", "confusing-browser-globals": "^1.0.9", "conventional-changelog-cli": "^2.0.23", - "copy-webpack-plugin": "6.4.1", + "copy-webpack-plugin": "^9.0.1", "core-js": "^3.6.5", + "css-minimizer-webpack-plugin": "^3.1.1", "cypress": "^8.3.0", "cytoscape": "^3.18.2", "cytoscape-dagre": "^2.3.2", @@ -180,7 +181,7 @@ "memfs": "^3.0.1", "metro-resolver": "^0.66.2", "mime": "2.4.4", - "mini-css-extract-plugin": "0.8.0", + "mini-css-extract-plugin": "^2.1.0", "minimatch": "3.0.4", "next": "11.1.2", "next-sitemap": "^1.6.108", @@ -200,7 +201,7 @@ "protractor": "5.4.3", "raw-loader": "3.1.0", "react-redux": "7.2.3", - "react-refresh": "^0.9.0", + "react-refresh": "^0.10.0", "react-router-dom": "5.1.2", "regenerator-runtime": "0.13.7", "release-it": "^14.11.3", @@ -216,7 +217,7 @@ "sass-loader": "8.0.2", "semver": "7.3.4", "source-map": "0.7.3", - "source-map-loader": "0.2.4", + "source-map-loader": "^3.0.0", "source-map-support": "0.5.19", "strip-json-comments": "^3.1.1", "style-loader": "1.0.0", @@ -226,12 +227,12 @@ "tailwindcss": "^2.2.7", "tcp-port-used": "^1.0.2", "terser": "4.3.8", - "terser-webpack-plugin": "2.3.8", + "terser-webpack-plugin": "^5.1.1", "tippy.js": "^6.3.1", "tmp": "~0.2.1", "tree-kill": "1.2.2", "ts-jest": "27.0.5", - "ts-loader": "5.4.5", + "ts-loader": "^9.2.6", "ts-node": "9.1.1", "tsconfig-paths": "^3.9.0", "tsconfig-paths-webpack-plugin": "3.4.1", @@ -244,11 +245,11 @@ "unzipper": "^0.10.11", "url-loader": "^3.0.0", "verdaccio": "^5.0.4", - "webpack": "4.46.0", - "webpack-dev-server": "3.11.2", - "webpack-merge": "4.2.1", - "webpack-node-externals": "1.7.2", - "webpack-sources": "1.4.3", + "webpack-dev-server": "^4.3.1", + "webpack-sources": "^3.0.2", + "webpack": "^5.58.1", + "webpack-merge": "^5.8.0", + "webpack-node-externals": "^3.0.0", "webpack-subresource-integrity": "^1.5.2", "worker-plugin": "3.2.0", "yargs": "15.4.1", @@ -289,4 +290,3 @@ "**/xmlhttprequest-ssl": "~1.6.2" } } - diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 38228dff7d..48993ca6fe 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -39,11 +39,11 @@ "@nrwl/devkit": "*", "@nrwl/linter": "*", "@nrwl/workspace": "*", - "@cypress/webpack-preprocessor": "4.1.5", + "@cypress/webpack-preprocessor": "^5.9.1", "chalk": "4.1.0", - "ts-loader": "5.4.5", + "ts-loader": "^9.2.6", "tsconfig-paths-webpack-plugin": "3.4.1", - "webpack-node-externals": "1.7.2", + "webpack-node-externals": "^3.0.0", "fork-ts-checker-webpack-plugin": "6.2.10", "rxjs": "^6.5.4", "tslib": "^2.0.0", diff --git a/packages/cypress/src/plugins/preprocessor.ts b/packages/cypress/src/plugins/preprocessor.ts index 818faeb3d5..f3ad7978b0 100644 --- a/packages/cypress/src/plugins/preprocessor.ts +++ b/packages/cypress/src/plugins/preprocessor.ts @@ -3,6 +3,7 @@ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'; import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); import { stripIndents } from '@nrwl/devkit'; import { installedCypressVersion } from '@nrwl/cypress/src/utils/cypress-version'; +import nodeExternals = require('webpack-node-externals'); /** * @deprecated This function is no longer necessary and will be removed in Nx 14 @@ -32,9 +33,6 @@ export function preprocessTypescript( } export function getWebpackConfig(config: any) { - // TODO(jack): Remove in Nx 13 and go back to proper import. - const { nodeExternals } = require('../webpack/entry'); - const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx']; return { resolve: { diff --git a/packages/cypress/src/webpack/bundle4.ts b/packages/cypress/src/webpack/bundle4.ts deleted file mode 100644 index 0728e4db92..0000000000 --- a/packages/cypress/src/webpack/bundle4.ts +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = function (useShim = true) { - return { - nodeExternals: require('webpack-node-externals'), - }; -}; diff --git a/packages/cypress/src/webpack/bundle5.ts b/packages/cypress/src/webpack/bundle5.ts deleted file mode 100644 index 8095e54f49..0000000000 --- a/packages/cypress/src/webpack/bundle5.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { logger, stripIndents } from '@nrwl/devkit'; -import chalk = require('chalk'); - -import { requireShim } from './require-shim'; -import packageJson = require('../../package.json'); - -function validateVersion(path) { - if ( - packageJson.dependencies[path] === - requireShim(`${path}/package.json`).version - ) { - logger.warn(`Found an outdated version of ${chalk.bold(path)}\n`); - - logger.info(stripIndents` - If you want to use webpack 5, try installing compatible versions of the plugins. - See: https://nx.dev/guides/webpack-5 - `); - - throw new Error('Incompatible version'); - } -} - -module.exports = function (onFallback) { - try { - validateVersion('webpack-node-externals'); - } catch { - logger.info( - `NX Falling back to webpack 4 due to incompatible plugin versions` - ); - onFallback(); - return require('./bundle4')(); - } - - return { - nodeExternals: requireShim('webpack-node-externals'), - }; -}; diff --git a/packages/cypress/src/webpack/delete-in-nx-13.txt b/packages/cypress/src/webpack/delete-in-nx-13.txt deleted file mode 100644 index 7d73560485..0000000000 --- a/packages/cypress/src/webpack/delete-in-nx-13.txt +++ /dev/null @@ -1 +0,0 @@ -TODO(jack): Delete for Nx 13 diff --git a/packages/cypress/src/webpack/entry.ts b/packages/cypress/src/webpack/entry.ts deleted file mode 100644 index 4f899b364c..0000000000 --- a/packages/cypress/src/webpack/entry.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { logger } from '@nrwl/devkit'; -import { requireShim } from './require-shim'; - -const { version } = requireShim('webpack/package.json'); - -exports.default = undefined; - -const forceWebpack4 = process.env.NX_FORCE_WEBPACK_4; - -exports.isWebpack5 = !forceWebpack4 && /^5\./.test(version); - -let hasLogged = false; - -if (exports.isWebpack5) { - if (!hasLogged) { - logger.info( - `NX Using webpack 5. Reason: detected version 5 in node_modules/webpack/package.json` - ); - hasLogged = true; - } - Object.assign( - exports, - require('./bundle5')(() => { - exports.isWebpack5 = false; - }) - ); -} else { - if (!hasLogged) { - hasLogged = true; - } - Object.assign(exports, require('./bundle4')()); -} diff --git a/packages/cypress/src/webpack/require-shim.ts b/packages/cypress/src/webpack/require-shim.ts deleted file mode 100644 index a20e3b1f73..0000000000 --- a/packages/cypress/src/webpack/require-shim.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { appRootPath } from '@nrwl/tao/src/utils/app-root'; -import { join } from 'path'; - -export function requireShim(path: string) { - try { - return require(join(appRootPath, 'node_modules', path)); - } catch { - return require(path); - } -} diff --git a/packages/next/migrations.json b/packages/next/migrations.json index bbc8193f52..2818a11c53 100644 --- a/packages/next/migrations.json +++ b/packages/next/migrations.json @@ -60,6 +60,12 @@ "version": "12.10.0-beta.1", "description": "Updates .eslintrc.json file to use the correct pages directory for '@next/next/no-html-link-for-pages'.", "factory": "./src/migrations/update-12-10-0/fix-page-dir-for-eslint" + }, + "update-to-webpack-5": { + "cli": "nx", + "version": "13.0.0-beta.1", + "description": "Set `webpack5: true` for all next.js projects.", + "factory": "./src/migrations/update-13-0-0/update-to-webpack-5" } }, "packageJsonUpdates": { diff --git a/packages/next/package.json b/packages/next/package.json index 74acabff85..a9f0cecd33 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -47,6 +47,7 @@ "fs-extra": "^9.1.0", "url-loader": "^3.0.0", "tsconfig-paths": "^3.9.0", - "ts-node": "~9.1.1" + "ts-node": "~9.1.1", + "webpack-merge": "^5.8.0" } } diff --git a/packages/next/plugins/with-stylus.ts b/packages/next/plugins/with-stylus.ts new file mode 100644 index 0000000000..afa134a81a --- /dev/null +++ b/packages/next/plugins/with-stylus.ts @@ -0,0 +1,100 @@ +// Adapted from https://raw.githubusercontent.com/elado/next-with-less/main/src/index.js +import { merge } from 'webpack-merge'; + +const addStylusToRegExp = (rx) => + new RegExp(rx.source.replace('|sass', '|sass|styl'), rx.flags); + +function patchNextCSSWithStylus( + nextCSSModule = require('next/dist/build/webpack/config/blocks/css') as any +) { + nextCSSModule.regexLikeCss = addStylusToRegExp(nextCSSModule.regexLikeCss); +} + +patchNextCSSWithStylus(); + +/* + * @deprecated Use CSS or SASS instead. + */ +function withStylus({ stylusLoaderOptions = {}, ...nextConfig }: any) { + return Object.assign({}, nextConfig, { + webpack(config, opts) { + // there are 2 relevant sass rules in next.js - css modules and global css + let sassModuleRule; + // global sass rule (does not exist in server builds) + let sassGlobalRule; + + const cssRule = config.module.rules.find( + (rule) => rule.oneOf?.[0]?.options?.__next_css_remove + ); + + const addStylusRuleToTest = (test) => { + if (Array.isArray(test)) { + return test.map((rx) => addStylusToRegExp(rx)); + } else { + return addStylusToRegExp(test); + } + }; + + cssRule.oneOf.forEach((rule) => { + if (rule.options?.__next_css_remove) return; + + if (rule.use?.loader === 'error-loader') { + rule.test = addStylusRuleToTest(rule.test); + } else if (rule.use?.loader?.includes('file-loader')) { + rule.issuer = addStylusRuleToTest(rule.issuer); + } else if (rule.use?.includes?.('ignore-loader')) { + rule.test = addStylusRuleToTest(rule.test); + } else if (rule.test?.source === '\\.module\\.(scss|sass)$') { + sassModuleRule = rule; + } else if (rule.test?.source === '(? { + rule.test = new RegExp(rule.test.source.replace('(scss|sass)', 'styl')); + // replace sass-loader (last entry) with stylus-loader + rule.use.splice(-1, 1, stylusLoader); + }; + + configureStylusRule(stylusModuleRule); + cssRule.oneOf.splice( + cssRule.oneOf.indexOf(sassModuleRule) + 1, + 0, + stylusModuleRule + ); + + if (sassGlobalRule) { + let stylusGlobalRule = merge({}, sassGlobalRule); + configureStylusRule(stylusGlobalRule); + cssRule.oneOf.splice( + cssRule.oneOf.indexOf(sassGlobalRule) + 1, + 0, + stylusGlobalRule + ); + } + + if (typeof nextConfig.webpack === 'function') { + return nextConfig.webpack(config, opts); + } + + return config; + }, + }); +} + +module.exports = withStylus; +module.exports.patchNext = patchNextCSSWithStylus; diff --git a/packages/next/src/executors/server/lib/default-server.ts b/packages/next/src/executors/server/lib/default-server.ts index 22939b1ff7..a788302428 100644 --- a/packages/next/src/executors/server/lib/default-server.ts +++ b/packages/next/src/executors/server/lib/default-server.ts @@ -26,7 +26,8 @@ export async function defaultServer( // Set up the proxy. if (proxyConfig) { - const proxyMiddleware = require('http-proxy-middleware'); + const proxyMiddleware = + require('http-proxy-middleware').createProxyMiddleware; Object.keys(proxyConfig).forEach((context) => { server.use(proxyMiddleware(context, proxyConfig[context])); }); diff --git a/packages/next/src/generators/application/files/next.config.js__tmpl__ b/packages/next/src/generators/application/files/next.config.js__tmpl__ index 34852df51f..21cd5045a0 100644 --- a/packages/next/src/generators/application/files/next.config.js__tmpl__ +++ b/packages/next/src/generators/application/files/next.config.js__tmpl__ @@ -2,7 +2,9 @@ const withNx = require('@nrwl/next/plugins/with-nx'); <% if (style === 'less') { %> -const withLess = require('@zeit/next-less'); +// This plugin is needed until this PR is merged. +// https://github.com/vercel/next.js/pull/23185 +const withLess = require('next-with-less'); /** * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions} @@ -16,13 +18,11 @@ const nextConfig = { // Set this to true if you use CSS modules. // See: https://github.com/css-modules/css-modules cssModules: false, - // @zeit/next-less does not support webpack 5 - webpack5: false, }; module.exports = withLess(withNx(nextConfig)); <% } else if (style === 'styl') { %> -const withStylus = require('@zeit/next-stylus'); +const withStylus = require('@nrwl/next/plugins/with-stylus'); /** * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions} @@ -36,8 +36,6 @@ const nextConfig = { // Set this to true if you use CSS modules. // See: https://github.com/css-modules/css-modules cssModules: false, - // @zeit/next-stylus does not support webpack 5 - webpack5: false, }; module.exports = withStylus(withNx(nextConfig)); diff --git a/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.spec.ts b/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.spec.ts new file mode 100644 index 0000000000..427095e785 --- /dev/null +++ b/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.spec.ts @@ -0,0 +1,97 @@ +import { Tree } from '@nrwl/devkit'; +import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; + +import { applicationGenerator } from '../../generators/application/application'; +import { update } from './update-to-webpack-5'; + +describe('Migration: enable webpack 5', () => { + let tree: Tree; + + beforeEach(async () => { + tree = createTreeWithEmptyWorkspace(); + }); + + it('should set webpack5 to true', async () => { + await applicationGenerator(tree, { + style: 'none', + name: 'demo', + skipFormat: false, + }); + + // Config that isn't configured properly + tree.write( + 'apps/demo/next.config.js', + `const withNx = require('@nrwl/next/plugins/with-nx'); +const nextConfig = { + webpack5: false, +}; + +module.exports = withNx(nextConfig); +` + ); + + await update(tree); + + const result = tree.read('apps/demo/next.config.js').toString(); + + expect(result).toMatch(/webpack5: true/); + }); + + it('should fix stylus support', async () => { + await applicationGenerator(tree, { + style: 'styl', + name: 'demo', + skipFormat: false, + }); + + // Config that isn't configured properly + tree.write( + 'apps/demo/next.config.js', + `const withNx = require('@nrwl/next/plugins/with-nx'); +const withStylus = require('@zeit/next-stylus'); + +const nextConfig = { + webpack5: false, +}; + +module.exports = withNx(withStylus(nextConfig)); +` + ); + + await update(tree); + + const result = tree.read('apps/demo/next.config.js').toString(); + + expect(result).toMatch(/@nrwl\/next\/plugins\/with-stylus/); + expect(result).not.toMatch(/@zeit\/next-stylus/); + }); + + it('should fix less support', async () => { + await applicationGenerator(tree, { + style: 'less', + name: 'demo', + skipFormat: false, + }); + + // Config that isn't configured properly + tree.write( + 'apps/demo/next.config.js', + `const withNx = require('@nrwl/next/plugins/with-nx'); +const withLess = require('@zeit/next-less'); + +const nextConfig = { + webpack5: false, +}; + +module.exports = withNx(withLess(nextConfig)); +` + ); + + await update(tree); + + const result = tree.read('apps/demo/next.config.js').toString(); + + expect(result).toMatch(/next-with-less/); + expect(result).not.toMatch(/@zeit\/next-less/); + }); +}); diff --git a/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.ts b/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.ts new file mode 100644 index 0000000000..1f1ab230f0 --- /dev/null +++ b/packages/next/src/migrations/update-13-0-0/update-to-webpack-5.ts @@ -0,0 +1,51 @@ +import { + addDependenciesToPackageJson, + formatFiles, + GeneratorCallback, + getProjects, + joinPathFragments, + Tree, +} from '@nrwl/devkit'; + +export async function update(host: Tree) { + const projects = getProjects(host); + let task: undefined | GeneratorCallback = undefined; + + projects.forEach((project) => { + const configPath = joinPathFragments(project.root, 'next.config.js'); + + if (!host.exists(configPath)) return; + + const content = host.read(configPath).toString(); + let updated = content.replace(/webpack5: false/, 'webpack5: true'); + + if (content.match(/@zeit\/next-less/)) { + updated = updated.replace('@zeit/next-less', 'next-with-less'); + task = addDependenciesToPackageJson( + host, + { 'next-with-less': '1.0.1' }, + {} + ); + } + + if (content.match(/@zeit\/next-stylus/)) { + updated = updated.replace( + '@zeit/next-stylus', + '@nrwl/next/plugins/with-stylus' + ); + task = addDependenciesToPackageJson( + host, + { 'stylus-loader': '6.2.0' }, + {} + ); + } + + host.write(configPath, updated); + }); + + await formatFiles(host); + + return task; +} + +export default update; diff --git a/packages/next/src/utils/config.spec.ts b/packages/next/src/utils/config.spec.ts index dd2fdfa696..125ad8cc3e 100644 --- a/packages/next/src/utils/config.spec.ts +++ b/packages/next/src/utils/config.spec.ts @@ -76,7 +76,7 @@ describe('Next.js webpack config builder', () => { ); const svgrRule = config.module.rules.find( - (rule) => rule.test.toString() === String(/\.svg$/) + (rule) => rule !== '...' && rule.test.toString() === String(/\.svg$/) ); expect(svgrRule).toBeTruthy(); }); @@ -96,7 +96,7 @@ describe('Next.js webpack config builder', () => { ); const svgrRule = config.module.rules.find( - (rule) => rule.test.toString() === String(/\.svg$/) + (rule) => rule !== '...' && rule.test.toString() === String(/\.svg$/) ); expect(svgrRule).toBeFalsy(); }); @@ -139,7 +139,6 @@ describe('Next.js webpack config builder', () => { [] ); - console.log('config', config); expect(config).toMatchObject({ myCustomValue: 'test', }); diff --git a/packages/next/src/utils/styles.ts b/packages/next/src/utils/styles.ts index 468ef700cf..a6e718b711 100644 --- a/packages/next/src/utils/styles.ts +++ b/packages/next/src/utils/styles.ts @@ -9,9 +9,9 @@ import { CSS_IN_JS_DEPENDENCIES } from '@nrwl/react'; import { babelPluginStyledComponentsVersion, emotionServerVersion, + nextWithLess, sassVersion, - zeitNextLess, - zeitNextStylus, + stylusLoader, } from './versions'; export const NEXT_SPECIFIC_STYLE_DEPENDENCIES = { @@ -39,13 +39,13 @@ export const NEXT_SPECIFIC_STYLE_DEPENDENCIES = { }, less: { dependencies: { - '@zeit/next-less': zeitNextLess, + 'next-with-less': nextWithLess, }, devDependencies: {}, }, styl: { dependencies: { - '@zeit/next-stylus': zeitNextStylus, + 'stylus-loader': stylusLoader, }, devDependencies: {}, }, diff --git a/packages/next/src/utils/versions.ts b/packages/next/src/utils/versions.ts index 22c5d76c17..b37aa98d12 100644 --- a/packages/next/src/utils/versions.ts +++ b/packages/next/src/utils/versions.ts @@ -3,7 +3,7 @@ export const nxVersion = '*'; export const nextVersion = '11.1.2'; export const eslintConfigNextVersion = '11.1.2'; export const sassVersion = '1.42.1'; -export const zeitNextLess = '1.0.1'; -export const zeitNextStylus = '1.0.1'; +export const nextWithLess = '1.0.1'; +export const stylusLoader = '6.2.0'; export const emotionServerVersion = '11.0.0'; export const babelPluginStyledComponentsVersion = '1.10.7'; diff --git a/packages/node/generators.json b/packages/node/generators.json index 3e18416ca3..734839344b 100644 --- a/packages/node/generators.json +++ b/packages/node/generators.json @@ -23,12 +23,6 @@ "aliases": ["lib"], "x-type": "library", "description": "Create a library" - }, - "migrate-to-webpack-5": { - "factory": "./src/generators/migrate-to-webpack-5/migrate-to-webpack-5#nodeMigrateToWebpack5Generator", - "schema": "./src/generators/migrate-to-webpack-5/schema.json", - "aliases": ["webpack5"], - "description": "Add webpack 5 compatible dependencies to the workspace" } }, "schematics": { @@ -52,12 +46,6 @@ "aliases": ["lib"], "x-type": "library", "description": "Create a library" - }, - "migrate-to-webpack-5": { - "factory": "./src/generators/migrate-to-webpack-5/migrate-to-webpack-5#nodeMigrateToWebpack5Schematic", - "schema": "./src/generators/migrate-to-webpack-5/schema.json", - "aliases": ["webpack5"], - "description": "Add webpack 5 compatible dependencies to the workspace" } } } diff --git a/packages/node/migrations.json b/packages/node/migrations.json index ac03218981..a72f6080f1 100644 --- a/packages/node/migrations.json +++ b/packages/node/migrations.json @@ -9,6 +9,12 @@ "version": "10.1.0-beta.1", "description": "Removes rootDir from node libs' tsconfig", "factory": "./src/migrations/update-10-1-0/remove-root-dir" + }, + "remove-webpack-5-packages": { + "cli": "nx", + "version": "13.0.0-beta.1", + "description": "Remove packages installed by Nx 12's `@nrwl/node:webpack5` generator.", + "factory": "./src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0" } } } diff --git a/packages/node/package.json b/packages/node/package.json index 10f601551f..3e17caec7b 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -36,7 +36,7 @@ "@nrwl/linter": "*", "chalk": "4.1.0", "circular-dependency-plugin": "5.2.0", - "copy-webpack-plugin": "6.4.1", + "copy-webpack-plugin": "^9.0.1", "fork-ts-checker-webpack-plugin": "6.2.10", "fs-extra": "^9.1.0", "glob": "7.1.4", @@ -44,12 +44,12 @@ "rxjs": "^6.5.4", "source-map-support": "0.5.19", "tree-kill": "1.2.2", - "ts-loader": "5.4.5", + "ts-loader": "^9.2.6", "tsconfig-paths-webpack-plugin": "3.4.1", "tslib": "^2.0.0", - "webpack": "4.46.0", - "webpack-merge": "4.2.1", - "webpack-node-externals": "1.7.2", + "webpack": "^5.58.1", + "webpack-merge": "^5.8.0", + "webpack-node-externals": "^3.0.0", "rxjs-for-await": "0.0.2" } } diff --git a/packages/node/src/executors/build/build.impl.spec.ts b/packages/node/src/executors/build/build.impl.spec.ts index 4cb9b9b26e..22a3a56743 100644 --- a/packages/node/src/executors/build/build.impl.spec.ts +++ b/packages/node/src/executors/build/build.impl.spec.ts @@ -59,8 +59,7 @@ describe('Node Build Executor', () => { libraryTarget: 'commonjs', path: '/root/dist/apps/wibble', }, - }), - expect.anything() + }) ); }); @@ -84,8 +83,7 @@ describe('Node Build Executor', () => { path: '/root/dist/apps/wibble', }, prop: 'my-val', - }), - expect.anything() + }) ); }); @@ -118,8 +116,7 @@ describe('Node Build Executor', () => { }, prop1: 'my-val-1-my-val-2', prop2: 'my-val-2', - }), - expect.anything() + }) ); }); }); diff --git a/packages/node/src/executors/build/build.impl.ts b/packages/node/src/executors/build/build.impl.ts index 3f75aec12b..4b63b38ae8 100644 --- a/packages/node/src/executors/build/build.impl.ts +++ b/packages/node/src/executors/build/build.impl.ts @@ -1,3 +1,4 @@ +import * as webpack from 'webpack'; import 'dotenv/config'; import { ExecutorContext } from '@nrwl/devkit'; @@ -28,7 +29,6 @@ export async function* buildExecutor( rawOptions: BuildNodeBuilderOptions, context: ExecutorContext ) { - const { webpack } = require('../../webpack/entry'); const { sourceRoot, root } = context.workspace.projects[context.projectName]; if (!sourceRoot) { @@ -84,7 +84,7 @@ export async function* buildExecutor( }, getNodeWebpackConfig(options)); return yield* eachValueFrom( - runWebpack(config, webpack).pipe( + runWebpack(config).pipe( tap((stats) => { console.info(stats.toString(config.stats)); }), diff --git a/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts b/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts deleted file mode 100644 index a17d540262..0000000000 --- a/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { readJson, Tree, updateJson } from '@nrwl/devkit'; -import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; -import { nodeMigrateToWebpack5Generator } from './migrate-to-webpack-5'; - -describe('nodeMigrateToWebpack5Generator', () => { - let tree: Tree; - - beforeEach(() => { - tree = createTreeWithEmptyWorkspace(); - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@nrwl/cli': '100.0.0', - '@nrwl/jest': '100.0.0', - '@nrwl/node': '100.0.0', - '@nrwl/workspace': '100.0.0', - }; - return json; - }); - }); - - it('should add packages needed by Node', async () => { - await nodeMigrateToWebpack5Generator(tree, {}); - - const json = readJson(tree, '/package.json'); - - expect(json.devDependencies['webpack']).toMatch(/\^5/); - }); - - it('should add packages needed by Web if used', async () => { - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@nrwl/cli': '100.0.0', - '@nrwl/jest': '100.0.0', - '@nrwl/node': '100.0.0', - '@nrwl/react': '100.0.0', - '@nrwl/web': '100.0.0', - '@nrwl/workspace': '100.0.0', - }; - return json; - }); - - await nodeMigrateToWebpack5Generator(tree, {}); - - const json = readJson(tree, '/package.json'); - - expect( - json.devDependencies['@pmmmwh/react-refresh-webpack-plugin'] - ).toMatch(/^0\.5/); - }); -}); diff --git a/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts b/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts deleted file mode 100644 index 92c04ed735..0000000000 --- a/packages/node/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { - addDependenciesToPackageJson, - convertNxGenerator, - GeneratorCallback, - logger, - readJson, - removeDependenciesFromPackageJson, - Tree, -} from '@nrwl/devkit'; -import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; - -const basePackages = { - 'copy-webpack-plugin': '^9.0.1', - webpack: '^5.47.0', - 'webpack-merge': '^5.8.0', - 'webpack-node-externals': '^3.0.0', -}; - -const webPackages = { - 'mini-css-extract-plugin': '^2.1.0', - 'source-map-loader': '^3.0.0', - 'terser-webpack-plugin': '^5.1.1', - 'webpack-dev-server': '4.0.0-rc.0', - 'webpack-sources': '^3.0.2', - 'react-refresh': '^0.10.0', - '@pmmmwh/react-refresh-webpack-plugin': '0.5.0-rc.2', -}; - -export async function nodeMigrateToWebpack5Generator(tree: Tree, schema: {}) { - let packages = basePackages; - const tasks: GeneratorCallback[] = []; - - const packageJson = readJson(tree, 'package.json'); - const deps = [ - ...Object.keys(packageJson.dependencies), // just in case someone installed it here - ...Object.keys(packageJson.devDependencies), - ]; - - if (deps.includes('@nrwl/web')) { - packages = { - ...packages, - ...webPackages, - }; - } - - logger.info(`NX Adding webpack 5 to workspace.`); - - // Removing the packages ensures that the versions will be updated when adding them after - tasks.push( - removeDependenciesFromPackageJson(tree, [], Object.keys(packages)) - ); - - tasks.push(addDependenciesToPackageJson(tree, {}, packages)); - - return runTasksInSerial(...tasks); -} - -export default nodeMigrateToWebpack5Generator; -export const nodeMigrateToWebpack5Schematic = convertNxGenerator( - nodeMigrateToWebpack5Generator -); diff --git a/packages/node/src/generators/migrate-to-webpack-5/schema.json b/packages/node/src/generators/migrate-to-webpack-5/schema.json deleted file mode 100644 index 0cedcc5578..0000000000 --- a/packages/node/src/generators/migrate-to-webpack-5/schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "http://json-schema.org/schema", - "$id": "NxNxMigrateToWebpack5", - "cli": "nx", - "title": "Migrate to webpack 5", - "type": "object", - "properties": {}, - "required": [] -} diff --git a/packages/node/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts b/packages/node/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts new file mode 100644 index 0000000000..c41f18d79e --- /dev/null +++ b/packages/node/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts @@ -0,0 +1,34 @@ +import { + formatFiles, + GeneratorCallback, + readJson, + removeDependenciesFromPackageJson, + Tree, +} from '@nrwl/devkit'; + +const packages = [ + 'webpack', + 'copy-webpack-plugin', + 'webpack-merge', + 'webpack-node-externals', + 'mini-css-extract-plugin', + 'source-map-loader', + 'terser-webpack-plugin', + 'webpack-dev-server', + 'webpack-sources', + 'react-refresh', + '@pmmmwh/react-refresh-webpack-plugin', +]; + +export default async function update(tree: Tree) { + const packageJson = readJson(tree, 'package.json'); + let task: undefined | GeneratorCallback = undefined; + + // Undo the install by `nx g @nrwl/web:webpack5` in Nx 12. + if (packageJson.devDependencies['webpack']?.startsWith('^5')) { + task = removeDependenciesFromPackageJson(tree, [], packages); + await formatFiles(tree); + } + + return task; +} diff --git a/packages/node/src/utils/config.ts b/packages/node/src/utils/config.ts index 14233376ed..20e02c9f07 100644 --- a/packages/node/src/utils/config.ts +++ b/packages/node/src/utils/config.ts @@ -1,3 +1,5 @@ +import type { Configuration, WebpackPluginInstance } from 'webpack'; +import * as webpack from 'webpack'; import * as ts from 'typescript'; import { LicenseWebpackPlugin } from 'license-webpack-plugin'; import TsConfigPathsPlugin from 'tsconfig-paths-webpack-plugin'; @@ -5,22 +7,16 @@ import TsConfigPathsPlugin from 'tsconfig-paths-webpack-plugin'; import { readTsConfig } from '@nrwl/workspace/src/utilities/typescript'; import { BuildBuilderOptions } from './types'; import { loadTsPlugins } from './load-ts-plugins'; +import CopyWebpackPlugin = require('copy-webpack-plugin'); import CircularDependencyPlugin = require('circular-dependency-plugin'); import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); export const OUT_FILENAME = 'main.js'; export const OUT_FILENAME_TEMPLATE = '[name].js'; -// TODO(jack): In Nx 13 go back to proper types. -type Configuration = any; -type WebpackPluginInstance = any; // This was webpack.Plugin in webpack 4 - export function getBaseWebpackPartial( options: BuildBuilderOptions ): Configuration { - // TODO(jack): Remove in Nx 13 - const { CopyWebpackPlugin, webpack } = require('../webpack/entry'); - const { options: compilerOptions } = readTsConfig(options.tsConfig); const supportsEs2015 = compilerOptions.target !== ts.ScriptTarget.ES3 && @@ -194,10 +190,7 @@ function getAliases(options: BuildBuilderOptions): { [key: string]: string } { ); } -// TODO(jack): Update the typing with new version of webpack -- was returning Stats.ToStringOptions in webpack 4 -// The StatsOptions type needs to be exported from webpack -// PR: https://github.com/webpack/webpack/pull/12875 -function getStatsConfig(options: BuildBuilderOptions): any { +function getStatsConfig(options: BuildBuilderOptions) { return { hash: true, timings: false, diff --git a/packages/node/src/utils/node.config.spec.ts b/packages/node/src/utils/node.config.spec.ts index 39f3364996..0a378d106b 100644 --- a/packages/node/src/utils/node.config.spec.ts +++ b/packages/node/src/utils/node.config.spec.ts @@ -79,9 +79,9 @@ describe('getNodePartial', () => { externalDependencies: ['module1'], }); const callback = jest.fn(); - result.externals[0](null, 'module1', callback); + result.externals[0]({ request: 'module1' }, callback); expect(callback).toHaveBeenCalledWith(null, 'commonjs module1'); - result.externals[0](null, '@nestjs/core', callback); + result.externals[0]({ request: '@nestjs/core' }, callback); expect(callback).toHaveBeenCalledWith(); }); diff --git a/packages/node/src/utils/node.config.ts b/packages/node/src/utils/node.config.ts index e113846fc3..5455d99ce3 100644 --- a/packages/node/src/utils/node.config.ts +++ b/packages/node/src/utils/node.config.ts @@ -1,11 +1,12 @@ import { appRootPath } from '@nrwl/tao/src/utils/app-root'; import { Configuration } from 'webpack'; +import { merge } from 'webpack-merge'; import { getBaseWebpackPartial } from './config'; import { BuildNodeBuilderOptions } from './types'; +import nodeExternals = require('webpack-node-externals'); function getNodePartial(options: BuildNodeBuilderOptions) { - const { nodeExternals } = require('../webpack/entry'); const webpackConfig: Configuration = { output: { libraryTarget: 'commonjs', @@ -26,10 +27,10 @@ function getNodePartial(options: BuildNodeBuilderOptions) { webpackConfig.externals = [nodeExternals({ modulesDir })]; } else if (Array.isArray(options.externalDependencies)) { webpackConfig.externals = [ - function (context, request, callback: Function) { - if (options.externalDependencies.includes(request)) { + function (context, callback: Function) { + if (options.externalDependencies.includes(context.request)) { // not bundled - return callback(null, `commonjs ${request}`); + return callback(null, `commonjs ${context.request}`); } // bundled callback(); @@ -40,9 +41,5 @@ function getNodePartial(options: BuildNodeBuilderOptions) { } export function getNodeWebpackConfig(options: BuildNodeBuilderOptions) { - const { webpackMerge } = require('../webpack/entry'); - return webpackMerge([ - getBaseWebpackPartial(options), - getNodePartial(options), - ]); + return merge([getBaseWebpackPartial(options), getNodePartial(options)]); } diff --git a/packages/node/src/webpack/bundle4.ts b/packages/node/src/webpack/bundle4.ts deleted file mode 100644 index 4792fb99f7..0000000000 --- a/packages/node/src/webpack/bundle4.ts +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function (useShim = true) { - const webpack = require('webpack'); - webpack.webpack = webpack; - webpack.WebpackError = require('webpack/lib/WebpackError'); - - return { - webpack, - webpackMerge: require('webpack-merge'), - CopyWebpackPlugin: require('copy-webpack-plugin'), - nodeExternals: require('webpack-node-externals'), - }; -}; diff --git a/packages/node/src/webpack/bundle5.ts b/packages/node/src/webpack/bundle5.ts deleted file mode 100644 index fb7bcaf26e..0000000000 --- a/packages/node/src/webpack/bundle5.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { logger, stripIndents } from '@nrwl/devkit'; -import chalk = require('chalk'); - -import { requireShim } from './require-shim'; -import packageJson = require('../../package.json'); - -function validateVersion(path) { - if ( - packageJson.dependencies[path] === - requireShim(`${path}/package.json`).version - ) { - logger.warn(`Found an outdated version of ${chalk.bold(path)}\n`); - - logger.info(stripIndents` - If you want to use webpack 5, try installing compatible versions of the plugins. - See: https://nx.dev/guides/webpack-5 - `); - - throw new Error('Incompatible version'); - } -} - -module.exports = function (onFallback) { - try { - validateVersion('webpack-merge'); - validateVersion('copy-webpack-plugin'); - validateVersion('webpack-node-externals'); - } catch { - logger.info( - `NX Falling back to webpack 4 due to incompatible plugin versions` - ); - onFallback(); - return require('./bundle4')(); - } - - return { - CopyWebpackPlugin: requireShim('copy-webpack-plugin'), - webpack: requireShim('webpack'), - webpackMerge: requireShim('webpack-merge').default, - nodeExternals: requireShim('webpack-node-externals'), - }; -}; diff --git a/packages/node/src/webpack/delete-in-nx-13.txt b/packages/node/src/webpack/delete-in-nx-13.txt deleted file mode 100644 index 7d73560485..0000000000 --- a/packages/node/src/webpack/delete-in-nx-13.txt +++ /dev/null @@ -1 +0,0 @@ -TODO(jack): Delete for Nx 13 diff --git a/packages/node/src/webpack/entry.ts b/packages/node/src/webpack/entry.ts deleted file mode 100644 index 4f899b364c..0000000000 --- a/packages/node/src/webpack/entry.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { logger } from '@nrwl/devkit'; -import { requireShim } from './require-shim'; - -const { version } = requireShim('webpack/package.json'); - -exports.default = undefined; - -const forceWebpack4 = process.env.NX_FORCE_WEBPACK_4; - -exports.isWebpack5 = !forceWebpack4 && /^5\./.test(version); - -let hasLogged = false; - -if (exports.isWebpack5) { - if (!hasLogged) { - logger.info( - `NX Using webpack 5. Reason: detected version 5 in node_modules/webpack/package.json` - ); - hasLogged = true; - } - Object.assign( - exports, - require('./bundle5')(() => { - exports.isWebpack5 = false; - }) - ); -} else { - if (!hasLogged) { - hasLogged = true; - } - Object.assign(exports, require('./bundle4')()); -} diff --git a/packages/node/src/webpack/require-shim.ts b/packages/node/src/webpack/require-shim.ts deleted file mode 100644 index a20e3b1f73..0000000000 --- a/packages/node/src/webpack/require-shim.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { appRootPath } from '@nrwl/tao/src/utils/app-root'; -import { join } from 'path'; - -export function requireShim(path: string) { - try { - return require(join(appRootPath, 'node_modules', path)); - } catch { - return require(path); - } -} diff --git a/packages/react/package.json b/packages/react/package.json index 7f3f4fecc5..d05e07a3da 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -45,10 +45,10 @@ "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4.2.0", - "react-refresh": "^0.9.0", + "react-refresh": "^0.10.0", "url-loader": "^3.0.0", - "webpack": "4.46.0", - "webpack-merge": "4.2.1", + "webpack": "^5.58.1", + "webpack-merge": "^5.8.0", "@storybook/node-logger": "6.1.20", "semver": "7.3.4" } diff --git a/packages/react/plugins/bundle-babel.ts b/packages/react/plugins/bundle-babel.ts deleted file mode 100644 index 6ae6705be6..0000000000 --- a/packages/react/plugins/bundle-babel.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { join } from 'path'; -import { readJsonFile } from '@nrwl/workspace/src/utilities/fileutils'; -import { appRootPath } from '@nrwl/tao/src/utils/app-root'; - -// TODO(jack): Remove this in Nx 13 since it is no longer needed with `.babelrc` changes -function getRollupBabelOptions(babelOptions: any) { - // Add react babel preset - const idx = babelOptions.presets.findIndex( - (p) => Array.isArray(p) && p[0].indexOf('@babel/preset-env') !== -1 - ); - babelOptions.presets.splice(idx + 1, 0, [ - require.resolve('@babel/preset-react'), - { - useBuiltIns: true, - }, - ]); - - // Add babel plugin for styled-components or emotion. - // We don't have a good way to know when a project uses one or the other, so - // add the plugin only if the other style package isn't used. - const packageJson = readJsonFile(join(appRootPath, 'package.json')); - const deps = { ...packageJson.dependencies, ...packageJson.devDependencies }; - const hasStyledComponents = !!deps['styled-components']; - const hasEmotion = !!deps['@emotion/react']; - if (hasStyledComponents && !hasEmotion) { - babelOptions.plugins.splice(0, 0, [ - require.resolve('babel-plugin-styled-components'), - { - pure: true, - }, - ]); - } - if (hasEmotion && !hasStyledComponents) { - babelOptions.plugins.splice(0, 0, require.resolve('babel-plugin-emotion')); - } - return babelOptions; -} - -module.exports = getRollupBabelOptions; diff --git a/packages/react/plugins/storybook/index.ts b/packages/react/plugins/storybook/index.ts index 4483da19c4..aa46b8a684 100644 --- a/packages/react/plugins/storybook/index.ts +++ b/packages/react/plugins/storybook/index.ts @@ -7,9 +7,10 @@ import { checkAndCleanWithSemver } from '@nrwl/workspace/src/utilities/version-u import { logger } from '@storybook/node-logger'; import { join } from 'path'; import { gte } from 'semver'; -import { Configuration } from 'webpack'; +import { Configuration, WebpackPluginInstance } from 'webpack'; import * as mergeWebpack from 'webpack-merge'; import { mergePlugins } from './merge-plugins'; + const reactWebpackConfig = require('../webpack'); export const babelDefault = (): Record< @@ -72,7 +73,7 @@ export const webpack = async ( const extractCss = storybookWebpackConfig.mode === 'production'; // ESM build for modern browsers. - const baseWebpackConfig = mergeWebpack([ + const baseWebpackConfig = mergeWebpack.merge([ getBaseWebpackPartial(builderOptions, esm, isScriptOptimizeOn), getStylesPartial( options.workspaceRoot, @@ -128,7 +129,7 @@ export const webpack = async ( }; } } - return mergeWebpack( + return mergeWebpack.merge( { ...storybookWebpackConfig, module: { @@ -141,7 +142,8 @@ export const webpack = async ( resolve: { ...storybookWebpackConfig.resolve, plugins: mergePlugins( - ...(storybookWebpackConfig.resolve.plugins ?? []), + ...((storybookWebpackConfig.resolve.plugins ?? + []) as unknown as WebpackPluginInstance[]), ...(finalConfig.resolve.plugins ?? []) ), }, diff --git a/packages/react/plugins/storybook/merge-plugins.ts b/packages/react/plugins/storybook/merge-plugins.ts index 8b1617569d..a7c20e3d92 100644 --- a/packages/react/plugins/storybook/merge-plugins.ts +++ b/packages/react/plugins/storybook/merge-plugins.ts @@ -1,4 +1,4 @@ -import { Plugin, RuleSetRule } from 'webpack'; +import { RuleSetRule, WebpackPluginInstance } from 'webpack'; export const mergeRules = (...args: RuleSetRule[]) => args.reduce((rules, rule) => { @@ -11,9 +11,11 @@ export const mergeRules = (...args: RuleSetRule[]) => return rules; } return [...rules, rule]; - }, [] as Plugin[]); + }, [] as WebpackPluginInstance[]); -export const mergePlugins = (...args: Plugin[]): Plugin[] => +export const mergePlugins = ( + ...args: WebpackPluginInstance[] +): WebpackPluginInstance[] => args.reduce((plugins, plugin) => { if ( plugins.some( @@ -24,4 +26,4 @@ export const mergePlugins = (...args: Plugin[]): Plugin[] => return plugins; } return [...plugins, plugin]; - }, [] as Plugin[]); + }, [] as WebpackPluginInstance[]); diff --git a/packages/react/plugins/webpack.ts b/packages/react/plugins/webpack.ts index 0dae10fb30..99f9a64522 100644 --- a/packages/react/plugins/webpack.ts +++ b/packages/react/plugins/webpack.ts @@ -1,9 +1,8 @@ import type { Configuration } from 'webpack'; +import ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); // Add React-specific configuration function getWebpackConfig(config: Configuration) { - // TODO(jack): Remove in Nx 13 - const { ReactRefreshPlugin, isWebpack5 } = require('../src/webpack/entry'); config.module.rules.push( { test: /\.(png|jpe?g|gif|webp)$/, @@ -18,7 +17,7 @@ function getWebpackConfig(config: Configuration) { oneOf: [ // If coming from JS/TS file, then transform into React component using SVGR. { - issuer: isWebpack5 ? /\.[jt]sx?$/ : { test: /\.[jt]sx?$/ }, + issuer: /\.[jt]sx?$/, use: [ { loader: require.resolve('@svgr/webpack'), @@ -56,10 +55,12 @@ function getWebpackConfig(config: Configuration) { if (config.mode === 'development' && config['devServer']?.hot) { // add `react-refresh/babel` to babel loader plugin - const babelLoader = config.module.rules.find((rule) => - rule.loader.toString().includes('babel-loader') + const babelLoader = config.module.rules.find( + (rule) => + typeof rule !== 'string' && + rule.loader.toString().includes('babel-loader') ); - if (babelLoader) { + if (babelLoader && typeof babelLoader !== 'string') { babelLoader.options['plugins'] = [ ...(babelLoader.options['plugins'] || []), [ diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index 9c21acbf73..a5df042d43 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -263,13 +263,6 @@ Object { }); expect(targetConfig.build.configurations.production).toEqual({ optimization: true, - budgets: [ - { - maximumError: '5mb', - maximumWarning: '2mb', - type: 'initial', - }, - ], extractCss: true, extractLicenses: true, fileReplacements: [ @@ -703,22 +696,5 @@ Object { tsconfigJson.compilerOptions.noFallthroughCasesInSwitch ).toBeTruthy(); }); - - it('should update budgets in workspace.json', async () => { - await applicationGenerator(appTree, { - ...schema, - strict: true, - }); - const workspaceJson = getProjects(appTree); - const targetConfig = workspaceJson.get('my-app').targets; - - expect(targetConfig.build.configurations.production.budgets).toEqual([ - { - type: 'initial', - maximumWarning: '500kb', - maximumError: '1mb', - }, - ]); - }); }); }); diff --git a/packages/react/src/generators/application/lib/add-project.ts b/packages/react/src/generators/application/lib/add-project.ts index 34009d46a8..0b42c97e4d 100644 --- a/packages/react/src/generators/application/lib/add-project.ts +++ b/packages/react/src/generators/application/lib/add-project.ts @@ -93,21 +93,6 @@ function createBuildTarget(options: NormalizedSchema): TargetConfiguration { namedChunks: false, extractLicenses: true, vendorChunk: false, - budgets: options.strict - ? [ - { - type: 'initial', - maximumWarning: '500kb', - maximumError: '1mb', - }, - ] - : [ - { - type: 'initial', - maximumWarning: '2mb', - maximumError: '5mb', - }, - ], }, }, }; diff --git a/packages/react/src/generators/application/schema.json b/packages/react/src/generators/application/schema.json index 9d65856c8e..34747e28c0 100644 --- a/packages/react/src/generators/application/schema.json +++ b/packages/react/src/generators/application/schema.json @@ -43,7 +43,10 @@ "message": "Which stylesheet format would you like to use?", "type": "list", "items": [ - { "value": "css", "label": "CSS" }, + { + "value": "css", + "label": "CSS" + }, { "value": "scss", "label": "SASS(.scss) [ http://sass-lang.com ]" @@ -138,7 +141,7 @@ }, "strict": { "type": "boolean", - "description": "Creates an application with stricter type checking and build optimization options.", + "description": "Creates an application with strict mode and strict type checking", "default": true }, "setParserOptionsProject": { diff --git a/packages/react/src/webpack/bundle4.ts b/packages/react/src/webpack/bundle4.ts deleted file mode 100644 index c352228663..0000000000 --- a/packages/react/src/webpack/bundle4.ts +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = function (useShim = true) { - const webpack = require('webpack'); - webpack.webpack = webpack; - - return { - ReactRefreshPlugin: require('@pmmmwh/react-refresh-webpack-plugin'), - webpack, - }; -}; diff --git a/packages/react/src/webpack/bundle5.ts b/packages/react/src/webpack/bundle5.ts deleted file mode 100644 index a41a393b23..0000000000 --- a/packages/react/src/webpack/bundle5.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { logger, stripIndents } from '@nrwl/devkit'; -import chalk = require('chalk'); - -import { requireShim } from './require-shim'; -import packageJson = require('../../package.json'); - -function validateVersion(path) { - if ( - packageJson.dependencies[path] === - requireShim(`${path}/package.json`).version - ) { - logger.warn(`Found an outdated version of ${chalk.bold(path)}\n`); - - logger.info(stripIndents` - If you want to use webpack 5, try installing compatible versions of the plugins. - See: https://nx.dev/guides/webpack-5 - `); - - throw new Error('Incompatible version'); - } -} - -module.exports = function (onFallback) { - try { - validateVersion('@pmmmwh/react-refresh-webpack-plugin'); - } catch { - logger.info( - `NX Falling back to webpack 4 due to incompatible plugin versions` - ); - onFallback(); - return require('./bundle4')(); - } - - return { - ReactRefreshPlugin: requireShim('@pmmmwh/react-refresh-webpack-plugin'), - webpack: requireShim('webpack'), - }; -}; diff --git a/packages/react/src/webpack/delete-in-nx-13.txt b/packages/react/src/webpack/delete-in-nx-13.txt deleted file mode 100644 index 7d73560485..0000000000 --- a/packages/react/src/webpack/delete-in-nx-13.txt +++ /dev/null @@ -1 +0,0 @@ -TODO(jack): Delete for Nx 13 diff --git a/packages/react/src/webpack/entry.ts b/packages/react/src/webpack/entry.ts deleted file mode 100644 index 8065e83916..0000000000 --- a/packages/react/src/webpack/entry.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { requireShim } from './require-shim'; - -const result = requireShim('webpack/package.json'); -const version = result?.version; - -exports.default = undefined; - -const forceWebpack4 = process.env.NX_FORCE_WEBPACK_4; - -exports.isWebpack5 = !forceWebpack4 && /^5\./.test(version); - -if (exports.isWebpack5) { - Object.assign( - exports, - require('./bundle5')(() => { - exports.isWebpack5 = false; - }) - ); -} else { - Object.assign(exports, require('./bundle4')()); -} diff --git a/packages/react/src/webpack/require-shim.ts b/packages/react/src/webpack/require-shim.ts deleted file mode 100644 index a20e3b1f73..0000000000 --- a/packages/react/src/webpack/require-shim.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { appRootPath } from '@nrwl/tao/src/utils/app-root'; -import { join } from 'path'; - -export function requireShim(path: string) { - try { - return require(join(appRootPath, 'node_modules', path)); - } catch { - return require(path); - } -} diff --git a/packages/storybook/package.json b/packages/storybook/package.json index b836af0613..ad54a1b19d 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -35,7 +35,7 @@ "@nrwl/workspace": "*", "core-js": "^3.6.5", "semver": "7.3.4", - "ts-loader": "5.4.5", + "ts-loader": "^9.2.6", "tsconfig-paths-webpack-plugin": "3.4.1" } } diff --git a/packages/storybook/src/executors/utils.ts b/packages/storybook/src/executors/utils.ts index 103466a3c2..77f1b44c7c 100644 --- a/packages/storybook/src/executors/utils.ts +++ b/packages/storybook/src/executors/utils.ts @@ -2,7 +2,6 @@ import { ExecutorContext, joinPathFragments, logger } from '@nrwl/devkit'; import { existsSync, readFileSync } from 'fs'; import { join } from 'path'; import { gte } from 'semver'; -import { isWebpack5 } from '../utils/utilities'; import { CommonNxStorybookConfig } from './models'; export interface NodePackage { @@ -73,16 +72,15 @@ export function runStorybookSetupCheck(options: CommonNxStorybookConfig) { function reactWebpack5Check(options: CommonNxStorybookConfig) { if (options.uiFramework === '@storybook/react') { - if (isWebpack5()) { - // check whether the current Storybook configuration has the webpack 5 builder enabled - const storybookConfig = readFileSync( - joinPathFragments(options.config.configFolder, 'main.js'), - { encoding: 'utf8' } - ); + // check whether the current Storybook configuration has the webpack 5 builder enabled + const storybookConfig = readFileSync( + joinPathFragments(options.config.configFolder, 'main.js'), + { encoding: 'utf8' } + ); - if (!storybookConfig.includes(`builder: 'webpack5'`)) { - // storybook needs to be upgraded to webpack 5 - logger.warn(` + if (!storybookConfig.includes(`builder: 'webpack5'`)) { + // storybook needs to be upgraded to webpack 5 + logger.warn(` It looks like you use Webpack 5 but your Storybook setup is not configured to leverage that and thus falls back to Webpack 4. Make sure you upgrade your Storybook config to use Webpack 5. @@ -90,7 +88,6 @@ Make sure you upgrade your Storybook config to use Webpack 5. - https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade `); - } } } } diff --git a/packages/storybook/src/generators/configuration/configuration.ts b/packages/storybook/src/generators/configuration/configuration.ts index 9a71ed93e3..a1baa186dd 100644 --- a/packages/storybook/src/generators/configuration/configuration.ts +++ b/packages/storybook/src/generators/configuration/configuration.ts @@ -19,13 +19,14 @@ import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-ser import { Linter } from '@nrwl/linter'; import { join } from 'path'; -import { isFramework, isWebpack5, TsConfig } from '../../utils/utilities'; +import { isFramework, TsConfig } from '../../utils/utilities'; import { cypressProjectGenerator } from '../cypress-project/cypress-project'; import { StorybookConfigureSchema } from './schema'; import { storybookVersion } from '../../utils/versions'; import { initGenerator } from '../init/init'; import { checkAndCleanWithSemver } from '@nrwl/workspace/src/utilities/version-utils'; import { gte } from 'semver'; + export async function configurationGenerator( tree: Tree, rawSchema: StorybookConfigureSchema @@ -154,7 +155,7 @@ function createProjectStorybookDir( projectType: projectDirectory, useWebpack5: uiFramework === '@storybook/angular' || - (uiFramework === '@storybook/react' && isWebpack5()), + uiFramework === '@storybook/react', existsRootWebpackConfig: tree.exists('.storybook/webpack.config.js'), }); diff --git a/packages/storybook/src/generators/init/init.ts b/packages/storybook/src/generators/init/init.ts index 89b606226c..5d6534a349 100644 --- a/packages/storybook/src/generators/init/init.ts +++ b/packages/storybook/src/generators/init/init.ts @@ -7,7 +7,7 @@ import { updateJson, updateWorkspaceConfiguration, } from '@nrwl/devkit'; -import { isFramework, isWebpack5 } from '../../utils/utilities'; +import { isFramework } from '../../utils/utilities'; import { babelCoreVersion, babelLoaderVersion, @@ -86,20 +86,18 @@ function checkDependenciesInstalled(host: Tree, schema: Schema) { devDependencies['@storybook/react'] = storybookVersion; } - if (isWebpack5()) { - if ( - !packageJson.dependencies['@storybook/builder-webpack5'] && - !packageJson.devDependencies['@storybook/builder-webpack5'] - ) { - devDependencies['@storybook/builder-webpack5'] = storybookVersion; - } + if ( + !packageJson.dependencies['@storybook/builder-webpack5'] && + !packageJson.devDependencies['@storybook/builder-webpack5'] + ) { + devDependencies['@storybook/builder-webpack5'] = storybookVersion; + } - if ( - !packageJson.dependencies['@storybook/manager-webpack5'] && - !packageJson.devDependencies['@storybook/manager-webpack5'] - ) { - devDependencies['@storybook/manager-webpack5'] = storybookVersion; - } + if ( + !packageJson.dependencies['@storybook/manager-webpack5'] && + !packageJson.devDependencies['@storybook/manager-webpack5'] + ) { + devDependencies['@storybook/manager-webpack5'] = storybookVersion; } } if (isFramework('html', schema)) { @@ -169,5 +167,6 @@ export function initGenerator(tree: Tree, schema: Schema) { addCacheableOperation(tree); return installTask; } + export default initGenerator; export const initSchematic = convertNxGenerator(initGenerator); diff --git a/packages/storybook/src/utils/utilities.ts b/packages/storybook/src/utils/utilities.ts index 732d3e98ca..2b57a648ba 100644 --- a/packages/storybook/src/utils/utilities.ts +++ b/packages/storybook/src/utils/utilities.ts @@ -76,44 +76,3 @@ export type TsConfig = { exclude?: string[]; references?: Array<{ path: string }>; }; - -// taken from packages/web/src/webpack/entry.ts -export function isWebpack5(): boolean { - const result = requireShim('webpack/package.json'); - const version = result?.version; - const forceWebpack4 = process.env.NX_FORCE_WEBPACK_4; - return !forceWebpack4 && /^5\./.test(version); -} - -// taken from packages/web/src/webpack/require-shim.ts -function requireShim(path: string) { - try { - return require(join(pathInner(__dirname), 'node_modules', path)); - } catch { - return require(path); - } -} - -// taken from packages/tao/src/utils/app-root.ts -function pathInner(dir: string): string { - if (process.env.NX_WORKSPACE_ROOT_PATH) - return process.env.NX_WORKSPACE_ROOT_PATH; - if (path.dirname(dir) === dir) return process.cwd(); - if ( - fileExists(path.join(dir, 'workspace.json')) || - fileExists(path.join(dir, 'angular.json')) - ) { - return dir; - } else { - return pathInner(path.dirname(dir)); - } -} - -// taken from packages/tao/src/utils/app-root.ts -function fileExists(filePath: string): boolean { - try { - return statSync(filePath).isFile(); - } catch (err) { - return false; - } -} diff --git a/packages/web/generators.json b/packages/web/generators.json index acb59ea948..4c9dced06e 100644 --- a/packages/web/generators.json +++ b/packages/web/generators.json @@ -15,12 +15,6 @@ "aliases": ["app"], "x-type": "application", "description": "Create an application" - }, - "migrate-to-webpack-5": { - "factory": "./src/generators/migrate-to-webpack-5/migrate-to-webpack-5#webMigrateToWebpack5Generator", - "schema": "./src/generators/migrate-to-webpack-5/schema.json", - "aliases": ["webpack5"], - "description": "Add webpack 5 compatible dependencies to the workspace" } }, "schematics": { @@ -36,12 +30,6 @@ "aliases": ["app"], "x-type": "application", "description": "Create an application" - }, - "migrate-to-webpack-5": { - "factory": "./src/generators/migrate-to-webpack-5/migrate-to-webpack-5#webMigrateToWebpack5Schematic", - "schema": "./src/generators/migrate-to-webpack-5/schema.json", - "aliases": ["webpack5"], - "description": "Add webpack 5 compatible dependencies to the workspace" } } } diff --git a/packages/web/migrations.json b/packages/web/migrations.json index 54494216e8..77899a10ce 100644 --- a/packages/web/migrations.json +++ b/packages/web/migrations.json @@ -38,6 +38,12 @@ "version": "13.0.0-beta.1", "description": "Removes deprecated node-sass package (sass is already a dependency of @nrwl/web).", "factory": "./src/migrations/update-13-0-0/remove-node-sass-13-0-0" + }, + "remove-webpack-5-packages": { + "cli": "nx", + "version": "13.0.0-beta.1", + "description": "Remove packages installed by Nx 12's `@nrwl/web:webpack5` generator.", + "factory": "./src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0" } }, "packageJsonUpdates": { diff --git a/packages/web/package.json b/packages/web/package.json index c30a9b85f7..265f962dbb 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -58,10 +58,12 @@ "chalk": "4.1.0", "chokidar": "^3.5.1", "circular-dependency-plugin": "5.2.0", - "clean-css": "4.2.1", - "copy-webpack-plugin": "6.4.1", + "copy-webpack-plugin": "^9.0.1", + "react-refresh": "^0.10.0", + "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1", "core-js": "^3.6.5", "css-loader": "3.6.0", + "css-minimizer-webpack-plugin": "^3.1.1", "file-loader": "4.2.0", "fork-ts-checker-webpack-plugin": "6.2.10", "fs-extra": "^9.1.0", @@ -70,7 +72,7 @@ "less-loader": "5.0.0", "license-webpack-plugin": "2.3.15", "loader-utils": "1.2.3", - "mini-css-extract-plugin": "0.8.0", + "mini-css-extract-plugin": "^2.1.0", "parse5": "4.0.0", "parse5-html-rewriting-stream": "6.0.1", "open": "^7.4.2", @@ -91,21 +93,21 @@ "sass-loader": "8.0.2", "semver": "7.3.4", "source-map": "0.7.3", - "source-map-loader": "0.2.4", + "source-map-loader": "^3.0.0", "style-loader": "1.0.0", "stylus": "0.54.5", "stylus-loader": "3.0.2", "terser": "4.3.8", - "terser-webpack-plugin": "2.3.8", - "ts-loader": "5.4.5", + "terser-webpack-plugin": "^5.1.1", + "ts-loader": "^9.2.6", "tsconfig-paths-webpack-plugin": "3.4.1", "tslib": "^2.0.0", - "webpack": "4.46.0", - "webpack-merge": "4.2.1", - "webpack-sources": "1.4.3", + "webpack": "^5.58.1", + "webpack-merge": "^5.8.0", + "webpack-sources": "^3.0.2", "webpack-subresource-integrity": "^1.5.2", "worker-plugin": "3.2.0", - "webpack-dev-server": "3.11.2", + "webpack-dev-server": "^4.3.1", "http-server": "0.12.3", "ignore": "^5.0.4" } diff --git a/packages/web/src/executors/build/build.impl.ts b/packages/web/src/executors/build/build.impl.ts index 08e8416447..7b74ef5190 100644 --- a/packages/web/src/executors/build/build.impl.ts +++ b/packages/web/src/executors/build/build.impl.ts @@ -1,5 +1,6 @@ import type { ExecutorContext } from '@nrwl/devkit'; - +import type { Configuration, Stats } from 'webpack'; +import * as webpack from 'webpack'; import { from, of } from 'rxjs'; import { bufferCount, mergeScan, switchMap, tap } from 'rxjs/operators'; import { eachValueFrom } from 'rxjs-for-await'; @@ -25,13 +26,9 @@ import { BuildBrowserFeatures } from '../../utils/third-party/utils/build-browse import { normalizeWebBuildOptions } from '../../utils/normalize'; import { getWebConfig } from '../../utils/web.config'; -import { BuildBuilderOptions } from '../../utils/types'; +import type { BuildBuilderOptions } from '../../utils/types'; import { deleteOutputDir } from '../../utils/delete-output-dir'; -import { ExtraEntryPoint } from '../../utils/third-party/browser/schema'; - -// TODO(jack): Remove in Nx 13 -type Configuration = any; -type Stats = any; +import type { ExtraEntryPoint } from '../../utils/third-party/browser/schema'; export interface WebBuildBuilderOptions extends BuildBuilderOptions { index: string; @@ -125,8 +122,6 @@ export async function* run( options: WebBuildBuilderOptions, context: ExecutorContext ) { - const { webpack } = require('../../webpack/entry'); - // Node versions 12.2-12.8 has a bug where prod builds will hang for 2-3 minutes // after the program exits. const nodeVersion = execSync(`node --version`).toString('utf-8').trim(); @@ -177,7 +172,7 @@ export async function* run( mergeScan( (acc, config) => { if (!acc.hasErrors()) { - return runWebpack(config, webpack.webpack).pipe( + return runWebpack(config).pipe( tap((stats) => { console.info(stats.toString(config.stats)); }) diff --git a/packages/web/src/executors/build/schema.json b/packages/web/src/executors/build/schema.json index c6009cb088..e93beb4e4e 100644 --- a/packages/web/src/executors/build/schema.json +++ b/packages/web/src/executors/build/schema.json @@ -54,37 +54,14 @@ "default": true }, "sourceMap": { - "description": "Output sourcemaps.", + "description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.", "default": true, "oneOf": [ { - "type": "object", - "properties": { - "scripts": { - "type": "boolean", - "description": "Output sourcemaps for all scripts.", - "default": true - }, - "styles": { - "type": "boolean", - "description": "Output sourcemaps for all styles.", - "default": true - }, - "hidden": { - "type": "boolean", - "description": "Output sourcemaps used for error reporting tools.", - "default": false - }, - "vendor": { - "type": "boolean", - "description": "Resolve vendor packages sourcemaps.", - "default": false - } - }, - "additionalProperties": false + "type": "boolean" }, { - "type": "boolean" + "type": "string" } ] }, @@ -260,7 +237,6 @@ } }, "required": ["tsConfig", "main", "index"], - "definitions": { "assetPattern": { "oneOf": [ diff --git a/packages/web/src/executors/dev-server/dev-server.impl.ts b/packages/web/src/executors/dev-server/dev-server.impl.ts index 0fe9e9cdba..0d26a6b852 100644 --- a/packages/web/src/executors/dev-server/dev-server.impl.ts +++ b/packages/web/src/executors/dev-server/dev-server.impl.ts @@ -1,8 +1,9 @@ +import * as webpack from 'webpack'; import { ExecutorContext, + joinPathFragments, parseTargetString, readTargetOptions, - joinPathFragments, } from '@nrwl/devkit'; import { eachValueFrom } from 'rxjs-for-await'; @@ -45,7 +46,6 @@ export default async function* devServerExecutor( serveOptions: WebDevServerOptions, context: ExecutorContext ) { - const { webpack } = require('../../webpack/entry'); const { root: projectRoot, sourceRoot } = context.workspace.projects[context.projectName]; const buildOptions = normalizeWebBuildOptions( diff --git a/packages/web/src/generators/application/application.spec.ts b/packages/web/src/generators/application/application.spec.ts index 6539aa19ce..a64191b3d9 100644 --- a/packages/web/src/generators/application/application.spec.ts +++ b/packages/web/src/generators/application/application.spec.ts @@ -268,13 +268,6 @@ describe('app', () => { }); expect(architectConfig.build.configurations.production).toEqual({ optimization: true, - budgets: [ - { - maximumError: '5mb', - maximumWarning: '2mb', - type: 'initial', - }, - ], extractCss: true, extractLicenses: true, fileReplacements: [ diff --git a/packages/web/src/generators/application/application.ts b/packages/web/src/generators/application/application.ts index fa5fcf4540..2f0365b75a 100644 --- a/packages/web/src/generators/application/application.ts +++ b/packages/web/src/generators/application/application.ts @@ -87,13 +87,6 @@ function addBuildTarget( namedChunks: false, extractLicenses: true, vendorChunk: false, - budgets: [ - { - type: 'initial', - maximumWarning: '2mb', - maximumError: '5mb', - }, - ], }; return { diff --git a/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts b/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts deleted file mode 100644 index 1ad671c8b1..0000000000 --- a/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.spec.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { readJson, Tree, updateJson } from '@nrwl/devkit'; -import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; -import { webMigrateToWebpack5Generator } from './migrate-to-webpack-5'; - -describe('webMigrateToWebpack5Generator', () => { - let tree: Tree; - - beforeEach(() => { - tree = createTreeWithEmptyWorkspace(); - }); - - it('should add packages needed by Web', async () => { - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@nrwl/cli': '100.0.0', - '@nrwl/jest': '100.0.0', - '@nrwl/node': '100.0.0', - '@nrwl/react': '100.0.0', - '@nrwl/web': '100.0.0', - '@nrwl/workspace': '100.0.0', - }; - return json; - }); - - await webMigrateToWebpack5Generator(tree, {}); - - const json = readJson(tree, '/package.json'); - - expect(json.devDependencies['webpack']).toMatch(/\^5/); - expect( - json.devDependencies['@pmmmwh/react-refresh-webpack-plugin'] - ).toMatch(/^0\.5/); - }); - - it('should add packages needed by Storybook if workspace has the @storybook/react package', async () => { - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@storybook/react': '~6.3.0', - }; - return json; - }); - - await webMigrateToWebpack5Generator(tree, {}); - - const json = readJson(tree, '/package.json'); - - expect(json.devDependencies['@storybook/builder-webpack5']).toBe('~6.3.0'); - expect(json.devDependencies['@storybook/manager-webpack5']).toBe('~6.3.0'); - }); - - it('should not add the webpack Storybook packages again if they already exist', async () => { - let newTree = createTreeWithEmptyWorkspace(); - updateJson(newTree, 'package.json', (json) => { - json.dependencies = { - '@storybook/react': '~6.3.0', - '@storybook/builder-webpack5': '~6.3.0', - '@storybook/manager-webpack5': '~6.3.0', - }; - return json; - }); - await webMigrateToWebpack5Generator(newTree, {}); - const json = readJson(newTree, '/package.json'); - expect(json.devDependencies['@storybook/builder-webpack5']).toBeUndefined(); - expect(json.devDependencies['@storybook/manager-webpack5']).toBeUndefined(); - }); - - it('should not add Storybook packages if @storybook/react does not exist', async () => { - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@storybook/angular': '~6.3.0', - }; - return json; - }); - await webMigrateToWebpack5Generator(tree, {}); - const json = readJson(tree, '/package.json'); - expect(json.devDependencies['@storybook/builder-webpack5']).toBeUndefined(); - expect(json.devDependencies['@storybook/manager-webpack5']).toBeUndefined(); - }); - - describe('updating project-level .storybook/main.js configurations for webpack 5', () => { - beforeEach(async () => { - updateJson(tree, 'package.json', (json) => { - json.devDependencies = { - '@storybook/react': '~6.3.0', - }; - return json; - }); - - updateJson(tree, 'workspace.json', (json) => { - json = { - ...json, - projects: { - ...json.projects, - 'test-one': { - targets: { - storybook: { - options: { - uiFramework: '@storybook/react', - config: { - configFolder: 'libs/test-one/.storybook', - }, - }, - }, - }, - }, - 'test-two': { - targets: { - storybook: { - options: { - uiFramework: '@storybook/react', - config: { - configFolder: 'libs/test-two/.storybook', - }, - }, - }, - }, - }, - }, - }; - return json; - }); - - tree.write( - `.storybook/main.js`, - `module.exports = { - stories: [], - addons: ['@storybook/addon-essentials'], - // uncomment the property below if you want to apply some webpack config globally - // webpackFinal: async (config, { configType }) => { - // // Make whatever fine-grained changes you need that should apply to all storybook configs - - // // Return the altered config - // return config; - // }, - }; - ` - ); - }); - - it('should update the project-level .storybook/main.js if there is a core object', async () => { - tree.write( - `libs/test-one/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - ...rootMain, - - core: { ...rootMain.core }, - stories: [ - ...rootMain.stories, - '../src/lib/**/*.stories.mdx', - '../src/lib/**/*.stories.@(js|jsx|ts|tsx)', - ], - addons: [...rootMain.addons, '@nrwl/react/plugins/storybook'], - webpackFinal: async (config, { configType }) => { - // apply any global webpack configs that might have been specified in .storybook/main.js - if (rootMain.webpackFinal) { - config = await rootMain.webpackFinal(config, { configType }); - } - - // add your own webpack tweaks if needed - - return config; - }, - };` - ); - - tree.write( - `libs/test-two/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - ...rootMain, - - core: { ...rootMain.core }, - stories: [ - ...rootMain.stories, - '../src/lib/**/*.stories.mdx', - '../src/lib/**/*.stories.@(js|jsx|ts|tsx)', - ], - addons: [...rootMain.addons, '@nrwl/react/plugins/storybook'], - webpackFinal: async (config, { configType }) => { - // apply any global webpack configs that might have been specified in .storybook/main.js - if (rootMain.webpackFinal) { - config = await rootMain.webpackFinal(config, { configType }); - } - - // add your own webpack tweaks if needed - - return config; - }, - };` - ); - - await webMigrateToWebpack5Generator(tree, {}); - - const projectOne = tree.read(`libs/test-one/.storybook/main.js`, 'utf-8'); - expect(projectOne).toContain(`builder: 'webpack5'`); - const projectTwo = tree.read(`libs/test-two/.storybook/main.js`, 'utf-8'); - expect(projectTwo).toContain(`builder: 'webpack5'`); - }); - - it('should update the project-level .storybook/main.js if there is not a core object', async () => { - tree.write( - `libs/test-one/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - ...rootMain, - - stories: [ - ...rootMain.stories, - '../src/lib/**/*.stories.mdx', - '../src/lib/**/*.stories.@(js|jsx|ts|tsx)', - ], - addons: [...rootMain.addons, '@nrwl/react/plugins/storybook'], - webpackFinal: async (config, { configType }) => { - // apply any global webpack configs that might have been specified in .storybook/main.js - if (rootMain.webpackFinal) { - config = await rootMain.webpackFinal(config, { configType }); - } - - // add your own webpack tweaks if needed - - return config; - }, - };` - ); - - tree.write( - `libs/test-two/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - ...rootMain, - - stories: [ - ...rootMain.stories, - '../src/lib/**/*.stories.mdx', - '../src/lib/**/*.stories.@(js|jsx|ts|tsx)', - ], - addons: [...rootMain.addons, '@nrwl/react/plugins/storybook'], - webpackFinal: async (config, { configType }) => { - // apply any global webpack configs that might have been specified in .storybook/main.js - if (rootMain.webpackFinal) { - config = await rootMain.webpackFinal(config, { configType }); - } - - // add your own webpack tweaks if needed - - return config; - }, - };` - ); - - await webMigrateToWebpack5Generator(tree, {}); - const projectOne = tree.read(`libs/test-one/.storybook/main.js`, 'utf-8'); - expect(projectOne).toContain(`builder: 'webpack5'`); - const projectTwo = tree.read(`libs/test-two/.storybook/main.js`, 'utf-8'); - expect(projectTwo).toContain(`builder: 'webpack5'`); - }); - - it('should not do anything if project-level .storybook/main.js is invalid', async () => { - tree.write( - `libs/test-one/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - };` - ); - - tree.write( - `libs/test-two/.storybook/main.js`, - `const rootMain = require('../../../.storybook/main'); - - module.exports = { - ...rootMain, - }, - };` - ); - - await webMigrateToWebpack5Generator(tree, {}); - const projectOne = tree.read(`libs/test-one/.storybook/main.js`, 'utf-8'); - expect(projectOne).not.toContain(`builder: 'webpack5'`); - const projectTwo = tree.read(`libs/test-two/.storybook/main.js`, 'utf-8'); - expect(projectTwo).not.toContain(`builder: 'webpack5'`); - }); - }); -}); diff --git a/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts b/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts deleted file mode 100644 index 2739501197..0000000000 --- a/packages/web/src/generators/migrate-to-webpack-5/migrate-to-webpack-5.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { GeneratorCallback, readJson, Tree } from '@nrwl/devkit'; -import { - addDependenciesToPackageJson, - convertNxGenerator, - logger, - removeDependenciesFromPackageJson, -} from '@nrwl/devkit'; -import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; -import { - migrateStorybookToWebPack5, - workspaceHasStorybookForReact, -} from './storybook-webpack5-changes'; - -const basePackages = { - 'copy-webpack-plugin': '^9.0.1', - webpack: '^5.47.0', - 'webpack-merge': '^5.8.0', - 'webpack-node-externals': '^3.0.0', -}; - -const webPackages = { - 'mini-css-extract-plugin': '^2.1.0', - 'source-map-loader': '^3.0.0', - 'terser-webpack-plugin': '^5.1.1', - 'webpack-dev-server': '4.0.0-rc.0', - 'webpack-sources': '^3.0.2', - 'react-refresh': '^0.10.0', - '@pmmmwh/react-refresh-webpack-plugin': '0.5.0-rc.2', -}; - -export async function webMigrateToWebpack5Generator(tree: Tree, schema: {}) { - const packages = { ...basePackages, ...webPackages }; - const tasks: GeneratorCallback[] = []; - const packageJson = readJson(tree, 'package.json'); - - logger.info(`NX Adding webpack 5 to workspace.`); - - // Removing the packages ensures that the versions will be updated when adding them after - tasks.push( - removeDependenciesFromPackageJson(tree, [], Object.keys(packages)) - ); - - // Here, if our workspace has Storybook for React, we add the Storybook webpack 5 dependencies - if (workspaceHasStorybookForReact(packageJson)) { - if ( - !( - packageJson.dependencies['@storybook/builder-webpack5'] || - packageJson.devDependencies['@storybook/builder-webpack5'] - ) - ) { - packages['@storybook/builder-webpack5'] = - workspaceHasStorybookForReact(packageJson); - } - if ( - !( - packageJson.dependencies['@storybook/manager-webpack5'] || - packageJson.devDependencies['@storybook/manager-webpack5'] - ) - ) { - packages['@storybook/manager-webpack5'] = - workspaceHasStorybookForReact(packageJson); - } - await migrateStorybookToWebPack5(tree); - } - - tasks.push(addDependenciesToPackageJson(tree, {}, packages)); - - return runTasksInSerial(...tasks); -} - -export default webMigrateToWebpack5Generator; -export const webMigrateToWebpack5Schematic = convertNxGenerator( - webMigrateToWebpack5Generator -); diff --git a/packages/web/src/generators/migrate-to-webpack-5/schema.json b/packages/web/src/generators/migrate-to-webpack-5/schema.json deleted file mode 100644 index 6afc0a0a85..0000000000 --- a/packages/web/src/generators/migrate-to-webpack-5/schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "http://json-schema.org/schema", - "$id": "NxWebMigrateToWebpack5", - "cli": "nx", - "title": "Migrate to webpack 5", - "type": "object", - "properties": {}, - "required": [] -} diff --git a/packages/web/src/generators/migrate-to-webpack-5/storybook-webpack5-changes.ts b/packages/web/src/generators/migrate-to-webpack-5/storybook-webpack5-changes.ts deleted file mode 100644 index 1bb85c7740..0000000000 --- a/packages/web/src/generators/migrate-to-webpack-5/storybook-webpack5-changes.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { getProjects, Tree } from '@nrwl/devkit'; -import { - logger, - formatFiles, - applyChangesToString, - ChangeType, -} from '@nrwl/devkit'; - -import ts = require('typescript'); -import { findNodes } from '@nrwl/workspace/src/utilities/typescript/find-nodes'; - -export function workspaceHasStorybookForReact( - packageJson: any -): string | undefined { - return ( - packageJson.dependencies['@storybook/react'] || - packageJson.devDependencies['@storybook/react'] - ); -} - -export async function migrateStorybookToWebPack5(tree: Tree) { - allReactProjectsWithStorybookConfiguration(tree).forEach((project) => { - editProjectMainJs( - tree, - `${project.storybookConfigPath}/main.js`, - project.projectName - ); - }); - await formatFiles(tree); -} - -export function allReactProjectsWithStorybookConfiguration(tree: Tree): { - projectName: string; - storybookConfigPath: string; -}[] { - const projects = getProjects(tree); - const reactProjectsThatHaveStorybookConfiguration: { - projectName: string; - storybookConfigPath: string; - }[] = [...projects.entries()] - ?.filter( - ([_, projectConfig]) => - projectConfig.targets && - projectConfig.targets.storybook && - projectConfig.targets.storybook.options - ) - ?.map(([projectName, projectConfig]) => { - if ( - projectConfig.targets && - projectConfig.targets.storybook && - projectConfig.targets.storybook.options?.config?.configFolder && - projectConfig.targets.storybook.options?.uiFramework === - '@storybook/react' - ) { - return { - projectName, - storybookConfigPath: - projectConfig.targets.storybook.options.config.configFolder, - }; - } - }); - return reactProjectsThatHaveStorybookConfiguration; -} - -export function editProjectMainJs( - tree: Tree, - projectMainJsFile: string, - projectName: string -) { - let newContents: string; - let moduleExportsIsEmptyOrNonExistentOrInvalid = false; - let alreadyHasBuilder: any; - const rootMainJsExists = tree.exists(projectMainJsFile); - if (rootMainJsExists) { - const file = getTsSourceFile(tree, projectMainJsFile); - const appFileContent = tree.read(projectMainJsFile, 'utf-8'); - newContents = appFileContent; - const moduleExportsFull = findNodes(file, [ - ts.SyntaxKind.ExpressionStatement, - ]); - - if (moduleExportsFull && moduleExportsFull[0]) { - const moduleExports = moduleExportsFull[0]; - const listOfStatements = findNodes(moduleExports, [ - ts.SyntaxKind.SyntaxList, - ]); - - /** - * Keep the index of the stories node - * to put the core object before it - * if it does not exist already - */ - - let indexOfStoriesNode = -1; - - const hasCoreObject = listOfStatements[0]?.getChildren()?.find((node) => { - if ( - node && - node.getText().length > 0 && - indexOfStoriesNode < 0 && - node?.getText().startsWith('stories') - ) { - indexOfStoriesNode = node.getStart(); - } - return ( - node?.kind === ts.SyntaxKind.PropertyAssignment && - node?.getText().startsWith('core') - ); - }); - - if (hasCoreObject) { - const contentsOfCoreNode = hasCoreObject.getChildren().find((node) => { - return node.kind === ts.SyntaxKind.ObjectLiteralExpression; - }); - const everyAttributeInsideCoreNode = contentsOfCoreNode - .getChildren() - .find((node) => node.kind === ts.SyntaxKind.SyntaxList); - - alreadyHasBuilder = everyAttributeInsideCoreNode - .getChildren() - .find((node) => node.getText() === "builder: 'webpack5'"); - - if (!alreadyHasBuilder) { - newContents = applyChangesToString(newContents, [ - { - type: ChangeType.Insert, - index: contentsOfCoreNode.getEnd() - 1, - text: ", builder: 'webpack5'", - }, - ]); - } - } else if (indexOfStoriesNode >= 0) { - /** - * Does not have core object, - * so just write one, at the start. - */ - newContents = applyChangesToString(newContents, [ - { - type: ChangeType.Insert, - index: indexOfStoriesNode - 1, - text: "core: { ...rootMain.core, builder: 'webpack5' }, ", - }, - ]); - } else { - /** - * Module exports is empty or does not - * contain stories - most probably invalid - */ - moduleExportsIsEmptyOrNonExistentOrInvalid = true; - } - } else { - /** - * module.exports does not exist - */ - moduleExportsIsEmptyOrNonExistentOrInvalid = true; - } - } else { - moduleExportsIsEmptyOrNonExistentOrInvalid = true; - } - - if (moduleExportsIsEmptyOrNonExistentOrInvalid) { - logger.info( - `Please configure Storybook for project "${projectName}"", since it has not been configured properly.` - ); - return; - } - - if (!alreadyHasBuilder) { - tree.write(projectMainJsFile, newContents); - } -} - -export function getTsSourceFile(host: Tree, path: string): ts.SourceFile { - const buffer = host.read(path); - if (!buffer) { - throw new Error(`Could not read TS file (${path}).`); - } - const content = buffer.toString(); - const source = ts.createSourceFile( - path, - content, - ts.ScriptTarget.Latest, - true - ); - - return source; -} diff --git a/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.spec.ts b/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.spec.ts new file mode 100644 index 0000000000..0e67c228cd --- /dev/null +++ b/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.spec.ts @@ -0,0 +1,59 @@ +import { readJson } from '@nrwl/devkit'; +import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; + +import subject from './remove-budgets-13-0-0'; + +describe('Migration: node-sass to sass', () => { + it(`should remove node-sass if present in devDependencies or dependencies`, async () => { + let tree = createTreeWithEmptyWorkspace(); + + tree.write( + 'workspace.json', + JSON.stringify({ + version: 2, + projects: { + myapp: { + root: 'apps/myapp', + sourceRoot: 'apps/myapp/src', + projectType: 'application', + targets: { + build: { + executor: '@nrwl/web:build', + options: { + budgets: [], + }, + configurations: { + production: { + budgets: [], + }, + }, + }, + }, + }, + }, + }) + ); + + await subject(tree); + + expect(readJson(tree, 'workspace.json')).toEqual({ + version: 2, + projects: { + myapp: { + root: 'apps/myapp', + sourceRoot: 'apps/myapp/src', + projectType: 'application', + targets: { + build: { + executor: '@nrwl/web:build', + options: {}, + configurations: { + production: {}, + }, + }, + }, + }, + }, + }); + }); +}); diff --git a/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.ts b/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.ts new file mode 100644 index 0000000000..a55a9d3044 --- /dev/null +++ b/packages/web/src/migrations/update-13-0-0/remove-budgets-13-0-0.ts @@ -0,0 +1,31 @@ +import { + formatFiles, + getProjects, + logger, + Tree, + updateProjectConfiguration, +} from '@nrwl/devkit'; + +export default async function update(host: Tree) { + const projects = getProjects(host); + + for (const [name, config] of projects.entries()) { + if (config.targets.build.executor === '@nrwl/web:build') { + let updated = false; + if (config.targets.build?.configurations?.production?.budgets) { + delete config.targets.build.configurations.production.budgets; + updated = true; + } + if (config.targets.build.options.budgets) { + delete config.targets.build.options.budgets; + updated = true; + } + if (updated) { + updateProjectConfiguration(host, name, config); + logger.info(`NX Removed legacy budgets build options from "${name}"`); + } + } + } + + await formatFiles(host); +} diff --git a/packages/web/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts b/packages/web/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts new file mode 100644 index 0000000000..c41f18d79e --- /dev/null +++ b/packages/web/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.ts @@ -0,0 +1,34 @@ +import { + formatFiles, + GeneratorCallback, + readJson, + removeDependenciesFromPackageJson, + Tree, +} from '@nrwl/devkit'; + +const packages = [ + 'webpack', + 'copy-webpack-plugin', + 'webpack-merge', + 'webpack-node-externals', + 'mini-css-extract-plugin', + 'source-map-loader', + 'terser-webpack-plugin', + 'webpack-dev-server', + 'webpack-sources', + 'react-refresh', + '@pmmmwh/react-refresh-webpack-plugin', +]; + +export default async function update(tree: Tree) { + const packageJson = readJson(tree, 'package.json'); + let task: undefined | GeneratorCallback = undefined; + + // Undo the install by `nx g @nrwl/web:webpack5` in Nx 12. + if (packageJson.devDependencies['webpack']?.startsWith('^5')) { + task = removeDependenciesFromPackageJson(tree, [], packages); + await formatFiles(tree); + } + + return task; +} diff --git a/packages/web/src/utils/config.ts b/packages/web/src/utils/config.ts index f5679b08dd..6541d35b70 100644 --- a/packages/web/src/utils/config.ts +++ b/packages/web/src/utils/config.ts @@ -1,7 +1,10 @@ import { join } from 'path'; +import * as webpack from 'webpack'; +import { Configuration, WebpackPluginInstance } from 'webpack'; import { LicenseWebpackPlugin } from 'license-webpack-plugin'; import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'; - +import * as CopyWebpackPlugin from 'copy-webpack-plugin'; +import * as TerserWebpackPlugin from 'terser-webpack-plugin'; import { AssetGlobPattern, BuildBuilderOptions } from './types'; import { getOutputHashFormat } from './hash-format'; import CircularDependencyPlugin = require('circular-dependency-plugin'); @@ -12,10 +15,6 @@ const IGNORED_WEBPACK_WARNINGS = [ /could not find any license/i, ]; -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Configuration = any; -type WebpackPluginInstance = any; - export function getBaseWebpackPartial( options: BuildBuilderOptions, esm?: boolean, @@ -23,10 +22,6 @@ export function getBaseWebpackPartial( emitDecoratorMetadata?: boolean, configuration?: string ): Configuration { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { webpack } = require('../webpack/entry'); - const { ProgressPlugin } = webpack; - const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx']; const mainFields = [...(esm ? ['es2015'] : []), 'module', 'main']; const hashFormat = getOutputHashFormat(options.outputHashing); @@ -45,14 +40,24 @@ export function getBaseWebpackPartial( entry: { main: [options.main], }, - devtool: options.sourceMap ? 'source-map' : false, + devtool: + options.sourceMap === 'hidden' + ? 'hidden-source-map' + : options.sourceMap + ? 'source-map' + : false, mode, output: { path: options.outputPath, filename, chunkFilename, + hashFunction: 'xxhash64', + // Disabled for performance + pathinfo: false, }, module: { + // Enabled for performance + unsafeCache: true, rules: [ { test: /\.([jt])sx?$/, @@ -94,11 +99,35 @@ export function getBaseWebpackPartial( poll: options.poll, }, stats: getStatsConfig(options), + ignoreWarnings: [ + (x) => + IGNORED_WEBPACK_WARNINGS.some((r) => + typeof x === 'string' ? r.test(x) : r.test(x.message) + ), + ], + experiments: { + cacheUnaffected: true, + }, }; if (isScriptOptimizeOn) { webpackConfig.optimization = { - minimizer: [createTerserPlugin(esm, !!options.sourceMap)], + sideEffects: false, + providedExports: false, + minimizer: [ + new TerserWebpackPlugin({ + parallel: true, + terserOptions: { + ecma: esm ? 2016 : 5, + safari10: true, + output: { + ascii_only: true, + comments: false, + webkit: true, + }, + }, + }), + ], runtimeChunk: true, }; } @@ -118,7 +147,7 @@ export function getBaseWebpackPartial( } if (options.progress) { - extraPlugins.push(new ProgressPlugin()); + extraPlugins.push(new webpack.ProgressPlugin()); } // TODO LicenseWebpackPlugin needs a PR for proper typing @@ -161,30 +190,7 @@ function getAliases(options: BuildBuilderOptions): { [key: string]: string } { ); } -// TODO Sourcemap and cache options have been removed from plugin. -// Investigate what this mgiht change in the build process -export function createTerserPlugin(esm: boolean, sourceMap: boolean) { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { TerserWebpackPlugin } = require('../webpack/entry'); - return new TerserWebpackPlugin({ - parallel: true, - terserOptions: { - ecma: esm ? 8 : 5, - safari10: true, - output: { - ascii_only: true, - comments: false, - webkit: true, - }, - }, - }); -} - -// TODO(jack): Update the typing with new version of webpack -- was returning Stats.ToStringOptions in webpack 4 -// The StatsOptions type needs to be exported from webpack -// PR: https://github.com/webpack/webpack/pull/12875 -function getStatsConfig(options: BuildBuilderOptions): any { - const { isWebpack5 } = require('../webpack/entry'); +function getStatsConfig(options: BuildBuilderOptions) { return { hash: true, timings: false, @@ -204,7 +210,6 @@ function getStatsConfig(options: BuildBuilderOptions): any { errorDetails: !!options.verbose, moduleTrace: !!options.verbose, usedExports: !!options.verbose, - warningsFilter: IGNORED_WEBPACK_WARNINGS, }; } @@ -240,9 +245,6 @@ function getClientEnvironment(mode) { } export function createCopyPlugin(assets: AssetGlobPattern[]) { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { CopyWebpackPlugin } = require('../webpack/entry'); - return new CopyWebpackPlugin({ patterns: assets.map((asset) => { return { diff --git a/packages/web/src/utils/devserver.config.ts b/packages/web/src/utils/devserver.config.ts index 01b2d36cc4..8fc2d43e42 100644 --- a/packages/web/src/utils/devserver.config.ts +++ b/packages/web/src/utils/devserver.config.ts @@ -1,8 +1,5 @@ import { logger } from '@nrwl/devkit'; import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server'; - -import * as open from 'open'; -import * as url from 'url'; import * as path from 'path'; import { getWebConfig } from './web.config'; @@ -18,7 +15,7 @@ export function getDevServerConfig( sourceRoot: string, buildOptions: WebBuildBuilderOptions, serveOptions: WebDevServerOptions -) { +): Partial { const webpackConfig = getWebConfig( workspaceRoot, projectRoot, @@ -33,10 +30,6 @@ export function getDevServerConfig( serveOptions, buildOptions ); - webpackConfig.plugins = [ - ...(webpackConfig.plugins || []), - getHmrPlugin(serveOptions), - ].filter(Boolean); return webpackConfig; } @@ -60,35 +53,30 @@ function getDevServerPartial( disableDotRule: true, htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'], }, - noInfo: true, onListening(server: any) { - // Depend on the info in the server for this function because the user might adjust the webpack config - const serverUrl = url.format({ - protocol: server.options.https ? 'https' : 'http', - hostname: server.hostname, - port: server.listeningApp.address().port, - pathname: buildServePath(buildOptions), - }); - - logger.info(`NX Web Development Server is listening at ${serverUrl}`); - if (options.open) { - open(serverUrl); - } + logger.info( + `NX Web Development Server is listening at ${ + server.options.https ? 'https' : 'http' + }://${server.options.host}:${server.options.port}${buildServePath( + buildOptions + )}` + ); }, - stats: false, + open: options.open, + static: false, compress: scriptsOptimization || stylesOptimization, https: options.ssl, - overlay: { - errors: !(scriptsOptimization || stylesOptimization), - warnings: false, + devMiddleware: { + publicPath: servePath, + stats: false, }, - watchOptions: { - poll: buildOptions.poll, + client: { + webSocketURL: options.publicHost, + overlay: { + errors: !(scriptsOptimization || stylesOptimization), + warnings: false, + }, }, - public: options.publicHost, - publicPath: servePath, - contentBase: false, - allowedHosts: [], liveReload: options.hmr ? false : options.liveReload, // disable liveReload if hmr is enabled hot: options.hmr, }; @@ -119,11 +107,3 @@ function getProxyConfig(root: string, options: WebDevServerOptions) { const proxyPath = path.resolve(root, options.proxyConfig as string); return require(proxyPath); } - -function getHmrPlugin(options: WebDevServerOptions) { - // TODO(jack): Remove in Nx 13 - const { - webpack: { HotModuleReplacementPlugin }, - } = require('../webpack/entry'); - return options.hmr && new HotModuleReplacementPlugin(); -} diff --git a/packages/web/src/utils/normalize.ts b/packages/web/src/utils/normalize.ts index fcbff4af70..87a8c06c2e 100644 --- a/packages/web/src/utils/normalize.ts +++ b/packages/web/src/utils/normalize.ts @@ -109,15 +109,6 @@ export function normalizeWebBuildOptions( styles: options.optimization, } : options.optimization, - sourceMap: - typeof options.sourceMap === 'object' - ? options.sourceMap - : { - scripts: options.sourceMap, - styles: options.sourceMap, - hidden: false, - vendors: false, - }, polyfills: options.polyfills ? resolve(root, options.polyfills) : undefined, es2015Polyfills: options.es2015Polyfills ? resolve(root, options.es2015Polyfills) @@ -130,7 +121,6 @@ export function convertBuildOptions(buildOptions: WebBuildBuilderOptions): any { return { ...options, buildOptimizer: options.optimization, - aot: false, forkTypeChecker: false, lazyModules: [] as string[], }; diff --git a/packages/web/src/utils/sass.ts b/packages/web/src/utils/sass.ts deleted file mode 100644 index 7130da51e4..0000000000 --- a/packages/web/src/utils/sass.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { logger, stripIndents } from '@nrwl/devkit'; - -export let sassImplementation: {} | undefined; - -// TODO(jack): Remove in Nx 13 -try { - sassImplementation = require('node-sass'); - logger.warn(stripIndents` - 'node-sass' has been deprecated and may not be supported in the future. - To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'. - `); -} catch { - sassImplementation = require('sass'); -} diff --git a/packages/web/src/utils/third-party/.eslintrc.json b/packages/web/src/utils/third-party/.eslintrc.json deleted file mode 100644 index 90d8894e28..0000000000 --- a/packages/web/src/utils/third-party/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rules": {} -} diff --git a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/browser.ts b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/browser.ts index 3a5d275c25..1611929276 100644 --- a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/browser.ts +++ b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/browser.ts @@ -7,11 +7,6 @@ */ import { LicenseWebpackPlugin } from 'license-webpack-plugin'; import { WebpackConfigOptions } from '../build-options'; -import { - getSourceMapDevTool, - isPolyfillsEntry, - normalizeExtraEntryPoints, -} from './utils'; const SubresourceIntegrityPlugin = require('webpack-subresource-integrity'); @@ -19,29 +14,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions) { const { buildOptions } = wco; const extraPlugins = []; - const { isWebpack5 } = require('../../../../../webpack/entry'); - - let isEval = false; - const { styles: stylesOptimization, scripts: scriptsOptimization } = - buildOptions.optimization; - const { - styles: stylesSourceMap, - scripts: scriptsSourceMap, - hidden: hiddenSourceMap, - vendor: vendorSourceMap, - } = buildOptions.sourceMap; - - // See https://webpack.js.org/configuration/devtool/ for sourcemap types. - if ( - (stylesSourceMap || scriptsSourceMap) && - buildOptions.evalSourceMap && - !stylesOptimization && - !scriptsOptimization - ) { - // Produce eval sourcemaps for development with serve, which are faster. - isEval = true; - } - if (buildOptions.subresourceIntegrity) { extraPlugins.push( new SubresourceIntegrityPlugin({ @@ -63,24 +35,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions) { ); } - if (!isEval && (scriptsSourceMap || stylesSourceMap)) { - extraPlugins.push( - getSourceMapDevTool( - !!scriptsSourceMap, - !!stylesSourceMap, - hiddenSourceMap, - vendorSourceMap - ) - ); - } - - const globalStylesBundleNames = normalizeExtraEntryPoints( - buildOptions.styles, - 'styles' - ).map((style) => style.bundleName); - return { - devtool: isEval ? 'eval' : false, resolve: { mainFields: [ ...(wco.supportES2015 ? ['es2015'] : []), @@ -112,30 +67,11 @@ export function getBrowserConfig(wco: WebpackConfigOptions) { priority: 5, }, vendors: false, - // TODO(jack): Support both 4 and 5 vendor: !!buildOptions.vendorChunk && { name: 'vendor', - chunks: isWebpack5 ? (chunk) => chunk.name === 'main' : 'initial', + chunks: (chunk) => chunk.name === 'main', enforce: true, - test: isWebpack5 - ? /[\\/]node_modules[\\/]/ - : ( - module: { nameForCondition?: Function }, - chunks: Array<{ name: string }> - ) => { - const moduleName = module.nameForCondition - ? module.nameForCondition() - : ''; - - return ( - /[\\/]node_modules[\\/]/.test(moduleName) && - !chunks.some( - ({ name }) => - isPolyfillsEntry(name) || - globalStylesBundleNames.includes(name) - ) - ); - }, + test: /[\\/]node_modules[\\/]/, }, }, }, diff --git a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/common.ts b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/common.ts index 9200f5b325..7466c01290 100644 --- a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/common.ts +++ b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/common.ts @@ -7,13 +7,12 @@ */ import * as path from 'path'; import { ScriptTarget } from 'typescript'; +import * as webpack from 'webpack'; +import { Compiler, Configuration } from 'webpack'; import { ExtraEntryPoint } from '../../../browser/schema'; import { BuildBrowserFeatures, fullDifferential } from '../../../utils'; import { manglingDisabled } from '../../../utils/mangle-options'; -import { BundleBudgetPlugin } from '../../plugins/bundle-budget'; -import { CleanCssWebpackPlugin } from '../../plugins/cleancss-webpack-plugin'; -import { NamedLazyChunksPlugin } from '../../plugins/named-chunks-plugin'; import { ScriptsWebpackPlugin } from '../../plugins/scripts-webpack-plugin'; import { findAllNodeModules, findUp } from '../../utilities/find-up'; import { WebpackConfigOptions } from '../build-options'; @@ -22,6 +21,7 @@ import { getOutputHashFormat, normalizeExtraEntryPoints, } from './utils'; +import CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); export const GLOBAL_DEFS_FOR_TERSER = { ngDevMode: false, @@ -40,18 +40,8 @@ const TerserPlugin = require('terser-webpack-plugin'); // tslint:disable-next-line:no-any const g: any = typeof global !== 'undefined' ? global : {}; -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Configuration = any; -type Compiler = any; - // tslint:disable-next-line:no-big-function export function getCommonConfig(wco: WebpackConfigOptions): Configuration { - // TODO(jack): Remove this in Nx 13 and go back to proper types - const { - webpack, - webpackSources, - isWebpack5, - } = require('../../../../../webpack/entry'); const { ContextReplacementPlugin, debug } = webpack; const { root, projectRoot, sourceRoot, buildOptions, tsConfig } = wco; @@ -254,18 +244,13 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { compilation.getStats().toJson('verbose') ); compilation.assets[`stats${targetInFileName}.json`] = - new webpackSources.RawSource(data); + new webpack.sources.RawSource(data); }); } })() ); } - //TODO(jack): Enable for webpack 5 - if (!isWebpack5 && buildOptions.namedChunks) { - extraPlugins.push(new NamedLazyChunksPlugin()); - } - let sourceMapUseRule; if ((scriptsSourceMap || stylesSourceMap) && vendorSourceMap) { sourceMapUseRule = { @@ -299,10 +284,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { const extraMinimizers = []; if (stylesOptimization) { extraMinimizers.push( - new CleanCssWebpackPlugin({ - sourceMap: stylesSourceMap, - // component styles retain their original file name - test: (file) => /\.(?:css|scss|sass|less|styl)$/.test(file), + new CssMinimizerPlugin({ + test: /\.(?:css|scss|sass|less|styl)$/, }) ); } @@ -378,44 +361,17 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { }; extraMinimizers.push( - new TerserPlugin( - !isWebpack5 - ? { - sourceMap: scriptsSourceMap, - parallel: true, - cache: true, - chunkFilter: (chunk: any) => - !globalScriptsByBundleName.some( - (s) => s.bundleName === chunk.name - ), - terserOptions, - } - : { terserOptions } - ), + new TerserPlugin({ terserOptions }), // Script bundles are fully optimized here in one step since they are never downleveled. // They are shared between ES2015 & ES5 outputs so must support ES5. - new TerserPlugin( - !isWebpack5 - ? { - sourceMap: scriptsSourceMap, - parallel: true, - cache: true, - chunkFilter: (chunk: any) => - globalScriptsByBundleName.some( - (s) => s.bundleName === chunk.name - ), - terserOptions: es5TerserOptions, - } - : { terserOptions: es5TerserOptions } - ) + new TerserPlugin({ terserOptions: es5TerserOptions }) ); } return { mode: scriptsOptimization || stylesOptimization ? 'production' : 'development', - devtool: false, profile: buildOptions.statsJson, resolve: { extensions: ['.ts', '.tsx', '.mjs', '.js'], @@ -429,7 +385,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { context: projectRoot, entry: entryPoints, output: { - ...(isWebpack5 ? {} : { futureEmitAssets: true }), path: path.resolve(root, buildOptions.outputPath as string), publicPath: buildOptions.deployUrl, }, @@ -473,24 +428,9 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { ], }, optimization: { - ...(isWebpack5 - ? { - emitOnErrors: false, - moduleIds: 'deterministic', - minimizer: [ - new webpack.ids.HashedModuleIdsPlugin(), - ...extraMinimizers, - ], - } - : { - noEmitOnErrors: true, - minimizer: [ - // TODO(jack): Enable these for webpack 5 - new webpack.HashedModuleIdsPlugin(), - new BundleBudgetPlugin({ budgets: buildOptions.budgets }), - ...extraMinimizers, - ], - }), + emitOnErrors: false, + moduleIds: 'deterministic', + minimizer: [new webpack.ids.HashedModuleIdsPlugin(), ...extraMinimizers], }, plugins: [ // Always replace the context for the System.import in angular/core to prevent warnings. diff --git a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/styles.ts b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/styles.ts index 11bf09fd88..5fdd720773 100644 --- a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/styles.ts +++ b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/styles.ts @@ -7,23 +7,21 @@ */ import * as path from 'path'; +import { RuleSetRule } from 'webpack'; + import { PostcssCliResources, RawCssLoader, RemoveHashPlugin, - SuppressExtractedTextChunksWebpackPlugin, } from '../../plugins/webpack'; import { BuildOptions } from '../build-options'; import { getOutputHashFormat, normalizeExtraEntryPoints } from './utils'; import { RemoveEmptyScriptsPlugin } from '../../plugins/remove-empty-scripts-plugin'; -import { sassImplementation } from '../../../../sass'; +import MiniCssExtractPlugin = require('mini-css-extract-plugin'); const autoprefixer = require('autoprefixer'); const postcssImports = require('postcss-import'); -// TODO(jack): Remove in Nx 13 -type RuleSetRule = any; - /** * Enumerate loaders and their dependencies from this file to let the dependency validator * know they are used. @@ -43,12 +41,6 @@ export function getStylesConfig( buildOptions: BuildOptions, includePaths: string[] ) { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { - isWebpack5, - MiniCssExtractPlugin, - } = require('../../../../../webpack/entry'); - const entryPoints: { [key: string]: string[] } = {}; const globalStylePaths: string[] = []; const extraPlugins = []; @@ -142,7 +134,7 @@ export function getStylesConfig( { loader: require.resolve('sass-loader'), options: { - implementation: sassImplementation, + implementation: require('sass'), sourceMap: cssSourceMap, sassOptions: { fiber: false, @@ -245,11 +237,11 @@ export function getStylesConfig( if (buildOptions.extractCss) { extraPlugins.push( // extract global css from js files into own css file - new MiniCssExtractPlugin({ filename: `[name]${hashFormat.extract}.css` }), + new MiniCssExtractPlugin({ + filename: `[name]${hashFormat.extract}.css`, + }), // suppress empty .js files in css only entry points - isWebpack5 - ? new RemoveEmptyScriptsPlugin() - : new SuppressExtractedTextChunksWebpackPlugin() + new RemoveEmptyScriptsPlugin() ); } diff --git a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/utils.ts b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/utils.ts index ed29f2f0ae..594ea16e8f 100644 --- a/packages/web/src/utils/third-party/cli-files/models/webpack-configs/utils.ts +++ b/packages/web/src/utils/third-party/cli-files/models/webpack-configs/utils.ts @@ -81,40 +81,6 @@ export function normalizeExtraEntryPoints( }); } -export function getSourceMapDevTool( - scriptsSourceMap: boolean, - stylesSourceMap: boolean, - hiddenSourceMap = false, - vendorSourceMap = false -) { - // TODO(jack): Remove in Nx 13 - const { - webpack: { SourceMapDevToolPlugin }, - } = require('../../../../../webpack/entry'); - - const include = []; - if (scriptsSourceMap) { - include.push(/js$/); - } - - if (stylesSourceMap) { - include.push(/css$/); - } - - return new SourceMapDevToolPlugin({ - filename: '[file].map', - include, - exclude: vendorSourceMap ? [] : ['vendor'], - // We want to set sourceRoot to `webpack:///` for non - // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser - // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently - // there is no way to set the 'webRoot' - sourceRoot: 'webpack:///', - moduleFilenameTemplate: '[resource-path]', - append: hiddenSourceMap ? false : undefined, - }); -} - /** * Returns an ES version file suffix to differentiate between various builds. */ @@ -126,7 +92,3 @@ export function getEsVersionForFileName( ? `-${ScriptTarget[scriptTargetOverride].toLowerCase()}` : ''; } - -export function isPolyfillsEntry(name: string) { - return name === 'polyfills' || name === 'polyfills-es5'; -} diff --git a/packages/web/src/utils/third-party/cli-files/plugins/bundle-budget.ts b/packages/web/src/utils/third-party/cli-files/plugins/bundle-budget.ts deleted file mode 100644 index 01f5f5ec03..0000000000 --- a/packages/web/src/utils/third-party/cli-files/plugins/bundle-budget.ts +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import { Budget, Type } from '../../browser/schema'; -import { - Size, - calculateBytes, - calculateSizes, -} from '../utilities/bundle-calculator'; -import { formatSize } from '../utilities/stats'; - -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Compilation = any; -type Compiler = any; - -interface Thresholds { - maximumWarning?: number; - maximumError?: number; - minimumWarning?: number; - minimumError?: number; - warningLow?: number; - warningHigh?: number; - errorLow?: number; - errorHigh?: number; -} - -export interface BundleBudgetPluginOptions { - budgets: Budget[]; -} - -export class BundleBudgetPlugin { - constructor(private options: BundleBudgetPluginOptions) {} - - apply(compiler: Compiler): void { - const { budgets } = this.options; - - if (!budgets || budgets.length === 0) { - return; - } - - compiler.hooks.compilation.tap( - 'BundleBudgetPlugin', - (compilation: Compilation) => { - compilation.hooks.afterOptimizeChunkAssets.tap( - 'BundleBudgetPlugin', - () => { - // In AOT compilations component styles get processed in child compilations. - // tslint:disable-next-line: no-any - const parentCompilation = (compilation.compiler as any) - .parentCompilation; - if (!parentCompilation) { - return; - } - - const filteredBudgets = budgets.filter( - (budget) => budget.type === Type.AnyComponentStyle - ); - this.runChecks(filteredBudgets, compilation); - } - ); - } - ); - - compiler.hooks.afterEmit.tap( - 'BundleBudgetPlugin', - (compilation: Compilation) => { - const filteredBudgets = budgets.filter( - (budget) => budget.type !== Type.AnyComponentStyle - ); - this.runChecks(filteredBudgets, compilation); - } - ); - } - - private checkMinimum( - threshold: number | undefined, - size: Size, - // TODO(jack): Remove this in Nx 13 and go back to proper imports - messages: any[] // WebpackError[] - ) { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { webpack } = require('../../../../webpack/entry'); - if (threshold) { - if (threshold > size.size) { - const sizeDifference = formatSize(threshold - size.size); - messages.push( - new webpack.WebpackError( - `budgets, minimum exceeded for ${size.label}. ` + - `Budget ${formatSize( - threshold - )} was not reached by ${sizeDifference}.` - ) - ); - } - } - } - - private checkMaximum( - threshold: number | undefined, - size: Size, - // TODO(jack): Remove this in Nx 13 and go back to proper imports - messages: any[] // WebpackError[] - ) { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { webpack } = require('../../../../webpack/entry'); - - if (threshold) { - if (threshold < size.size) { - const sizeDifference = formatSize(size.size - threshold); - messages.push( - new webpack.WebpackError( - `budgets, maximum exceeded for ${size.label}. ` + - `Budget ${formatSize( - threshold - )} was exceeded by ${sizeDifference}.` - ) - ); - } - } - } - - private calculate(budget: Budget): Thresholds { - const thresholds: Thresholds = {}; - if (budget.maximumWarning) { - thresholds.maximumWarning = calculateBytes( - budget.maximumWarning, - budget.baseline, - 1 - ); - } - - if (budget.maximumError) { - thresholds.maximumError = calculateBytes( - budget.maximumError, - budget.baseline, - 1 - ); - } - - if (budget.minimumWarning) { - thresholds.minimumWarning = calculateBytes( - budget.minimumWarning, - budget.baseline, - -1 - ); - } - - if (budget.minimumError) { - thresholds.minimumError = calculateBytes( - budget.minimumError, - budget.baseline, - -1 - ); - } - - if (budget.warning) { - thresholds.warningLow = calculateBytes( - budget.warning, - budget.baseline, - -1 - ); - } - - if (budget.warning) { - thresholds.warningHigh = calculateBytes( - budget.warning, - budget.baseline, - 1 - ); - } - - if (budget.error) { - thresholds.errorLow = calculateBytes(budget.error, budget.baseline, -1); - } - - if (budget.error) { - thresholds.errorHigh = calculateBytes(budget.error, budget.baseline, 1); - } - - return thresholds; - } - - private runChecks(budgets: Budget[], compilation: Compilation) { - budgets - .map((budget) => ({ - budget, - thresholds: this.calculate(budget), - sizes: calculateSizes(budget, compilation), - })) - .forEach((budgetCheck) => { - budgetCheck.sizes.forEach((size) => { - this.checkMaximum( - budgetCheck.thresholds.maximumWarning, - size, - compilation.warnings - ); - this.checkMaximum( - budgetCheck.thresholds.maximumError, - size, - compilation.errors - ); - this.checkMinimum( - budgetCheck.thresholds.minimumWarning, - size, - compilation.warnings - ); - this.checkMinimum( - budgetCheck.thresholds.minimumError, - size, - compilation.errors - ); - this.checkMinimum( - budgetCheck.thresholds.warningLow, - size, - compilation.warnings - ); - this.checkMaximum( - budgetCheck.thresholds.warningHigh, - size, - compilation.warnings - ); - this.checkMinimum( - budgetCheck.thresholds.errorLow, - size, - compilation.errors - ); - this.checkMaximum( - budgetCheck.thresholds.errorHigh, - size, - compilation.errors - ); - }); - }); - } -} diff --git a/packages/web/src/utils/third-party/cli-files/plugins/cleancss-webpack-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/cleancss-webpack-plugin.ts deleted file mode 100644 index 0c70f3c8a1..0000000000 --- a/packages/web/src/utils/third-party/cli-files/plugins/cleancss-webpack-plugin.ts +++ /dev/null @@ -1,151 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import * as CleanCSS from 'clean-css'; -import { RawSourceMap } from 'source-map'; - -export interface CleanCssWebpackPluginOptions { - sourceMap: boolean; - test: (file: string) => boolean; -} - -// TODO(jack): Remove this entire plugin in Nx 13 (once we deprecate webpack 4) -type Compiler = any; -type Compilation = any; -type Chunk = any; - -function hook( - compiler: Compiler, - action: (compilation: Compilation, chunks: Chunk[]) => Promise -) { - compiler.hooks.compilation.tap( - 'cleancss-webpack-plugin', - (compilation: Compilation) => { - compilation.hooks.optimizeChunkAssets.tapPromise( - 'cleancss-webpack-plugin', - (chunks) => action(compilation, chunks) - ); - } - ); -} - -export class CleanCssWebpackPlugin { - private readonly _options: CleanCssWebpackPluginOptions; - - constructor(options: Partial) { - this._options = { - sourceMap: false, - test: (file) => file.endsWith('.css'), - ...options, - }; - } - - apply(compiler: Compiler): void { - // TODO(jack): Remove this in Nx 13 and go back to proper types - const { webpackSources, webpack } = require('../../../../webpack/entry'); - const { WebpackError } = webpack; - - hook(compiler, (compilation, chunks) => { - // TODO(jack): Remove in Nx 13 - const { isWebpack5 } = require('../../../../webpack/entry'); - - const cleancss = new CleanCSS({ - compatibility: 'ie9', - level: { - 2: { - skipProperties: [ - 'transition', // Fixes #12408 - 'font', // Fixes #9648 - ], - }, - }, - inline: false, - returnPromise: true, - sourceMap: this._options.sourceMap, - }); - - const files: string[] = [...compilation.additionalChunkAssets]; - - chunks.forEach((chunk) => { - if (isWebpack5) { - if (chunk.files && chunk.files.size > 0) { - const xs: any = Array.from(chunk.files.values()); - files.push(...xs); - } - } else { - if (chunk.files && chunk.files.length > 0) { - files.push(...chunk.files); - } - } - }); - - const actions = files - .filter((file) => this._options.test(file)) - .map(async (file) => { - const asset = compilation.assets[file]; - if (!asset) { - return; - } - - let content: string | Buffer; - let map: RawSourceMap; - if (this._options.sourceMap && asset.sourceAndMap) { - const sourceAndMap = asset.sourceAndMap(); - content = sourceAndMap.source; - map = sourceAndMap.map as RawSourceMap; - } else { - content = asset.source(); - } - - if (content.length === 0) { - return; - } - - const output = await cleancss.minify(content, map); - - let hasWarnings = false; - if (output.warnings && output.warnings.length > 0) { - compilation.warnings.push(...output.warnings); - hasWarnings = true; - } - - if (output.errors && output.errors.length > 0) { - output.errors.forEach((error: string) => - compilation.errors.push(new WebpackError(error)) - ); - - return; - } - - // generally means invalid syntax so bail - if (hasWarnings && output.stats.minifiedSize === 0) { - return; - } - - let newSource; - if (output.sourceMap) { - newSource = new webpackSources.SourceMapSource( - output.styles, - file, - // tslint:disable-next-line: no-any - output.sourceMap.toString() as any, - content as string, - // TODO This map is not mapping as expected... - // @ts-ignore - map - ); - } else { - newSource = new webpackSources.RawSource(output.styles); - } - - compilation.assets[file] = newSource; - }); - - return Promise.all(actions).then(() => undefined); - }); - } -} diff --git a/packages/web/src/utils/third-party/cli-files/plugins/index-html-webpack-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/index-html-webpack-plugin.ts index 8853c52b40..b918a008ee 100644 --- a/packages/web/src/utils/third-party/cli-files/plugins/index-html-webpack-plugin.ts +++ b/packages/web/src/utils/third-party/cli-files/plugins/index-html-webpack-plugin.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ - +import * as webpack from 'webpack'; import { basename, dirname, extname } from 'path'; import { FileInfo } from '../utils/index-file/augment-index-html'; import { @@ -27,9 +27,8 @@ export interface IndexHtmlWebpackPluginOptions type Compiler = any; const PLUGIN_NAME = 'index-html-webpack-plugin'; -export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator { - webpack: any; +export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator { private _compilation: any | undefined; get compilation(): any { @@ -42,8 +41,6 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator { constructor(readonly options: IndexHtmlWebpackPluginOptions) { super(options); - const { webpack } = require('../../../../webpack/entry'); - this.webpack = webpack; } apply(compiler: Compiler) { @@ -52,7 +49,7 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator { compilation.hooks.processAssets.tapPromise( { name: PLUGIN_NAME, - stage: this.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE + 1, + stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE + 1, }, callback ); @@ -107,7 +104,7 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator { lang: this.options.lang, }); - assets[this.options.outputPath] = new this.webpack.sources.RawSource( + assets[this.options.outputPath] = new webpack.sources.RawSource( content ); diff --git a/packages/web/src/utils/third-party/cli-files/plugins/legacy-index-html-webpack-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/legacy-index-html-webpack-plugin.ts deleted file mode 100644 index 81eb92cb8f..0000000000 --- a/packages/web/src/utils/third-party/cli-files/plugins/legacy-index-html-webpack-plugin.ts +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import * as path from 'path'; -import { - CrossOriginValue, - FileInfo, - augmentIndexHtml, -} from '../utilities/index-file/augment-index-html'; -import { IndexHtmlTransform } from '../utilities/index-file/write-index-html'; -import { stripBom } from '../utilities/strip-bom'; -import { interpolateEnvironmentVariablesToIndex } from '../../../interpolate-env-variables-to-index'; - -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Compiler = any; -type Compilation = any; - -export interface IndexHtmlWebpackPluginOptions { - input: string; - output: string; - baseHref?: string; - entrypoints: string[]; - deployUrl?: string; - sri: boolean; - noModuleEntrypoints: string[]; - moduleEntrypoints: string[]; - postTransform?: IndexHtmlTransform; - crossOrigin?: CrossOriginValue; -} - -function readFile(filename: string, compilation: Compilation): Promise { - return new Promise((resolve, reject) => { - compilation.inputFileSystem.readFile( - filename, - (err: Error, data: Buffer) => { - if (err) { - reject(err); - - return; - } - - resolve(stripBom(data.toString())); - } - ); - }); -} - -export class LegacyIndexHtmlWebpackPlugin { - private _options: IndexHtmlWebpackPluginOptions; - - constructor(options?: Partial) { - this._options = { - input: 'index.html', - output: 'index.html', - entrypoints: ['polyfills', 'main'], - noModuleEntrypoints: [], - moduleEntrypoints: [], - sri: false, - ...options, - }; - } - - apply(compiler: Compiler) { - // TODO(jack): Remove this in Nx 13 and go back to proper types - const { webpackSources, webpack } = require('../../../../webpack/entry'); - - compiler.hooks.emit.tapPromise( - 'index-html-webpack-plugin', - async (compilation) => { - // Get input html file - const inputContent = await readFile(this._options.input, compilation); - compilation.fileDependencies.add(this._options.input); - - // Get all files for selected entrypoints - const files: FileInfo[] = []; - const noModuleFiles: FileInfo[] = []; - const moduleFiles: FileInfo[] = []; - - for (const [entryName, entrypoint] of compilation.entrypoints) { - const entryFiles: FileInfo[] = ( - (entrypoint && entrypoint.getFiles()) || - [] - ).map( - (f: string): FileInfo => ({ - name: entryName, - file: f, - extension: path.extname(f), - }) - ); - - if (this._options.noModuleEntrypoints.includes(entryName)) { - noModuleFiles.push(...entryFiles); - } else if (this._options.moduleEntrypoints.includes(entryName)) { - moduleFiles.push(...entryFiles); - } else { - files.push(...entryFiles); - } - } - - // TODO: the source() method can return a Buffer. - // This fails to handle that case - const loadOutputFile = (name: string) => - compilation.assets[name].source() as string; // This will break if Buffer _generateSriAttributes in augment-index.html.ts - - let indexSource = await augmentIndexHtml({ - input: this._options.input, - inputContent: interpolateEnvironmentVariablesToIndex( - inputContent, - this._options.deployUrl - ), - baseHref: this._options.baseHref, - deployUrl: this._options.deployUrl, - sri: this._options.sri, - crossOrigin: this._options.crossOrigin, - files, - noModuleFiles, - loadOutputFile, - moduleFiles, - entrypoints: this._options.entrypoints, - }); - - if (this._options.postTransform) { - indexSource = await this._options.postTransform(indexSource); - } - - // Add to compilation assets - compilation.assets[this._options.output] = new webpackSources.RawSource( - indexSource - ) as never; //TODO This is a hack as RawSource lacks Buffer, which is now in the webpack Source object - } - ); - } -} diff --git a/packages/web/src/utils/third-party/cli-files/plugins/postcss-cli-resources.ts b/packages/web/src/utils/third-party/cli-files/plugins/postcss-cli-resources.ts index a83f00bc55..696d79f154 100644 --- a/packages/web/src/utils/third-party/cli-files/plugins/postcss-cli-resources.ts +++ b/packages/web/src/utils/third-party/cli-files/plugins/postcss-cli-resources.ts @@ -9,7 +9,7 @@ import { interpolateName } from 'loader-utils'; import * as path from 'path'; import type { Declaration } from 'postcss'; import * as url from 'url'; -import * as webpack from 'webpack'; +import { LoaderContext } from 'webpack'; function wrapUrl(url: string): string { let wrappedUrl; @@ -21,26 +21,28 @@ function wrapUrl(url: string): string { } return `url(${wrappedUrl})`; } + export interface PostcssCliResourcesOptions { baseHref?: string; deployUrl?: string; resourcesOutputPath?: string; rebaseRootRelative?: boolean; filename: string; - loader: webpack.loader.LoaderContext; + loader: LoaderContext; } async function resolve( file: string, base: string, - resolver: (file: string, base: string) => Promise -): Promise { + resolver: (file: string, base: string) => Promise +): Promise { try { return await resolver(`./${file}`, base); } catch { return resolver(file, base); } } + module.exports.postcss = true; export default (options: PostcssCliResourcesOptions) => { const { @@ -96,7 +98,7 @@ export default (options: PostcssCliResourcesOptions) => { } const { pathname, hash, search } = url.parse(inputUrl.replace(/\\/g, '/')); const resolver = (file: string, base: string) => - new Promise((resolve, reject) => { + new Promise((resolve, reject) => { loader.resolve(base, decodeURI(file), (err, result) => { if (err) { reject(err); @@ -106,31 +108,29 @@ export default (options: PostcssCliResourcesOptions) => { }); }); const result = await resolve(pathname as string, context, resolver); - return new Promise((resolve, reject) => { - loader.fs.readFile(result, (err: Error, content: Buffer) => { + return new Promise((resolve, reject) => { + loader.fs.readFile(result as string, (err: Error, content: Buffer) => { if (err) { reject(err); return; } let outputPath = interpolateName( - { resourcePath: result } as webpack.loader.LoaderContext, + { resourcePath: result } as LoaderContext, filename, { content } ); if (resourcesOutputPath) { outputPath = path.posix.join(resourcesOutputPath, outputPath); } - loader.addDependency(result); + loader.addDependency(result as string); loader.emitFile(outputPath, content, undefined); let outputUrl = outputPath.replace(/\\/g, '/'); if (hash || search) { outputUrl = url.format({ pathname: outputUrl, hash, search }); } - if ( - deployUrl && - loader.loaders[loader.loaderIndex].options.ident !== 'extracted' - ) { + const loaderOptions: any = loader.loaders[loader.loaderIndex].options; + if (deployUrl && loaderOptions.ident !== 'extracted') { outputUrl = url.resolve(deployUrl, outputUrl); } resourceCache.set(cacheKey, outputUrl); @@ -174,9 +174,7 @@ export default (options: PostcssCliResourcesOptions) => { try { processedUrl = await process(originalUrl, context, resourceCache); } catch (err) { - loader.emitError( - decl.error(err.message, { word: originalUrl }).toString() - ); + loader.emitError(decl.error(err.message, { word: originalUrl })); continue; } if (lastIndex < match.index) { diff --git a/packages/web/src/utils/third-party/cli-files/plugins/remove-hash-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/remove-hash-plugin.ts index ee91011ae2..31f957d171 100644 --- a/packages/web/src/utils/third-party/cli-files/plugins/remove-hash-plugin.ts +++ b/packages/web/src/utils/third-party/cli-files/plugins/remove-hash-plugin.ts @@ -5,10 +5,8 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import { compilation } from 'webpack'; import { HashFormat } from '../models/webpack-configs/utils'; -// TODO(jack): Remove this in Nx 13 and go back to proper types type Compiler = any; export interface RemoveHashPluginOptions { @@ -22,12 +20,7 @@ export class RemoveHashPlugin { apply(compiler: Compiler): void { compiler.hooks.compilation.tap('remove-hash-plugin', (compilation) => { // MainTemplate is slated to be removed in Webpack 6 - const mainTemplate = - compilation.mainTemplate as compilation.MainTemplate & { - hooks: compilation.CompilationHooks; - }; - - mainTemplate.hooks.assetPath.tap( + compilation.mainTemplate.hooks.assetPath.tap( 'remove-hash-plugin', (path: string, data: { chunk?: { name: string } }) => { const chunkName = data.chunk && data.chunk.name; diff --git a/packages/web/src/utils/third-party/cli-files/plugins/scripts-webpack-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/scripts-webpack-plugin.ts index c790629fbb..44e9bee5c2 100644 --- a/packages/web/src/utils/third-party/cli-files/plugins/scripts-webpack-plugin.ts +++ b/packages/web/src/utils/third-party/cli-files/plugins/scripts-webpack-plugin.ts @@ -17,14 +17,18 @@ */ import { interpolateName } from 'loader-utils'; import * as path from 'path'; +import { Compiler } from 'webpack'; +import { + CachedSource, + ConcatSource, + OriginalSource, + RawSource, + Source, +} from 'webpack-sources'; const Chunk = require('webpack/lib/Chunk'); const EntryPoint = require('webpack/lib/Entrypoint'); -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Compiler = any; -type Source = any; - export interface ScriptsWebpackPluginOptions { name: string; sourceMap: boolean; @@ -35,9 +39,7 @@ export interface ScriptsWebpackPluginOptions { interface ScriptOutput { filename: string; - - // TODO(jack): This should be CachedSource from 'webpack-sources' fix in Nx 13 - source: any; + source: Source; } function addDependencies(compilation: any, scripts: string[]): void { @@ -104,9 +106,6 @@ export class ScriptsWebpackPlugin { } apply(compiler: Compiler): void { - // TODO(jack): Remove this in Nx 13 and go back to proper types - const { webpackSources } = require('../../../../webpack/entry'); - if (!this.options.scripts || this.options.scripts.length === 0) { return; } @@ -147,12 +146,9 @@ export class ScriptsWebpackPlugin { if (this.options.basePath) { adjustedPath = path.relative(this.options.basePath, fullPath); } - source = new webpackSources.OriginalSource( - content, - adjustedPath - ); + source = new OriginalSource(content, adjustedPath); } else { - source = new webpackSources.RawSource(content); + source = new RawSource(content); } resolve(source); @@ -163,13 +159,13 @@ export class ScriptsWebpackPlugin { Promise.all(sourceGetters) .then((sources) => { - const concatSource = new webpackSources.ConcatSource(); + const concatSource = new ConcatSource(); sources.forEach((source) => { concatSource.add(source); concatSource.add('\n;'); }); - const combinedSource = new webpackSources.CachedSource(concatSource); + const combinedSource = new CachedSource(concatSource); const filename = interpolateName( { resourcePath: 'scripts.js' }, this.options.filename as string, diff --git a/packages/web/src/utils/third-party/cli-files/plugins/suppress-entry-chunks-webpack-plugin.ts b/packages/web/src/utils/third-party/cli-files/plugins/suppress-entry-chunks-webpack-plugin.ts deleted file mode 100644 index f1cf2b1686..0000000000 --- a/packages/web/src/utils/third-party/cli-files/plugins/suppress-entry-chunks-webpack-plugin.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -// tslint:disable -// TODO: cleanup this file, it's copied as is from Angular CLI. - -// Remove .js files from entry points consisting entirely of .css|scss|sass|less|styl. -// To be used together with ExtractTextPlugin. - -export class SuppressExtractedTextChunksWebpackPlugin { - constructor() {} - - apply(compiler: any): void { - compiler.hooks.compilation.tap( - 'SuppressExtractedTextChunks', - (compilation: any) => { - // find which chunks have css only entry points - const cssOnlyChunks: string[] = []; - const entryPoints = compilation.options.entry; - // determine which entry points are composed entirely of css files - for (let entryPoint of Object.keys(entryPoints)) { - let entryFiles: string[] | string = entryPoints[entryPoint]; - // when type of entryFiles is not array, make it as an array - entryFiles = entryFiles instanceof Array ? entryFiles : [entryFiles]; - if ( - entryFiles.every( - (el: string) => el.match(/\.(css|scss|sass|less|styl)$/) !== null - ) - ) { - cssOnlyChunks.push(entryPoint); - } - } - // Remove the js file for supressed chunks - compilation.hooks.afterSeal.tap('SuppressExtractedTextChunks', () => { - compilation.chunks - .filter((chunk: any) => cssOnlyChunks.indexOf(chunk.name) !== -1) - .forEach((chunk: any) => { - let newFiles: string[] = []; - chunk.files.forEach((file: string) => { - if (file.match(/\.js(\.map)?$/)) { - // remove js files - delete compilation.assets[file]; - } else { - newFiles.push(file); - } - }); - chunk.files = newFiles; - }); - }); - // Remove scripts tags with a css file as source, because HtmlWebpackPlugin will use - // a css file as a script for chunks without js files. - // TODO: Enable this once HtmlWebpackPlugin supports Webpack 4 - // compilation.plugin('html-webpack-plugin-alter-asset-tags', - // (htmlPluginData: any, callback: any) => { - // const filterFn = (tag: any) => - // !(tag.tagName === 'script' && tag.attributes.src.match(/\.css$/)); - // htmlPluginData.head = htmlPluginData.head.filter(filterFn); - // htmlPluginData.body = htmlPluginData.body.filter(filterFn); - // callback(null, htmlPluginData); - // }); - } - ); - } -} diff --git a/packages/web/src/utils/third-party/cli-files/plugins/webpack.ts b/packages/web/src/utils/third-party/cli-files/plugins/webpack.ts index 3ae70a2d2e..f38b9a57e6 100644 --- a/packages/web/src/utils/third-party/cli-files/plugins/webpack.ts +++ b/packages/web/src/utils/third-party/cli-files/plugins/webpack.ts @@ -7,16 +7,10 @@ */ // Exports the webpack plugins we use internally. -export { - CleanCssWebpackPlugin, - CleanCssWebpackPluginOptions, -} from './cleancss-webpack-plugin'; -export { BundleBudgetPlugin, BundleBudgetPluginOptions } from './bundle-budget'; export { ScriptsWebpackPlugin, ScriptsWebpackPluginOptions, } from './scripts-webpack-plugin'; -export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunks-webpack-plugin'; export { RemoveHashPlugin, RemoveHashPluginOptions, diff --git a/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.spec.ts b/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.spec.ts deleted file mode 100644 index 0f21ba97e1..0000000000 --- a/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.spec.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import { calculateBytes } from './bundle-calculator'; - -describe('bundle-calculator', () => { - it('converts an integer with no postfix', () => { - expect(calculateBytes('0')).toBe(0); - expect(calculateBytes('5')).toBe(5); - expect(calculateBytes('190')).toBe(190); - expect(calculateBytes('92')).toBe(92); - }); - - it('converts a decimal with no postfix', () => { - expect(calculateBytes('3.14')).toBe(3.14); - expect(calculateBytes('0.25')).toBe(0.25); - expect(calculateBytes('90.5')).toBe(90.5); - expect(calculateBytes('25.0')).toBe(25); - }); - - it('converts an integer with kb postfix', () => { - expect(calculateBytes('0kb')).toBe(0); - expect(calculateBytes('5kb')).toBe(5 * 1024); - expect(calculateBytes('190KB')).toBe(190 * 1024); - expect(calculateBytes('92Kb')).toBe(92 * 1024); - expect(calculateBytes('25kB')).toBe(25 * 1024); - }); - - it('converts a decimal with kb postfix', () => { - expect(calculateBytes('3.14kb')).toBe(3.14 * 1024); - expect(calculateBytes('0.25KB')).toBe(0.25 * 1024); - expect(calculateBytes('90.5Kb')).toBe(90.5 * 1024); - expect(calculateBytes('25.0kB')).toBe(25 * 1024); - }); - - it('converts an integer with mb postfix', () => { - expect(calculateBytes('0mb')).toBe(0); - expect(calculateBytes('5mb')).toBe(5 * 1024 * 1024); - expect(calculateBytes('190MB')).toBe(190 * 1024 * 1024); - expect(calculateBytes('92Mb')).toBe(92 * 1024 * 1024); - expect(calculateBytes('25mB')).toBe(25 * 1024 * 1024); - }); - - it('converts a decimal with mb postfix', () => { - expect(calculateBytes('3.14mb')).toBe(3.14 * 1024 * 1024); - expect(calculateBytes('0.25MB')).toBe(0.25 * 1024 * 1024); - expect(calculateBytes('90.5Mb')).toBe(90.5 * 1024 * 1024); - expect(calculateBytes('25.0mB')).toBe(25 * 1024 * 1024); - }); - - it('converts an integer with gb postfix', () => { - expect(calculateBytes('0gb')).toBe(0); - expect(calculateBytes('5gb')).toBe(5 * 1024 * 1024 * 1024); - expect(calculateBytes('190GB')).toBe(190 * 1024 * 1024 * 1024); - expect(calculateBytes('92Gb')).toBe(92 * 1024 * 1024 * 1024); - expect(calculateBytes('25gB')).toBe(25 * 1024 * 1024 * 1024); - }); - - it('converts a decimal with gb postfix', () => { - expect(calculateBytes('3.14gb')).toBe(3.14 * 1024 * 1024 * 1024); - expect(calculateBytes('0.25GB')).toBe(0.25 * 1024 * 1024 * 1024); - expect(calculateBytes('90.5Gb')).toBe(90.5 * 1024 * 1024 * 1024); - expect(calculateBytes('25.0gB')).toBe(25 * 1024 * 1024 * 1024); - }); - - it('converts a decimal with mb and baseline', () => { - expect(calculateBytes('3mb', '5mb', -1)).toBe(2 * 1024 * 1024); - }); - - it('converts a percentage with baseline', () => { - expect(calculateBytes('20%', '1mb')).toBe(1024 * 1024 * 1.2); - expect(calculateBytes('20%', '1mb', -1)).toBe(1024 * 1024 * 0.8); - }); - - it('supports whitespace', () => { - expect(calculateBytes(' 5kb ')).toBe(5 * 1024); - expect(calculateBytes('0.25 MB')).toBe(0.25 * 1024 * 1024); - expect(calculateBytes(' 20 % ', ' 1 mb ')).toBe(1024 * 1024 * 1.2); - }); -}); diff --git a/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.ts b/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.ts deleted file mode 100644 index fe73078b1c..0000000000 --- a/packages/web/src/utils/third-party/cli-files/utilities/bundle-calculator.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import { Budget } from '../../browser/schema'; - -export interface Size { - size: number; - label?: string; -} - -// TODO(jack): Remove this in Nx 13 and go back to proper types -type Compilation = any; - -export function calculateSizes( - budget: Budget, - compilation: Compilation -): Size[] { - const calculatorMap = { - all: AllCalculator, - allScript: AllScriptCalculator, - any: AnyCalculator, - anyScript: AnyScriptCalculator, - anyComponentStyle: AnyComponentStyleCalculator, - bundle: BundleCalculator, - initial: InitialCalculator, - }; - - const ctor = calculatorMap[budget.type]; - const calculator = new ctor(budget, compilation); - - return calculator.calculate(); -} - -export abstract class Calculator { - constructor(protected budget: Budget, protected compilation: Compilation) {} - - abstract calculate(): Size[]; -} - -/** - * A named bundle. - */ -class BundleCalculator extends Calculator { - calculate() { - // TODO(jack): properly type this in Nx 13 - const xs: any = Array.from(this.compilation.chunks.values()); - const size: number = xs - .filter((chunk) => chunk.name === this.budget.name) - .reduce((files, chunk) => [...files, ...chunk.files], []) - .filter((file: string) => !file.endsWith('.map')) - .map((file: string) => this.compilation.assets[file].size()) - .reduce((total: number, size: number) => total + size, 0); - - return [{ size, label: this.budget.name }]; - } -} - -/** - * The sum of all initial chunks (marked as initial by webpack). - */ -class InitialCalculator extends Calculator { - calculate() { - // TODO(jack): properly type this in Nx 13 - const { isWebpack5 } = require('../../../../webpack/entry'); - - const initialChunks = isWebpack5 - ? Array.from(this.compilation.chunks.values()).filter((chunk: any) => - chunk.isOnlyInitial() - ) - : this.compilation.chunks.filter((chunk) => chunk.isOnlyInitial()); - const size: number = initialChunks - .reduce((files, chunk) => [...files, ...chunk.files], []) - .filter((file: string) => !file.endsWith('.map')) - .map((file: string) => this.compilation.assets[file].size()) - .reduce((total: number, size: number) => total + size, 0); - - return [{ size, label: 'initial' }]; - } -} - -/** - * The sum of all the scripts portions. - */ -class AllScriptCalculator extends Calculator { - calculate() { - const size: number = Object.keys(this.compilation.assets) - .filter((key) => key.endsWith('.js')) - .map((key) => this.compilation.assets[key]) - .map((asset) => asset.size()) - .reduce((total: number, size: number) => total + size, 0); - - return [{ size, label: 'total scripts' }]; - } -} - -/** - * All scripts and assets added together. - */ -class AllCalculator extends Calculator { - calculate() { - const size: number = Object.keys(this.compilation.assets) - .filter((key) => !key.endsWith('.map')) - .map((key) => this.compilation.assets[key].size()) - .reduce((total: number, size: number) => total + size, 0); - - return [{ size, label: 'total' }]; - } -} - -/** - * Any components styles - */ -class AnyComponentStyleCalculator extends Calculator { - calculate() { - return Object.keys(this.compilation.assets) - .filter((key) => key.endsWith('.css')) - .map((key) => ({ - size: this.compilation.assets[key].size(), - label: key, - })); - } -} - -/** - * Any script, individually. - */ -class AnyScriptCalculator extends Calculator { - calculate() { - return Object.keys(this.compilation.assets) - .filter((key) => key.endsWith('.js')) - .map((key) => { - const asset = this.compilation.assets[key]; - - return { - size: asset.size(), - label: key, - }; - }); - } -} - -/** - * Any script or asset (images, css, etc). - */ -class AnyCalculator extends Calculator { - calculate() { - return Object.keys(this.compilation.assets) - .filter((key) => !key.endsWith('.map')) - .map((key) => { - const asset = this.compilation.assets[key]; - - return { - size: asset.size(), - label: key, - }; - }); - } -} - -/** - * Calculate the bytes given a string value. - */ -export function calculateBytes( - input: string, - baseline?: string, - factor: 1 | -1 = 1 -): number { - const matches = input.match( - /^\s*(\d+(?:\.\d+)?)\s*(%|(?:[mM]|[kK]|[gG])?[bB])?\s*$/ - ); - if (!matches) { - return NaN; - } - - const baselineBytes = (baseline && calculateBytes(baseline)) || 0; - - let value = Number(matches[1]); - switch (matches[2] && matches[2].toLowerCase()) { - case '%': - value = (baselineBytes * value) / 100; - break; - case 'kb': - value *= 1024; - break; - case 'mb': - value *= 1024 * 1024; - break; - case 'gb': - value *= 1024 * 1024 * 1024; - break; - } - - if (baselineBytes === 0) { - return value; - } - - return baselineBytes + value * factor; -} diff --git a/packages/web/src/utils/third-party/cli-files/utilities/index-file/augment-index-html.ts b/packages/web/src/utils/third-party/cli-files/utilities/index-file/augment-index-html.ts index e93766fb4c..300017d8a6 100644 --- a/packages/web/src/utils/third-party/cli-files/utilities/index-file/augment-index-html.ts +++ b/packages/web/src/utils/third-party/cli-files/utilities/index-file/augment-index-html.ts @@ -7,6 +7,7 @@ */ import { createHash } from 'crypto'; +import { RawSource, ReplaceSource } from 'webpack-sources'; const parse5 = require('parse5'); @@ -56,9 +57,6 @@ export interface FileInfo { * bundles for differential serving. */ export function augmentIndexHtml(params: AugmentIndexHtmlOptions): string { - // TODO(jack): Remove this in Nx 13 and go back to proper types - const { webpackSources } = require('../../../../../webpack/entry'); - const { loadOutputFile, files, @@ -138,8 +136,8 @@ export function augmentIndexHtml(params: AugmentIndexHtmlOptions): string { } // Inject into the html - const indexSource = new webpackSources.ReplaceSource( - new webpackSources.RawSource(params.inputContent), + const indexSource = new ReplaceSource( + new RawSource(params.inputContent), params.input ); diff --git a/packages/web/src/utils/third-party/cli-files/utilities/stats.ts b/packages/web/src/utils/third-party/cli-files/utilities/stats.ts deleted file mode 100644 index f1883b77f4..0000000000 --- a/packages/web/src/utils/third-party/cli-files/utilities/stats.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -export function formatSize(size: number): string { - if (size <= 0) { - return '0 bytes'; - } - - const abbreviations = ['bytes', 'kB', 'MB', 'GB']; - const index = Math.floor(Math.log(size) / Math.log(1024)); - - return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${ - abbreviations[index] - }`; -} diff --git a/packages/web/src/utils/third-party/transforms.ts b/packages/web/src/utils/third-party/transforms.ts deleted file mode 100644 index c724aedab6..0000000000 --- a/packages/web/src/utils/third-party/transforms.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -export type ExecutionTransformer = (input: T) => T | Promise; diff --git a/packages/web/src/utils/types.ts b/packages/web/src/utils/types.ts index 7252816989..adeabb7d09 100644 --- a/packages/web/src/utils/types.ts +++ b/packages/web/src/utils/types.ts @@ -5,19 +5,12 @@ export interface OptimizationOptions { styles: boolean; } -export interface SourceMapOptions { - scripts: boolean; - styles: boolean; - vendors: boolean; - hidden: boolean; -} - export interface BuildBuilderOptions { main: string; outputPath: string; tsConfig: string; watch?: boolean; - sourceMap?: boolean | SourceMapOptions; + sourceMap?: boolean | 'hidden'; optimization?: boolean | OptimizationOptions; showCircularDependencies?: boolean; memoryLimit?: number; diff --git a/packages/web/src/utils/web.config.ts b/packages/web/src/utils/web.config.ts index f766d26269..7ccff43936 100644 --- a/packages/web/src/utils/web.config.ts +++ b/packages/web/src/utils/web.config.ts @@ -1,23 +1,23 @@ +import * as path from 'path'; +import { basename, posix, resolve } from 'path'; +import { readTsConfig } from '@nrwl/workspace/src/utilities/typescript'; +import { ScriptTarget } from 'typescript'; +import { getHashDigest, interpolateName } from 'loader-utils'; +import { Configuration } from 'webpack'; + // TODO @FrozenPandaz we should remove the following imports import { getBrowserConfig } from './third-party/cli-files/models/webpack-configs/browser'; import { getCommonConfig } from './third-party/cli-files/models/webpack-configs/common'; import { getStylesConfig } from './third-party/cli-files/models/webpack-configs/styles'; -import * as path from 'path'; -import { basename, posix, resolve } from 'path'; -import { WebBuildBuilderOptions } from '../executors/build/build.impl'; -import { convertBuildOptions } from './normalize'; -import { readTsConfig } from '@nrwl/workspace/src/utilities/typescript'; -import { getBaseWebpackPartial } from './config'; -import { LegacyIndexHtmlWebpackPlugin } from './third-party/cli-files/plugins/legacy-index-html-webpack-plugin'; import { IndexHtmlWebpackPlugin } from './third-party/cli-files/plugins/index-html-webpack-plugin'; import { generateEntryPoints } from './third-party/cli-files/utilities/package-chunk-sort'; -import { ScriptTarget } from 'typescript'; -import { getHashDigest, interpolateName } from 'loader-utils'; -import { sassImplementation } from './sass'; -import postcssImports = require('postcss-import'); -// TODO(jack): Remove this in Nx 13 -type Configuration = any; +import { WebBuildBuilderOptions } from '../executors/build/build.impl'; +import { convertBuildOptions } from './normalize'; +import { getBaseWebpackPartial } from './config'; +import MiniCssExtractPlugin = require('mini-css-extract-plugin'); +import webpackMerge = require('webpack-merge'); +import postcssImports = require('postcss-import'); // PostCSS options depend on the webpack loader, but we need to set the `config` path as a string due to this check: // https://github.com/webpack-contrib/postcss-loader/blob/0d342b1/src/utils.js#L36 @@ -36,9 +36,6 @@ export function getWebConfig( isScriptOptimizeOn?: boolean, configuration?: string ) { - // TODO(jack): Remove this in Nx 13 and go back to proper import - const { webpackMerge } = require('../webpack/entry'); - const tsConfig = readTsConfig(options.tsConfig); if (isScriptOptimizeOn) { @@ -58,7 +55,7 @@ export function getWebConfig( tsConfig, tsConfigPath: options.tsConfig, }; - return webpackMerge([ + return webpackMerge.merge([ _getBaseWebpackPartial( options, esm, @@ -89,7 +86,6 @@ function getBrowserPartial( isScriptOptimizeOn: boolean ) { const config = getBrowserConfig(wco); - const { isWebpack5 } = require('../webpack/entry'); if (!isScriptOptimizeOn) { const { @@ -102,26 +98,16 @@ function getBrowserPartial( } = options; config.plugins.push( - isWebpack5 - ? new IndexHtmlWebpackPlugin({ - indexPath: resolve(wco.root, index), - outputPath: basename(index), - baseHref, - entrypoints: generateEntryPoints({ scripts, styles }), - deployUrl, - sri: subresourceIntegrity, - moduleEntrypoints: [], - noModuleEntrypoints: ['polyfills-es5'], - }) - : new LegacyIndexHtmlWebpackPlugin({ - input: resolve(wco.root, index), - output: basename(index), - baseHref, - entrypoints: generateEntryPoints({ scripts, styles }), - deployUrl, - sri: subresourceIntegrity, - noModuleEntrypoints: ['polyfills-es5'], - }) + new IndexHtmlWebpackPlugin({ + indexPath: resolve(wco.root, index), + outputPath: basename(index), + baseHref, + entrypoints: generateEntryPoints({ scripts, styles }), + deployUrl, + sri: subresourceIntegrity, + moduleEntrypoints: [], + noModuleEntrypoints: ['polyfills-es5'], + }) ); } @@ -162,9 +148,6 @@ export function getStylesPartial( options: any, extractCss: boolean ): Configuration { - // TODO(jack): Remove this in Nx 13 and go back to proper imports - const { MiniCssExtractPlugin } = require('../webpack/entry'); - const includePaths: string[] = []; if (options?.stylePreprocessorOptions?.includePaths?.length > 0) { @@ -258,7 +241,7 @@ export function getStylesPartial( { loader: require.resolve('sass-loader'), options: { - implementation: sassImplementation, + implementation: require('sass'), sassOptions: { fiber: false, precision: 8, diff --git a/packages/web/src/webpack/bundle4.ts b/packages/web/src/webpack/bundle4.ts deleted file mode 100644 index 6d7e5ac510..0000000000 --- a/packages/web/src/webpack/bundle4.ts +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = function (useShim = true) { - const webpack = require('webpack'); - webpack.webpack = webpack; - webpack.WebpackError = require('webpack/lib/WebpackError'); - - return { - CopyWebpackPlugin: require('copy-webpack-plugin'), - MiniCssExtractPlugin: require('mini-css-extract-plugin'), - SourceMapLoader: require('source-map-loader'), - TerserWebpackPlugin: require('terser-webpack-plugin'), - webpackSources: require('webpack-sources'), - webpack, - webpackMerge: require('webpack-merge'), - }; -}; diff --git a/packages/web/src/webpack/bundle5.ts b/packages/web/src/webpack/bundle5.ts deleted file mode 100644 index 9e87ca5dbd..0000000000 --- a/packages/web/src/webpack/bundle5.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { logger, stripIndents } from '@nrwl/devkit'; -import chalk = require('chalk'); - -import { requireShim } from './require-shim'; -import packageJson = require('../../package.json'); - -function validateVersion(path) { - if ( - packageJson.dependencies[path] === - requireShim(`${path}/package.json`).version - ) { - logger.warn(`Found an outdated version of ${chalk.bold(path)}\n`); - - logger.info(stripIndents` - If you want to use webpack 5, try installing compatible versions of the plugins. - See: https://nx.dev/guides/webpack-5 - `); - - throw new Error('Incompatible version'); - } -} - -module.exports = function (onFallback) { - try { - validateVersion('copy-webpack-plugin'); - validateVersion('terser-webpack-plugin'); - validateVersion('mini-css-extract-plugin'); - validateVersion('source-map-loader'); - validateVersion('webpack-merge'); - validateVersion('webpack-sources'); - } catch { - logger.info( - `NX Falling back to webpack 4 due to incompatible plugin versions` - ); - onFallback(); - return require('./bundle4')(); - } - - return { - CopyWebpackPlugin: requireShim('copy-webpack-plugin'), - MiniCssExtractPlugin: requireShim('mini-css-extract-plugin'), - SourceMapLoader: requireShim('source-map-loader'), - TerserWebpackPlugin: requireShim('terser-webpack-plugin'), - webpackSources: requireShim('webpack-sources'), - webpack: requireShim('webpack'), - webpackMerge: requireShim('webpack-merge').default, - }; -}; diff --git a/packages/web/src/webpack/delete-in-nx-13.txt b/packages/web/src/webpack/delete-in-nx-13.txt deleted file mode 100644 index 7d73560485..0000000000 --- a/packages/web/src/webpack/delete-in-nx-13.txt +++ /dev/null @@ -1 +0,0 @@ -TODO(jack): Delete for Nx 13 diff --git a/packages/web/src/webpack/entry.ts b/packages/web/src/webpack/entry.ts deleted file mode 100644 index 311fa5d151..0000000000 --- a/packages/web/src/webpack/entry.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { logger } from '@nrwl/devkit'; -import { requireShim } from './require-shim'; - -const result = requireShim('webpack/package.json'); -const version = result?.version; - -exports.default = undefined; - -const forceWebpack4 = process.env.NX_FORCE_WEBPACK_4; - -exports.isWebpack5 = !forceWebpack4 && /^5\./.test(version); - -let hasLogged = false; - -if (exports.isWebpack5) { - if (!hasLogged) { - logger.info( - `NX Using webpack 5. Reason: detected version 5 in node_modules/webpack/package.json` - ); - hasLogged = true; - } - Object.assign( - exports, - require('./bundle5')(() => { - exports.isWebpack5 = false; - }) - ); -} else { - if (!hasLogged) { - hasLogged = true; - } - Object.assign(exports, require('./bundle4')()); -} diff --git a/packages/web/src/webpack/require-shim.ts b/packages/web/src/webpack/require-shim.ts deleted file mode 100644 index a20e3b1f73..0000000000 --- a/packages/web/src/webpack/require-shim.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { appRootPath } from '@nrwl/tao/src/utils/app-root'; -import { join } from 'path'; - -export function requireShim(path: string) { - try { - return require(join(appRootPath, 'node_modules', path)); - } catch { - return require(path); - } -} diff --git a/packages/workspace/src/utilities/run-webpack.ts b/packages/workspace/src/utilities/run-webpack.ts index 0458d95f06..29de0ed912 100644 --- a/packages/workspace/src/utilities/run-webpack.ts +++ b/packages/workspace/src/utilities/run-webpack.ts @@ -1,40 +1,34 @@ +import * as webpack from 'webpack'; import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server'; - import { Observable } from 'rxjs/internal/Observable'; - import { extname } from 'path'; -import * as url from 'url'; -export function runWebpack(config: any, webpack: any): Observable { +export function runWebpack(config: webpack.Configuration): Observable { return new Observable((subscriber) => { - const webpackCompiler = webpack(config); + // Passing `watch` option here will result in a warning due to missing callback. + // We manually call `.watch` or `.run` later so this option isn't needed here. + const { watch, ...normalizedConfig } = config; + const webpackCompiler = webpack(normalizedConfig); - function callback(err: Error, stats: any) { + const callback = (err: Error, stats: webpack.Stats) => { if (err) { subscriber.error(err); } subscriber.next(stats); - } + }; if (config.watch) { const watchOptions = config.watchOptions || {}; const watching = webpackCompiler.watch(watchOptions, callback); - return () => { - watching.close(() => {}); - }; + return () => watching.close(() => subscriber.complete()); } else { webpackCompiler.run((err, stats) => { callback(err, stats); - - // TODO: Delete for Nx 13 and leave only the call to close method - if (typeof webpackCompiler.close === 'function') { - webpackCompiler.close(() => { - subscriber.complete(); - }); - } else { + webpackCompiler.close((closeErr) => { + if (closeErr) subscriber.error(closeErr); subscriber.complete(); - } + }); }); } }); @@ -62,34 +56,20 @@ export function runWebpackDevServer( originalOnListen(server); const devServerOptions: WebpackDevServerConfiguration = server.options; - baseUrl = url.format({ - protocol: devServerOptions.https ? 'https' : 'http', - hostname: server.hostname, - port: server.listeningApp.address().port, - pathname: devServerOptions.publicPath, - }); + + baseUrl = `${server.options.https ? 'https' : 'http'}://${ + server.options.host + }:${server.options.port}${devServerOptions.devMiddleware.publicPath}`; }; const webpackServer = new WebpackDevServer( - // Some type mismatches between webpack's built-in type defs and what webpack-dev-server expects. - webpackCompiler as any, - devServerConfig + devServerConfig, + webpackCompiler as any ); try { - const server = webpackServer.listen( - devServerConfig.port ?? 8080, - devServerConfig.host ?? 'localhost', - function (err) { - if (err) { - subscriber.error(err); - } - } - ); - - return () => { - server.close(); - }; + webpackServer.start().catch((err) => subscriber.error(err)); + return () => webpackServer.stop(); } catch (e) { throw new Error('Could not start start dev server'); } @@ -105,7 +85,7 @@ export interface EmittedFile { asset?: boolean; } -export function getEmittedFiles(stats: any) { +export function getEmittedFiles(stats: webpack.Stats) { const { compilation } = stats; const files: EmittedFile[] = []; // adds all chunks to the list of emitted files such as lazy loaded modules diff --git a/yarn.lock b/yarn.lock index efc0c71546..1f4f22cbac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3307,6 +3307,15 @@ "@babel/preset-env" "^7.0.0" babel-loader "^8.0.2" +"@cypress/webpack-preprocessor@^5.9.1": + version "5.9.1" + resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.9.1.tgz#2694aa832baf3984d90bcb899e1ecff377560904" + integrity sha512-cg1ikftIo7NdlRA8ocNSxWjHJlh1JlTkN9ZfXUuKWWcJgrEdYLjXk0UzY6gYbLLaFka4oIhN6SvL5Y/7iELvgg== + dependencies: + bluebird "^3.7.1" + debug "4.3.2" + lodash "^4.17.20" + "@cypress/xvfb@^1.2.4": version "1.2.4" resolved "https://registry.yarnpkg.com/@cypress/xvfb/-/xvfb-1.2.4.tgz#2daf42e8275b39f4aa53c14214e557bd14e7748a" @@ -5926,6 +5935,23 @@ dependencies: "@types/node" "*" +"@types/css-minimizer-webpack-plugin@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@types/css-minimizer-webpack-plugin/-/css-minimizer-webpack-plugin-3.0.2.tgz#ed58bbbde8a7b7591118aa93d8f8d0cdc0cc6173" + integrity sha512-Y5dt+W/zZXSVpGiVIAlDHRhmUuL2Wd/3mYld5/qaJ87ORuTVVIwmLZyPKWMPk8eVjdVng1641VpRZ57rd7ZeYw== + dependencies: + "@types/cssnano" "*" + postcss "^8.2.9" + tapable "^2.2.0" + webpack "^5.37.0" + +"@types/cssnano@*": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/cssnano/-/cssnano-4.0.1.tgz#67fa912753d80973a016e7684a47fedf338aacff" + integrity sha512-hGOroxRTBkYl5gSBRJOffhV4+io+Y2bFX1VP7LgKEVHJt/LPPJaWUIuDAz74Vlp7l7hCDZfaDi7iPxwNwuVA4Q== + dependencies: + postcss "5 - 7" + "@types/cytoscape@^3.14.12": version "3.14.12" resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.14.12.tgz#b46c445da97df76d486c5b3b25554f616deefd41" @@ -6062,6 +6088,13 @@ resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== +"@types/http-proxy@^1.17.5": + version "1.17.7" + resolved "https://registry.yarnpkg.com/@types%2fhttp-proxy/-/http-proxy-1.17.7.tgz#30ea85cc2c868368352a37f0d0d3581e24834c6f" + integrity sha512-9hdj6iXH64tHSLTY+Vt2eYOGzSogC+JQ2H7bdPWkuh7KXP5qLllWx++t+K9Wk556c3dkDdPws/SpMRi0sdCT1w== + dependencies: + "@types/node" "*" + "@types/is-ci@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/is-ci/-/is-ci-3.0.0.tgz#7e8910af6857601315592436f030aaa3ed9783c3" @@ -6376,6 +6409,11 @@ dependencies: "@types/node" "*" +"@types/retry@^0.12.0": + version "0.12.1" + resolved "https://registry.yarnpkg.com/@types%2fretry/-/retry-0.12.1.tgz#d8f1c0d0dc23afad6dc16a9e993a0865774b4065" + integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g== + "@types/scheduler@*": version "0.16.1" resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275" @@ -7399,6 +7437,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -8288,7 +8331,7 @@ bluebird@3.7.1: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.1.tgz#df70e302b471d7473489acf26a93d63b53f874de" integrity sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg== -bluebird@^3.3.0, bluebird@^3.3.5, bluebird@^3.5.5, bluebird@^3.7.2: +bluebird@^3.3.0, bluebird@^3.3.5, bluebird@^3.5.5, bluebird@^3.7.1, bluebird@^3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== @@ -9424,6 +9467,11 @@ colorette@^1.1.0, colorette@^1.2.1, colorette@^1.2.2: resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== +colorette@^2.0.10: + version "2.0.15" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.15.tgz#8e634aa0429b110d24be82eac4d42f5ea65ab2d5" + integrity sha512-lIFQhufWaVvwi4wOlX9Gx5b0Nmw3XAZ8HzHNH9dfxhe+JaKNTmX6QLk4o7UHyI+tUY8ClvyfaHUm5bf61O3psA== + colors@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" @@ -9918,7 +9966,7 @@ copy-webpack-plugin@6.4.1: serialize-javascript "^5.0.1" webpack-sources "^1.4.3" -copy-webpack-plugin@9.0.1: +copy-webpack-plugin@9.0.1, copy-webpack-plugin@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-9.0.1.tgz#b71d21991599f61a4ee00ba79087b8ba279bbb59" integrity sha512-14gHKKdYIxF84jCEgPgYXCPpldbwpxxLbCmA7LReY7gvbaT555DgeBWBgBZM116tv/fO6RRJrsivBqRyRlukhw== @@ -10274,6 +10322,19 @@ css-minimizer-webpack-plugin@3.0.2: serialize-javascript "^6.0.0" source-map "^0.6.1" +css-minimizer-webpack-plugin@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/css-minimizer-webpack-plugin/-/css-minimizer-webpack-plugin-3.1.1.tgz#27bafa3b75054713565b2266c64b0228acd18634" + integrity sha512-KlB8l5uoNcf9F7i5kXnkxoqJGd2BXH4f0+Lj2vSWSmuvMLYO1kNsJ1KHSzeDW8e45/whgSOPcKVT/3JopkT8dg== + dependencies: + cssnano "^5.0.6" + jest-worker "^27.0.2" + p-limit "^3.0.2" + postcss "^8.3.5" + schema-utils "^3.1.0" + serialize-javascript "^6.0.0" + source-map "^0.6.1" + css-parse@1.7.x: version "1.7.0" resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-1.7.0.tgz#321f6cf73782a6ff751111390fc05e2c657d8c9b" @@ -10872,6 +10933,13 @@ default-gateway@^4.2.0: execa "^1.0.0" ip-regex "^2.1.0" +default-gateway@^6.0.0: + version "6.0.3" + resolved "https://registry.yarnpkg.com/default-gateway/-/default-gateway-6.0.3.tgz#819494c888053bdb743edbf343d6cdf7f2943a71" + integrity sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg== + dependencies: + execa "^5.0.0" + default-require-extensions@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-2.0.0.tgz#f5f8fbb18a7d6d50b21f641f649ebb522cfe24f7" @@ -10961,6 +11029,20 @@ del@^4.1.1: pify "^4.0.1" rimraf "^2.6.3" +del@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/del/-/del-6.0.0.tgz#0b40d0332cea743f1614f818be4feb717714c952" + integrity sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ== + dependencies: + globby "^11.0.1" + graceful-fs "^4.2.4" + is-glob "^4.0.1" + is-path-cwd "^2.2.0" + is-path-inside "^3.0.2" + p-map "^4.0.0" + rimraf "^3.0.2" + slash "^3.0.0" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -11622,6 +11704,14 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.5.0: memory-fs "^0.5.0" tapable "^1.0.0" +enhanced-resolve@^5.0.0, enhanced-resolve@^5.8.3: + version "5.8.3" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz#6d552d465cce0423f5b3d718511ea53826a7b2f0" + integrity sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + enhanced-resolve@^5.7.0, enhanced-resolve@^5.8.0: version "5.8.2" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz#15ddc779345cbb73e97c611cd00c01c1e7bf4d8b" @@ -11734,6 +11824,11 @@ es-module-lexer@^0.7.1: resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.7.1.tgz#c2c8e0f46f2df06274cdaf0dd3f3b33e0a0b267d" integrity sha512-MgtWFl5No+4S3TmhDmCz2ObFGm6lEpTnzbQi+Dd+pw4mlTIZTmM2iAs5gRlmx5zS9luzobCSBSI90JM/1/JgOw== +es-module-lexer@^0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.2.tgz#d0a8c72c5d904014111fac7fab4c92b9ac545564" + integrity sha512-YkAGWqxZq2B4FxQ5y687UwywDwvLQhIMCZ+SDU7ZW729SDHOEI6wVFXwTRecz+yiwJzCsVwC6V7bxyNbZSB1rg== + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -13560,6 +13655,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== +graceful-fs@^4.2.6: + version "4.2.8" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" + integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== + graphlib@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/graphlib/-/graphlib-2.1.8.tgz#5761d414737870084c92ec7b5dbcb0592c9d35da" @@ -13975,7 +14075,7 @@ html-entities@^1.2.0, html-entities@^1.2.1, html-entities@^1.3.1: resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.4.0.tgz#cfbd1b01d2afaf9adca1b10ae7dffab98c71d2dc" integrity sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA== -html-entities@^2.1.0: +html-entities@^2.1.0, html-entities@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.2.tgz#760b404685cb1d794e4f4b744332e3b00dcfe488" integrity sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ== @@ -14138,7 +14238,18 @@ http-proxy-middleware@0.19.1: lodash "^4.17.11" micromatch "^3.1.10" -http-proxy@^1.13.0, http-proxy@^1.17.0, http-proxy@^1.18.0: +http-proxy-middleware@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.1.tgz#7ef3417a479fb7666a571e09966c66a39bd2c15f" + integrity sha512-cfaXRVoZxSed/BmkA7SwBVNI9Kj7HFltaE5rqYOub5kWzWZ+gofV2koVN1j2rMW7pEfSSlCHGJ31xmuyFyfLOg== + dependencies: + "@types/http-proxy" "^1.17.5" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + +http-proxy@^1.13.0, http-proxy@^1.17.0, http-proxy@^1.18.0, http-proxy@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== @@ -14492,6 +14603,16 @@ internal-ip@^4.3.0: default-gateway "^4.2.0" ipaddr.js "^1.9.0" +internal-ip@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-6.2.0.tgz#d5541e79716e406b74ac6b07b856ef18dc1621c1" + integrity sha512-D8WGsR6yDt8uq7vDMu7mjcR+yRMm3dW8yufyChmszWRjcSHuxLBkR3GdS2HZAjodsaGuCvXeEJpueisXJULghg== + dependencies: + default-gateway "^6.0.0" + ipaddr.js "^1.9.1" + is-ip "^3.1.0" + p-event "^4.2.0" + internal-slot@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" @@ -14530,7 +14651,7 @@ ip-regex@^2.1.0: resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk= -ip-regex@^4.1.0: +ip-regex@^4.0.0, ip-regex@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5" integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q== @@ -14540,11 +14661,16 @@ ip@^1.1.0, ip@^1.1.5: resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= -ipaddr.js@1.9.1, ipaddr.js@^1.9.0: +ipaddr.js@1.9.1, ipaddr.js@^1.9.0, ipaddr.js@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== +ipaddr.js@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0" + integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng== + is-absolute-url@^3.0.0, is-absolute-url@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-3.0.3.tgz#96c6a22b6a23929b11ea0afb1836c36ad4a5d698" @@ -14831,6 +14957,13 @@ is-interactive@^1.0.0: resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w== +is-ip@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-3.1.0.tgz#2ae5ddfafaf05cb8008a62093cf29734f657c5d8" + integrity sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q== + dependencies: + ip-regex "^4.0.0" + is-lambda@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" @@ -14896,7 +15029,7 @@ is-path-cwd@^1.0.0: resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" integrity sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0= -is-path-cwd@^2.0.0: +is-path-cwd@^2.0.0, is-path-cwd@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== @@ -14944,6 +15077,11 @@ is-plain-obj@^2.0.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + is-plain-object@3.0.1, is-plain-object@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b" @@ -16234,7 +16372,7 @@ jest-worker@^27.0.2: merge-stream "^2.0.0" supports-color "^8.0.0" -jest-worker@^27.2.2, jest-worker@^27.2.4: +jest-worker@^27.0.6, jest-worker@^27.2.2, jest-worker@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.2.4.tgz#881455df75e22e7726a53f43703ab74d6b36f82d" integrity sha512-Zq9A2Pw59KkVjBBKD1i3iE2e22oSjXhUKKuAK1HGX8flGwkm6NMozyEYzKd41hXc64dbd/0eWFeEEuxqXyhM+g== @@ -17910,6 +18048,13 @@ mini-css-extract-plugin@2.1.0: dependencies: schema-utils "^3.0.0" +mini-css-extract-plugin@^2.1.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-2.4.2.tgz#b3508191ea479388a4715018c99dd3e6dd40d2d2" + integrity sha512-ZmqShkn79D36uerdED+9qdo1ZYG8C1YsWvXu0UMJxurZnSdgz7gQKO2EGv8T55MhDqG3DYmGtizZNpM/UbTlcA== + dependencies: + schema-utils "^3.1.0" + mini-svg-data-uri@^1.2.3: version "1.3.3" resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.3.3.tgz#91d2c09f45e056e5e1043340b8b37ba7b50f4fac" @@ -18184,6 +18329,11 @@ nanoid@^3.1.23: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81" integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw== +nanoid@^3.1.28: + version "3.1.29" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.29.tgz#214fb2d7a33e1a5bef4757b779dfaeb6a4e5aeb4" + integrity sha512-dW2pUSGZ8ZnCFIlBIA31SV8huOGCHb6OwzVCc7A69rb/a+SgPBwfmLvK5TKQ3INPbRkcI8a/Owo0XbiTNH19wg== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -18972,6 +19122,15 @@ open@8.2.1: is-docker "^2.1.1" is-wsl "^2.2.0" +open@^8.0.9: + version "8.3.0" + resolved "https://registry.yarnpkg.com/open/-/open-8.3.0.tgz#fdef1cdfe405e60dec8ebd18889e7e812f39c59f" + integrity sha512-7INcPWb1UcOwSQxAXTnBJ+FxVV4MPs/X++FWWBtgY69/J5lc+tCteMt/oFK1MnkyHC4VILLa9ntmwKTwDR4Q9w== + dependencies: + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" + opener@^1.5.1: version "1.5.2" resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" @@ -19127,7 +19286,7 @@ p-each-series@^2.1.0: resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" integrity sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA== -p-event@^4.1.0: +p-event@^4.1.0, p-event@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/p-event/-/p-event-4.2.0.tgz#af4b049c8acd91ae81083ebd1e6f5cae2044c1b5" integrity sha512-KXatOjCRXXkSePPb1Nbi0p0m+gQAwdlbhi4wQKJPI1HsMQS9g+Sqp2o+QHziPr7eYJyOZet836KoHEVM1mwOrQ== @@ -19229,6 +19388,14 @@ p-retry@^3.0.1: dependencies: retry "^0.12.0" +p-retry@^4.5.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-4.6.1.tgz#8fcddd5cdf7a67a0911a9cf2ef0e5df7f602316c" + integrity sha512-e2xXGNhZOZ0lfgR9kL34iGlU8N/KO0xZnQxVEwdeOvpqNDQfdnxIYizvWtK8RglUa3bGqI8g0R/BdfzLMxRkiA== + dependencies: + "@types/retry" "^0.12.0" + retry "^0.13.1" + p-timeout@^3.1.0, p-timeout@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" @@ -19634,6 +19801,11 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= +picocolors@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f" + integrity sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA== + picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1, picomatch@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" @@ -19792,7 +19964,7 @@ polished@^4.0.5: dependencies: "@babel/runtime" "^7.13.17" -portfinder@^1.0.25, portfinder@^1.0.26: +portfinder@^1.0.25, portfinder@^1.0.26, portfinder@^1.0.28: version "1.0.28" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA== @@ -20488,6 +20660,14 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1: indexes-of "^1.0.1" uniq "^1.0.1" +"postcss@5 - 7": + version "7.0.39" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.39.tgz#9624375d965630e2e1f2c02a935c82a59cb48309" + integrity sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA== + dependencies: + picocolors "^0.2.1" + source-map "^0.6.1" + postcss@8.2.15: version "8.2.15" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.15.tgz#9e66ccf07292817d226fc315cbbf9bc148fbca65" @@ -20560,6 +20740,15 @@ postcss@^8.2.15: nanoid "^3.1.23" source-map-js "^0.6.2" +postcss@^8.2.9: + version "8.3.9" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.9.tgz#98754caa06c4ee9eb59cc48bd073bb6bd3437c31" + integrity sha512-f/ZFyAKh9Dnqytx5X62jgjhhzttjZS7hMsohcI7HEI5tjELX/HxCy3EFhsRxyzGvrzFF+82XPvCS8T9TFleVJw== + dependencies: + nanoid "^3.1.28" + picocolors "^0.2.1" + source-map-js "^0.6.2" + precise-commits@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/precise-commits/-/precise-commits-1.0.2.tgz#4659be01a9c3310f50ce51ddf913fead1d7cc940" @@ -21306,6 +21495,11 @@ react-refresh@0.8.3, react-refresh@^0.8.3: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f" integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg== +react-refresh@^0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.10.0.tgz#2f536c9660c0b9b1d500684d9e52a65e7404f7e3" + integrity sha512-PgidR3wST3dDYKr6b4pJoqQFpPGNKDSCDx4cZoshjXipw3LzO7mG1My2pwEzz2JVkF+inx3xRpDeQLFQGH/hsQ== + react-refresh@^0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf" @@ -22159,6 +22353,11 @@ retry@0.12.0, retry@^0.12.0: resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= +retry@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + reusify@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" @@ -22556,7 +22755,7 @@ schema-utils@^3.0.0: ajv "^6.12.5" ajv-keywords "^3.5.2" -schema-utils@^3.1.0: +schema-utils@^3.1.0, schema-utils@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== @@ -22606,6 +22805,13 @@ selenium-webdriver@3.6.0, selenium-webdriver@^3.0.1: tmp "0.0.30" xml2js "^0.4.17" +selfsigned@^1.10.11: + version "1.10.11" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.11.tgz#24929cd906fe0f44b6d01fb23999a739537acbe9" + integrity sha512-aVmbPOfViZqOZPgRBT0+3u4yZFHpmnIghLMlAcb5/xhp5ZtB/RVnKhz5vl2M32CLXAqR4kha9zfhNg0Lf/sxKA== + dependencies: + node-forge "^0.10.0" + selfsigned@^1.10.8: version "1.10.8" resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.8.tgz#0d17208b7d12c33f8eac85c41835f27fc3d81a30" @@ -23062,7 +23268,7 @@ source-map-loader@0.2.4: async "^2.5.0" loader-utils "^1.1.0" -source-map-loader@3.0.0: +source-map-loader@3.0.0, source-map-loader@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-3.0.0.tgz#f2a04ee2808ad01c774dea6b7d2639839f3b3049" integrity sha512-GKGWqWvYr04M7tn8dryIWvb0s8YM41z82iQv01yBtIylgxax0CwvSy6gc2Y02iuXwEfGWRlMicH0nvms9UZphw== @@ -23105,6 +23311,14 @@ source-map-support@~0.4.0: dependencies: source-map "^0.5.6" +source-map-support@~0.5.20: + version "0.5.20" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" + integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map-url@^0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" @@ -23561,6 +23775,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== + dependencies: + ansi-regex "^6.0.1" + strip-bom-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-bom-string/-/strip-bom-string-1.0.0.tgz#e5211e9224369fbb81d633a2f00044dc8cedad92" @@ -24053,6 +24274,18 @@ terser-webpack-plugin@^4.2.3: terser "^5.3.4" webpack-sources "^1.4.3" +terser-webpack-plugin@^5.1.1: + version "5.2.4" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.2.4.tgz#ad1be7639b1cbe3ea49fab995cbe7224b31747a1" + integrity sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA== + dependencies: + jest-worker "^27.0.6" + p-limit "^3.1.0" + schema-utils "^3.1.1" + serialize-javascript "^6.0.0" + source-map "^0.6.1" + terser "^5.7.2" + terser@4.3.8: version "4.3.8" resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.8.tgz#707f05f3f4c1c70c840e626addfdb1c158a17136" @@ -24098,6 +24331,15 @@ terser@^5.6.0: source-map "~0.7.2" source-map-support "~0.5.19" +terser@^5.7.2: + version "5.9.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.9.0.tgz#47d6e629a522963240f2b55fcaa3c99083d2c351" + integrity sha512-h5hxa23sCdpzcye/7b8YqbE5OwKca/ni0RQz1uRX3tGh8haaGHqcuSqbGRybuAKNdntZ0mDgFNXPJ48xQ2RXKQ== + dependencies: + commander "^2.20.0" + source-map "~0.7.2" + source-map-support "~0.5.20" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" @@ -24462,6 +24704,16 @@ ts-loader@^8.0.14: micromatch "^4.0.0" semver "^7.3.4" +ts-loader@^9.2.6: + version "9.2.6" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.6.tgz#9937c4dd0a1e3dbbb5e433f8102a6601c6615d74" + integrity sha512-QMTC4UFzHmu9wU2VHZEmWWE9cUajjfcdcws+Gh7FhiO+Dy0RnR1bNz0YCHqhI0yRowCE9arVnNxYHqELOy9Hjw== + dependencies: + chalk "^4.1.0" + enhanced-resolve "^5.0.0" + micromatch "^4.0.0" + semver "^7.3.4" + ts-node@9.1.1, ts-node@^9.1.1, ts-node@~9.1.1: version "9.1.1" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" @@ -25539,6 +25791,17 @@ webpack-dev-middleware@^3.7.0, webpack-dev-middleware@^3.7.2, webpack-dev-middle range-parser "^1.2.1" webpack-log "^2.0.0" +webpack-dev-middleware@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.2.1.tgz#97c948144349177856a3d2d9c612cc3fee180cf1" + integrity sha512-Kx1X+36Rn9JaZcQMrJ7qN3PMAuKmEDD9ZISjUj3Cgq4A6PtwYsC4mpaKotSRYH3iOF6HsUa8viHKS59FlyVifQ== + dependencies: + colorette "^2.0.10" + memfs "^3.2.2" + mime-types "^2.1.31" + range-parser "^1.2.1" + schema-utils "^3.1.0" + webpack-dev-server@3.11.2: version "3.11.2" resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.2.tgz#695ebced76a4929f0d5de7fd73fafe185fe33708" @@ -25578,6 +25841,37 @@ webpack-dev-server@3.11.2: ws "^6.2.1" yargs "^13.3.2" +webpack-dev-server@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.3.1.tgz#759d3337f0fbea297fbd1e433ab04ccfc000076b" + integrity sha512-qNXQCVYo1kYhH9pgLtm8LRNkXX3XzTfHSj/zqzaqYzGPca+Qjr+81wj1jgPMCHhIhso9WEQ+kX9z23iG9PzQ7w== + dependencies: + ansi-html-community "^0.0.8" + bonjour "^3.5.0" + chokidar "^3.5.1" + colorette "^2.0.10" + compression "^1.7.4" + connect-history-api-fallback "^1.6.0" + del "^6.0.0" + express "^4.17.1" + graceful-fs "^4.2.6" + html-entities "^2.3.2" + http-proxy-middleware "^2.0.0" + internal-ip "^6.2.0" + ipaddr.js "^2.0.1" + open "^8.0.9" + p-retry "^4.5.0" + portfinder "^1.0.28" + schema-utils "^3.1.0" + selfsigned "^1.10.11" + serve-index "^1.9.1" + sockjs "^0.3.21" + spdy "^4.0.2" + strip-ansi "^7.0.0" + url "^0.11.0" + webpack-dev-middleware "^5.2.1" + ws "^8.1.0" + webpack-filter-warnings-plugin@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/webpack-filter-warnings-plugin/-/webpack-filter-warnings-plugin-1.2.1.tgz#dc61521cf4f9b4a336fbc89108a75ae1da951cdb" @@ -25608,7 +25902,7 @@ webpack-merge@4.2.1: dependencies: lodash "^4.17.5" -webpack-merge@5.8.0: +webpack-merge@5.8.0, webpack-merge@^5.8.0: version "5.8.0" resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== @@ -25621,6 +25915,11 @@ webpack-node-externals@1.7.2: resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.7.2.tgz#6e1ee79ac67c070402ba700ef033a9b8d52ac4e3" integrity sha512-ajerHZ+BJKeCLviLUUmnyd5B4RavLF76uv3cs6KNuO8W+HuQaEs0y0L7o40NQxdPy5w0pcv8Ew7yPUAQG0UdCg== +webpack-node-externals@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-3.0.0.tgz#1a3407c158d547a9feb4229a9e3385b7b60c9917" + integrity sha512-LnL6Z3GGDPht/AigwRh2dvL9PQPFQ8skEpVrWZXLWBYmqcaojHNN0onvHzie6rq7EWKrrBfPYqNEzTJgiwEQDQ== + webpack-sources@1.4.3, webpack-sources@^1.1.0, webpack-sources@^1.2.0, webpack-sources@^1.3.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" @@ -25629,6 +25928,11 @@ webpack-sources@1.4.3, webpack-sources@^1.1.0, webpack-sources@^1.2.0, webpack-s source-list-map "^2.0.0" source-map "~0.6.1" +webpack-sources@^3.0.2: + version "3.2.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.1.tgz#251a7d9720d75ada1469ca07dbb62f3641a05b6d" + integrity sha512-t6BMVLQ0AkjBOoRTZgqrWm7xbXMBzD+XDq2EZ96+vMfn3qKgsvdXZhbPZ4ElUOpdv4u+iiGe+w3+J75iy/bYGA== + webpack-sources@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.0.tgz#b16973bcf844ebcdb3afde32eda1c04d0b90f89d" @@ -25707,6 +26011,66 @@ webpack@5.50.0: watchpack "^2.2.0" webpack-sources "^3.2.0" +webpack@^5.37.0: + version "5.58.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.58.0.tgz#9ec621cf8534f23c25e779e7c35dfde1211d5ccb" + integrity sha512-xc2k5MLbR1iah24Z5xUm1nBh1PZXEdUnrX6YkTSOScq/VWbl5JCLREXJzGYqEAUbIO8tZI+Dzv82lGtnuUnVCQ== + dependencies: + "@types/eslint-scope" "^3.7.0" + "@types/estree" "^0.0.50" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + acorn "^8.4.1" + acorn-import-assertions "^1.7.6" + browserslist "^4.14.5" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.8.3" + es-module-lexer "^0.9.0" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.4" + json-parse-better-errors "^1.0.2" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.1.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.1.3" + watchpack "^2.2.0" + webpack-sources "^3.2.0" + +webpack@^5.58.1: + version "5.58.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.58.1.tgz#df8aad72b617a9d0db8c89d4f410784ee93320d7" + integrity sha512-4Z/dmbTU+VmkCb2XNgW7wkE5TfEcSooclprn/UEuVeAkwHhn07OcgUsyaKHGtCY/VobjnsYBlyhKeMLiSoOqPg== + dependencies: + "@types/eslint-scope" "^3.7.0" + "@types/estree" "^0.0.50" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + acorn "^8.4.1" + acorn-import-assertions "^1.7.6" + browserslist "^4.14.5" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.8.3" + es-module-lexer "^0.9.0" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.4" + json-parse-better-errors "^1.0.2" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.1.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.1.3" + watchpack "^2.2.0" + webpack-sources "^3.2.0" + websocket-driver@>=0.5.1, websocket-driver@^0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" @@ -25936,6 +26300,11 @@ ws@^7.4.5: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.0.tgz#0033bafea031fb9df041b2026fc72a571ca44691" integrity sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw== +ws@^8.1.0: + version "8.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" + integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== + ws@~3.3.1: version "3.3.3" resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"