feat(core): upgrade to webpack 5 (#7283)
* feat(core): upgrade to webpack 5 * chore(core): update webpack 5 docs
This commit is contained in:
parent
9d2a304b11
commit
724b0c0e3c
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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",
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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 <div className={styles.container}>Hello</div>;
|
||||
}
|
||||
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`);
|
||||
|
||||
@ -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);
|
||||
});
|
||||
@ -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(
|
||||
`<link rel="stylesheet" href="styles.css">`
|
||||
);
|
||||
|
||||
if (isNotWindows() && runCypressTests()) {
|
||||
const e2eResults = runCLI(`e2e ${appName}-e2e --headless --no-watch`);
|
||||
expect(e2eResults).toContain('All specs passed!');
|
||||
expect(await killPorts()).toBeTruthy();
|
||||
}
|
||||
}, 500000);
|
||||
});
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ All projects
|
||||
|
||||
### base
|
||||
|
||||
Base of the current branch (usually master)
|
||||
Base of the current branch (usually main)
|
||||
|
||||
### configuration
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
28
package.json
28
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"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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: {
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
module.exports = function (useShim = true) {
|
||||
return {
|
||||
nodeExternals: require('webpack-node-externals'),
|
||||
};
|
||||
};
|
||||
@ -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'),
|
||||
};
|
||||
};
|
||||
@ -1 +0,0 @@
|
||||
TODO(jack): Delete for Nx 13
|
||||
@ -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')());
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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": {
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
100
packages/next/plugins/with-stylus.ts
Normal file
100
packages/next/plugins/with-stylus.ts
Normal file
@ -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 === '(?<!\\.module)\\.(scss|sass)$') {
|
||||
sassGlobalRule = rule;
|
||||
}
|
||||
});
|
||||
|
||||
const stylusLoader = {
|
||||
loader: 'stylus-loader',
|
||||
options: {
|
||||
...stylusLoaderOptions,
|
||||
stylusOptions: {
|
||||
javascriptEnabled: true,
|
||||
...stylusLoaderOptions.stylusOptions,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let stylusModuleRule = merge({}, sassModuleRule);
|
||||
|
||||
const configureStylusRule = (rule) => {
|
||||
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;
|
||||
@ -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]));
|
||||
});
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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/);
|
||||
});
|
||||
});
|
||||
@ -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;
|
||||
@ -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',
|
||||
});
|
||||
|
||||
@ -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: {},
|
||||
},
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -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));
|
||||
}),
|
||||
|
||||
@ -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/);
|
||||
});
|
||||
});
|
||||
@ -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
|
||||
);
|
||||
@ -1,9 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/schema",
|
||||
"$id": "NxNxMigrateToWebpack5",
|
||||
"cli": "nx",
|
||||
"title": "Migrate to webpack 5",
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user