feat(nextjs): support next 11 (#6131)
This commit is contained in:
parent
442e4fc6a1
commit
434e2915f0
@ -146,6 +146,7 @@ describe('Next.js Applications', () => {
|
|||||||
updateFile(
|
updateFile(
|
||||||
mainPath,
|
mainPath,
|
||||||
`
|
`
|
||||||
|
/* eslint-disable */
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
const DynamicComponent = dynamic(
|
const DynamicComponent = dynamic(
|
||||||
() => import('@${proj}/${libName}').then(d => d.${stringUtils.capitalize(
|
() => import('@${proj}/${libName}').then(d => d.${stringUtils.capitalize(
|
||||||
@ -358,9 +359,6 @@ describe('Next.js Applications', () => {
|
|||||||
`apps/${appName}/next.config.js`,
|
`apps/${appName}/next.config.js`,
|
||||||
`
|
`
|
||||||
module.exports = {
|
module.exports = {
|
||||||
future: {
|
|
||||||
webpack5: false,
|
|
||||||
},
|
|
||||||
webpack: (c) => {
|
webpack: (c) => {
|
||||||
console.log('NODE_ENV is', process.env.NODE_ENV);
|
console.log('NODE_ENV is', process.env.NODE_ENV);
|
||||||
return c;
|
return c;
|
||||||
@ -459,7 +457,7 @@ describe('Next.js Applications', () => {
|
|||||||
});
|
});
|
||||||
}, 120000);
|
}, 120000);
|
||||||
|
|
||||||
it('webpack5 - should be able to consume a react libs (buildable and non-buildable)', async () => {
|
it('webpack4 - should be able to consume a react libs (buildable and non-buildable)', async () => {
|
||||||
if (isNotWindows()) {
|
if (isNotWindows()) {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
const buildableLibName = uniq('lib');
|
const buildableLibName = uniq('lib');
|
||||||
@ -488,16 +486,13 @@ describe('Next.js Applications', () => {
|
|||||||
`
|
`
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const withNx = require('@nrwl/next/plugins/with-nx');
|
const withNx = require('@nrwl/next/plugins/with-nx');
|
||||||
|
|
||||||
module.exports = withNx({
|
module.exports = withNx({
|
||||||
nx: {
|
nx: {
|
||||||
// Set this to false if you do not want to use SVGR
|
// Set this to false if you do not want to use SVGR
|
||||||
// See: https://github.com/gregberge/svgr
|
// See: https://github.com/gregberge/svgr
|
||||||
svgr: true,
|
svgr: true,
|
||||||
},
|
},
|
||||||
future: {
|
webpack5: false
|
||||||
webpack5: true
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
@ -524,12 +519,12 @@ describe('Next.js Applications', () => {
|
|||||||
checkUnitTest: true,
|
checkUnitTest: true,
|
||||||
checkLint: true,
|
checkLint: true,
|
||||||
checkE2E: true,
|
checkE2E: true,
|
||||||
checkWebpack5: true,
|
checkWebpack4: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 300000);
|
}, 300000);
|
||||||
|
|
||||||
it('webpack5 - should build with a next.config.js file in the dist folder', async () => {
|
it('webpack4 - should build with a next.config.js file in the dist folder', async () => {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
|
|
||||||
runCLI(`generate @nrwl/next:app ${appName} --no-interactive --style=css`);
|
runCLI(`generate @nrwl/next:app ${appName} --no-interactive --style=css`);
|
||||||
@ -538,9 +533,7 @@ describe('Next.js Applications', () => {
|
|||||||
`apps/${appName}/next.config.js`,
|
`apps/${appName}/next.config.js`,
|
||||||
`
|
`
|
||||||
module.exports = {
|
module.exports = {
|
||||||
future: {
|
webpack5: false,
|
||||||
webpack5: true,
|
|
||||||
},
|
|
||||||
webpack: (c) => {
|
webpack: (c) => {
|
||||||
console.log('NODE_ENV is', process.env.NODE_ENV);
|
console.log('NODE_ENV is', process.env.NODE_ENV);
|
||||||
return c;
|
return c;
|
||||||
@ -556,7 +549,6 @@ describe('Next.js Applications', () => {
|
|||||||
|
|
||||||
checkFilesExist(`dist/apps/${appName}/next.config.js`);
|
checkFilesExist(`dist/apps/${appName}/next.config.js`);
|
||||||
expect(result).toContain('NODE_ENV is production');
|
expect(result).toContain('NODE_ENV is production');
|
||||||
expect(result).toContain('Using webpack 5');
|
|
||||||
}, 120000);
|
}, 120000);
|
||||||
|
|
||||||
it('should allow using a custom server implementation in TypeScript', async () => {
|
it('should allow using a custom server implementation in TypeScript', async () => {
|
||||||
@ -644,12 +636,12 @@ async function checkApp(
|
|||||||
checkUnitTest: boolean;
|
checkUnitTest: boolean;
|
||||||
checkLint: boolean;
|
checkLint: boolean;
|
||||||
checkE2E: boolean;
|
checkE2E: boolean;
|
||||||
checkWebpack5?: boolean;
|
checkWebpack4?: boolean;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const buildResult = runCLI(`build ${appName} --withDeps`);
|
const buildResult = runCLI(`build ${appName} --withDeps`);
|
||||||
if (opts.checkWebpack5) {
|
if (opts.checkWebpack4) {
|
||||||
expect(buildResult).toContain('Using webpack 5');
|
expect(buildResult).toContain('Using webpack 4');
|
||||||
}
|
}
|
||||||
expect(buildResult).toContain(`Compiled successfully`);
|
expect(buildResult).toContain(`Compiled successfully`);
|
||||||
checkFilesExist(`dist/apps/${appName}/.next/build-manifest.json`);
|
checkFilesExist(`dist/apps/${appName}/.next/build-manifest.json`);
|
||||||
|
|||||||
@ -46,6 +46,7 @@
|
|||||||
"@angular/router": "^12.0.0",
|
"@angular/router": "^12.0.0",
|
||||||
"@angular/service-worker": "^12.0.0",
|
"@angular/service-worker": "^12.0.0",
|
||||||
"@angular/upgrade": "^12.0.0",
|
"@angular/upgrade": "^12.0.0",
|
||||||
|
"@babel/helper-create-regexp-features-plugin": "^7.14.5",
|
||||||
"@cypress/webpack-preprocessor": "4.1.5",
|
"@cypress/webpack-preprocessor": "4.1.5",
|
||||||
"@nestjs/common": "^7.0.0",
|
"@nestjs/common": "^7.0.0",
|
||||||
"@nestjs/core": "^7.0.0",
|
"@nestjs/core": "^7.0.0",
|
||||||
@ -131,6 +132,7 @@
|
|||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"eslint": "7.10.0",
|
"eslint": "7.10.0",
|
||||||
|
"eslint-config-next": "^11.0.1",
|
||||||
"eslint-config-prettier": "^8.1.0",
|
"eslint-config-prettier": "^8.1.0",
|
||||||
"eslint-plugin-cypress": "^2.10.3",
|
"eslint-plugin-cypress": "^2.10.3",
|
||||||
"eslint-plugin-import": "2.22.1",
|
"eslint-plugin-import": "2.22.1",
|
||||||
|
|||||||
@ -42,6 +42,12 @@
|
|||||||
"version": "11.6.0-beta.0",
|
"version": "11.6.0-beta.0",
|
||||||
"description": "Add js patterns to tsconfig.json",
|
"description": "Add js patterns to tsconfig.json",
|
||||||
"factory": "./src/migrations/update-11-6-0/add-js-include-11-6-0"
|
"factory": "./src/migrations/update-11-6-0/add-js-include-11-6-0"
|
||||||
|
},
|
||||||
|
"add-next-eslint-12.6.0": {
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "12.6.0-beta.0",
|
||||||
|
"description": "Add 'next' eslint config",
|
||||||
|
"factory": "./src/migrations/update-12-6-0/add-next-eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageJsonUpdates": {
|
"packageJsonUpdates": {
|
||||||
@ -119,6 +125,15 @@
|
|||||||
"alwaysAddToPackageJson": false
|
"alwaysAddToPackageJson": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"12.6.0": {
|
||||||
|
"version": "12.6.0-beta.0",
|
||||||
|
"packages": {
|
||||||
|
"next": {
|
||||||
|
"version": "11.0.1",
|
||||||
|
"alwaysAddToPackageJson": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
"migrations": "./migrations.json"
|
"migrations": "./migrations.json"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"next": "^10.2.0"
|
"next": "^11.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-decorators": "7.12.13",
|
"@babel/plugin-proposal-decorators": "7.12.13",
|
||||||
@ -41,6 +41,7 @@
|
|||||||
"@nrwl/workspace": "*",
|
"@nrwl/workspace": "*",
|
||||||
"@svgr/webpack": "^5.5.0",
|
"@svgr/webpack": "^5.5.0",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
|
"eslint-config-next": "^11.0.1",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"url-loader": "^3.0.0",
|
"url-loader": "^3.0.0",
|
||||||
"tsconfig-paths": "^3.9.0",
|
"tsconfig-paths": "^3.9.0",
|
||||||
|
|||||||
@ -310,9 +310,14 @@ describe('app', () => {
|
|||||||
const eslintJson = readJson(tree, '/apps/my-app/.eslintrc.json');
|
const eslintJson = readJson(tree, '/apps/my-app/.eslintrc.json');
|
||||||
expect(eslintJson).toMatchInlineSnapshot(`
|
expect(eslintJson).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
|
"env": Object {
|
||||||
|
"jest": true,
|
||||||
|
},
|
||||||
"extends": Array [
|
"extends": Array [
|
||||||
"plugin:@nrwl/nx/react",
|
"plugin:@nrwl/nx/react-typescript",
|
||||||
"../../.eslintrc.json",
|
"../../.eslintrc.json",
|
||||||
|
"next",
|
||||||
|
"next/core-web-vitals",
|
||||||
],
|
],
|
||||||
"ignorePatterns": Array [
|
"ignorePatterns": Array [
|
||||||
"!**/*",
|
"!**/*",
|
||||||
|
|||||||
@ -4,3 +4,15 @@ declare module '*.svg' {
|
|||||||
export const ReactComponent: any;
|
export const ReactComponent: any;
|
||||||
export default content;
|
export default content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<% if (style === 'less') { %>
|
||||||
|
declare module '*.module.less' {
|
||||||
|
const classes: { readonly [key: string]: string };
|
||||||
|
export default classes;
|
||||||
|
}
|
||||||
|
<% } else if (style === 'styl') { %>
|
||||||
|
declare module '*.module.styl' {
|
||||||
|
const classes: { readonly [key: string]: string };
|
||||||
|
export default classes;
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|||||||
@ -1,13 +1,3 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
/// <reference types="next/types/global" />
|
||||||
<% if (style === 'less') { %>
|
/// <reference types="next/image-types/global" />
|
||||||
declare module '*.module.less' {
|
|
||||||
const classes: { readonly [key: string]: string };
|
|
||||||
export default classes;
|
|
||||||
}
|
|
||||||
<% } else if (style === 'styl') { %>
|
|
||||||
declare module '*.module.styl' {
|
|
||||||
const classes: { readonly [key: string]: string };
|
|
||||||
export default classes;
|
|
||||||
}
|
|
||||||
<% } %>
|
|
||||||
|
|||||||
@ -15,7 +15,9 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
// Set this to true if you use CSS modules.
|
// Set this to true if you use CSS modules.
|
||||||
// See: https://github.com/css-modules/css-modules
|
// See: https://github.com/css-modules/css-modules
|
||||||
cssModules: false
|
cssModules: false,
|
||||||
|
// @zeit/next-less does not support webpack 5
|
||||||
|
webpack5: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = withLess(withNx(nextConfig));
|
module.exports = withLess(withNx(nextConfig));
|
||||||
@ -33,7 +35,9 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
// Set this to true if you use CSS modules.
|
// Set this to true if you use CSS modules.
|
||||||
// See: https://github.com/css-modules/css-modules
|
// See: https://github.com/css-modules/css-modules
|
||||||
cssModules: false
|
cssModules: false,
|
||||||
|
// @zeit/next-stylus does not support webpack 5
|
||||||
|
webpack5: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = withStylus(withNx(nextConfig));
|
module.exports = withStylus(withNx(nextConfig));
|
||||||
|
|||||||
@ -39,6 +39,23 @@ export async function addLinting(
|
|||||||
`${options.appProjectRoot}/tsconfig(.*)?.json`,
|
`${options.appProjectRoot}/tsconfig(.*)?.json`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
if (!reactEslintJson.extends) {
|
||||||
|
reactEslintJson.extends = [];
|
||||||
|
}
|
||||||
|
if (typeof reactEslintJson.extends === 'string') {
|
||||||
|
reactEslintJson.extends = [reactEslintJson.extends];
|
||||||
|
}
|
||||||
|
// add next.js configuration
|
||||||
|
reactEslintJson.extends.push(...['next', 'next/core-web-vitals']);
|
||||||
|
// remove nx/react plugin, as it conflicts with the next.js one
|
||||||
|
reactEslintJson.extends = reactEslintJson.extends.filter(
|
||||||
|
(name) => name !== 'plugin:@nrwl/nx/react'
|
||||||
|
);
|
||||||
|
reactEslintJson.extends.unshift('plugin:@nrwl/nx/react-typescript');
|
||||||
|
if (!reactEslintJson.env) {
|
||||||
|
reactEslintJson.env = {};
|
||||||
|
}
|
||||||
|
reactEslintJson.env.jest = true;
|
||||||
return reactEslintJson;
|
return reactEslintJson;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export function createAppJsx(name: string) {
|
|||||||
<div className="flex github-star-container">
|
<div className="flex github-star-container">
|
||||||
<a href="https://github.com/nrwl/nx" target="_blank" rel="noopener noreferrer"> If you like Nx, please give it a star:
|
<a href="https://github.com/nrwl/nx" target="_blank" rel="noopener noreferrer"> If you like Nx, please give it a star:
|
||||||
<div className="github-star-badge">
|
<div className="github-star-badge">
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img src="/star.svg" className="material-icons" alt="" />
|
<img src="/star.svg" className="material-icons" alt="" />
|
||||||
Star
|
Star
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -11,7 +11,11 @@ import { jestInitGenerator } from '@nrwl/jest';
|
|||||||
import { cypressInitGenerator } from '@nrwl/cypress';
|
import { cypressInitGenerator } from '@nrwl/cypress';
|
||||||
import { reactDomVersion, reactInitGenerator, reactVersion } from '@nrwl/react';
|
import { reactDomVersion, reactInitGenerator, reactVersion } from '@nrwl/react';
|
||||||
|
|
||||||
import { nextVersion, nxVersion } from '../../utils/versions';
|
import {
|
||||||
|
eslintConfigNextVersion,
|
||||||
|
nextVersion,
|
||||||
|
nxVersion,
|
||||||
|
} from '../../utils/versions';
|
||||||
import { InitSchema } from './schema';
|
import { InitSchema } from './schema';
|
||||||
|
|
||||||
function updateDependencies(host: Tree) {
|
function updateDependencies(host: Tree) {
|
||||||
@ -31,7 +35,9 @@ function updateDependencies(host: Tree) {
|
|||||||
'react-dom': reactDomVersion,
|
'react-dom': reactDomVersion,
|
||||||
tslib: '^2.0.0',
|
tslib: '^2.0.0',
|
||||||
},
|
},
|
||||||
{}
|
{
|
||||||
|
'eslint-config-next': eslintConfigNextVersion,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,214 @@
|
|||||||
|
import { readJson, Tree } from '@nrwl/devkit';
|
||||||
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
|
import addNextEslint from './add-next-eslint';
|
||||||
|
|
||||||
|
describe('Add next eslint 12.6.0', () => {
|
||||||
|
let tree: Tree;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
tree = createTreeWithEmptyWorkspace();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add "next" config options', async () => {
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {
|
||||||
|
root: 'apps/app1',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/next:build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'nx.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'apps/app1/.eslintrc.json',
|
||||||
|
JSON.stringify({
|
||||||
|
extends: ['../../.eslintrc.json'],
|
||||||
|
ignorePatterns: ['!**/*'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
const result = readJson(tree, 'apps/app1/.eslintrc.json');
|
||||||
|
expect(result.extends).toContain('next');
|
||||||
|
expect(result.extends).toContain('next/core-web-vitals');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add "next" config options when no "extends" property is present', async () => {
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {
|
||||||
|
root: 'apps/app1',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/next:build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'nx.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'apps/app1/.eslintrc.json',
|
||||||
|
JSON.stringify({
|
||||||
|
ignorePatterns: ['!**/*'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
const result = readJson(tree, 'apps/app1/.eslintrc.json');
|
||||||
|
expect(result.extends).toContain('next');
|
||||||
|
expect(result.extends).toContain('next/core-web-vitals');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add "next" config options when "extends" property is a string', async () => {
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {
|
||||||
|
root: 'apps/app1',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/next:build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'nx.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'apps/app1/.eslintrc.json',
|
||||||
|
JSON.stringify({
|
||||||
|
extends: '../../.eslintrc.json',
|
||||||
|
ignorePatterns: ['!**/*'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
const result = readJson(tree, 'apps/app1/.eslintrc.json');
|
||||||
|
expect(result.extends).toContain('next');
|
||||||
|
expect(result.extends).toContain('next/core-web-vitals');
|
||||||
|
expect(result.extends).toContain('../../.eslintrc.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not change projects that are not next.js', async () => {
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {
|
||||||
|
root: 'apps/app1',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/web:build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'nx.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'apps/app1/.eslintrc.json',
|
||||||
|
JSON.stringify({
|
||||||
|
extends: '../../.eslintrc.json',
|
||||||
|
ignorePatterns: ['!**/*'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
expect(readJson(tree, 'apps/app1/.eslintrc.json')).toMatchObject({
|
||||||
|
extends: '../../.eslintrc.json',
|
||||||
|
ignorePatterns: ['!**/*'],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove nx/react eslint plugin', async () => {
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {
|
||||||
|
root: 'apps/app1',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/next:build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'nx.json',
|
||||||
|
JSON.stringify({
|
||||||
|
projects: {
|
||||||
|
app1: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tree.write(
|
||||||
|
'apps/app1/.eslintrc.json',
|
||||||
|
JSON.stringify({
|
||||||
|
extends: ['plugin:@nrwl/nx/react', '../../.eslintrc.json'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
expect(readJson(tree, 'apps/app1/.eslintrc.json').extends).not.toContain(
|
||||||
|
'plugin:@nrwl/nx/react'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add eslint-config-next to dev dependencies', async () => {
|
||||||
|
await addNextEslint(tree);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
readJson(tree, 'package.json').devDependencies['eslint-config-next']
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
import { formatFiles, getProjects, Tree, updateJson } from '@nrwl/devkit';
|
||||||
|
import { eslintConfigNextVersion } from '../../utils/versions';
|
||||||
|
|
||||||
|
export async function addNextEslint(host: Tree) {
|
||||||
|
const projects = getProjects(host);
|
||||||
|
|
||||||
|
projects.forEach((project) => {
|
||||||
|
if (project.targets?.build?.executor !== '@nrwl/next:build') return;
|
||||||
|
|
||||||
|
const eslintPath = `${project.root}/.eslintrc.json`;
|
||||||
|
if (!host.exists(eslintPath)) return;
|
||||||
|
|
||||||
|
updateJson(host, eslintPath, (eslintConfig) => {
|
||||||
|
if (!eslintConfig.extends) {
|
||||||
|
eslintConfig.extends = [];
|
||||||
|
}
|
||||||
|
if (typeof eslintConfig.extends === 'string') {
|
||||||
|
eslintConfig.extends = [eslintConfig.extends];
|
||||||
|
}
|
||||||
|
// add next.js configuration
|
||||||
|
eslintConfig.extends.push(...['next', 'next/core-web-vitals']);
|
||||||
|
// remove nx/react plugin, as it conflicts with the next.js one
|
||||||
|
eslintConfig.extends = eslintConfig.extends.filter(
|
||||||
|
(name) => name !== 'plugin:@nrwl/nx/react'
|
||||||
|
);
|
||||||
|
eslintConfig.extends.unshift('plugin:@nrwl/nx/react-typescript');
|
||||||
|
if (!eslintConfig.env) {
|
||||||
|
eslintConfig.env = {};
|
||||||
|
}
|
||||||
|
eslintConfig.env.jest = true;
|
||||||
|
return eslintConfig;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
updateJson(host, 'package.json', (packageJsonContents) => {
|
||||||
|
if (!packageJsonContents.devDependencies) {
|
||||||
|
packageJsonContents.devDependencies = {};
|
||||||
|
}
|
||||||
|
packageJsonContents.devDependencies['eslint-config-next'] =
|
||||||
|
eslintConfigNextVersion;
|
||||||
|
return packageJsonContents;
|
||||||
|
});
|
||||||
|
|
||||||
|
await formatFiles(host);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default addNextEslint;
|
||||||
@ -1,6 +1,7 @@
|
|||||||
export const nxVersion = '*';
|
export const nxVersion = '*';
|
||||||
|
|
||||||
export const nextVersion = '10.2.0';
|
export const nextVersion = '11.0.1';
|
||||||
|
export const eslintConfigNextVersion = '11.0.1';
|
||||||
export const nodeSass = '5.0.0';
|
export const nodeSass = '5.0.0';
|
||||||
export const zeitNextLess = '1.0.1';
|
export const zeitNextLess = '1.0.1';
|
||||||
export const zeitNextStylus = '1.0.1';
|
export const zeitNextStylus = '1.0.1';
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { logger } from '@nrwl/devkit';
|
import { logger } from '@nrwl/devkit';
|
||||||
import { requireShim } from './require-shim';
|
import { requireShim } from './require-shim';
|
||||||
|
|
||||||
const { version } = requireShim('webpack/package.json');
|
const result = requireShim('webpack/package.json');
|
||||||
|
const version = result?.version;
|
||||||
|
|
||||||
exports.default = undefined;
|
exports.default = undefined;
|
||||||
|
|
||||||
|
|||||||
90
yarn.lock
90
yarn.lock
@ -714,6 +714,14 @@
|
|||||||
"@babel/helper-annotate-as-pure" "^7.12.13"
|
"@babel/helper-annotate-as-pure" "^7.12.13"
|
||||||
regexpu-core "^4.7.1"
|
regexpu-core "^4.7.1"
|
||||||
|
|
||||||
|
"@babel/helper-create-regexp-features-plugin@^7.14.5":
|
||||||
|
version "7.14.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.14.5.tgz#c7d5ac5e9cf621c26057722fb7a8a4c5889358c4"
|
||||||
|
integrity sha512-TLawwqpOErY2HhWbGJ2nZT5wSkR192QpN+nBg1THfBfftrlvOh+WbhrxXCH4q4xJ9Gl16BGPR/48JA+Ryiho/A==
|
||||||
|
dependencies:
|
||||||
|
"@babel/helper-annotate-as-pure" "^7.14.5"
|
||||||
|
regexpu-core "^4.7.1"
|
||||||
|
|
||||||
"@babel/helper-define-polyfill-provider@^0.1.5":
|
"@babel/helper-define-polyfill-provider@^0.1.5":
|
||||||
version "0.1.5"
|
version "0.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.1.5.tgz#3c2f91b7971b9fc11fe779c945c014065dea340e"
|
resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.1.5.tgz#3c2f91b7971b9fc11fe779c945c014065dea340e"
|
||||||
@ -3194,6 +3202,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@next/env/-/env-10.2.0.tgz#154dbce2efa3ad067ebd20b7d0aa9aed775e7c97"
|
resolved "https://registry.yarnpkg.com/@next/env/-/env-10.2.0.tgz#154dbce2efa3ad067ebd20b7d0aa9aed775e7c97"
|
||||||
integrity sha512-tsWBsn1Rb6hXRaHc/pWMCpZ4Ipkf3OCbZ54ef5ukgIyEvzzGdGFXQshPP2AF7yb+8yMpunWs7vOMZW3e8oPF6A==
|
integrity sha512-tsWBsn1Rb6hXRaHc/pWMCpZ4Ipkf3OCbZ54ef5ukgIyEvzzGdGFXQshPP2AF7yb+8yMpunWs7vOMZW3e8oPF6A==
|
||||||
|
|
||||||
|
"@next/eslint-plugin-next@11.0.1":
|
||||||
|
version "11.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-11.0.1.tgz#5dd3264a40fadcf28eba00d914d69103422bb7e6"
|
||||||
|
integrity sha512-UzdX3y6XSrj9YuASUb/p4sRvfjP2klj2YgIOfMwrWoLTTPJQMh00hREB9Ftr7m7RIxjVSAaaLXIRLdxvq948GA==
|
||||||
|
|
||||||
"@next/polyfill-module@10.2.0":
|
"@next/polyfill-module@10.2.0":
|
||||||
version "10.2.0"
|
version "10.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-10.2.0.tgz#61f41110c4b465cc26d113e2054e205df61c3594"
|
resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-10.2.0.tgz#61f41110c4b465cc26d113e2054e205df61c3594"
|
||||||
@ -3819,6 +3832,11 @@
|
|||||||
estree-walker "^2.0.1"
|
estree-walker "^2.0.1"
|
||||||
picomatch "^2.2.2"
|
picomatch "^2.2.2"
|
||||||
|
|
||||||
|
"@rushstack/eslint-patch@^1.0.6":
|
||||||
|
version "1.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.0.6.tgz#023d72a5c4531b4ce204528971700a78a85a0c50"
|
||||||
|
integrity sha512-Myxw//kzromB9yWgS8qYGuGVf91oBUUJpNvy5eM50sqvmKLbKjwLxohJnkWGTeeI9v9IBMtPLxz5Gc60FIfvCA==
|
||||||
|
|
||||||
"@samverschueren/stream-to-observable@^0.3.0":
|
"@samverschueren/stream-to-observable@^0.3.0":
|
||||||
version "0.3.1"
|
version "0.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz#a21117b19ee9be70c379ec1877537ef2e1c63301"
|
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz#a21117b19ee9be70c379ec1877537ef2e1c63301"
|
||||||
@ -5480,6 +5498,16 @@
|
|||||||
eslint-scope "^5.0.0"
|
eslint-scope "^5.0.0"
|
||||||
eslint-utils "^2.0.0"
|
eslint-utils "^2.0.0"
|
||||||
|
|
||||||
|
"@typescript-eslint/parser@^4.20.0":
|
||||||
|
version "4.28.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.0.tgz#2404c16751a28616ef3abab77c8e51d680a12caa"
|
||||||
|
integrity sha512-7x4D22oPY8fDaOCvkuXtYYTQ6mTMmkivwEzS+7iml9F9VkHGbbZ3x4fHRwxAb5KeuSkLqfnYjs46tGx2Nour4A==
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/scope-manager" "4.28.0"
|
||||||
|
"@typescript-eslint/types" "4.28.0"
|
||||||
|
"@typescript-eslint/typescript-estree" "4.28.0"
|
||||||
|
debug "^4.3.1"
|
||||||
|
|
||||||
"@typescript-eslint/parser@^4.3.0":
|
"@typescript-eslint/parser@^4.3.0":
|
||||||
version "4.17.0"
|
version "4.17.0"
|
||||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.17.0.tgz#141b647ffc72ebebcbf9b0fe6087f65b706d3215"
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.17.0.tgz#141b647ffc72ebebcbf9b0fe6087f65b706d3215"
|
||||||
@ -5506,6 +5534,14 @@
|
|||||||
"@typescript-eslint/types" "4.23.0"
|
"@typescript-eslint/types" "4.23.0"
|
||||||
"@typescript-eslint/visitor-keys" "4.23.0"
|
"@typescript-eslint/visitor-keys" "4.23.0"
|
||||||
|
|
||||||
|
"@typescript-eslint/scope-manager@4.28.0":
|
||||||
|
version "4.28.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.0.tgz#6a3009d2ab64a30fc8a1e257a1a320067f36a0ce"
|
||||||
|
integrity sha512-eCALCeScs5P/EYjwo6se9bdjtrh8ByWjtHzOkC4Tia6QQWtQr3PHovxh3TdYTuFcurkYI4rmFsRFpucADIkseg==
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types" "4.28.0"
|
||||||
|
"@typescript-eslint/visitor-keys" "4.28.0"
|
||||||
|
|
||||||
"@typescript-eslint/types@4.17.0":
|
"@typescript-eslint/types@4.17.0":
|
||||||
version "4.17.0"
|
version "4.17.0"
|
||||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.17.0.tgz#f57d8fc7f31b348db946498a43050083d25f40ad"
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.17.0.tgz#f57d8fc7f31b348db946498a43050083d25f40ad"
|
||||||
@ -5516,6 +5552,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b"
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b"
|
||||||
integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw==
|
integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw==
|
||||||
|
|
||||||
|
"@typescript-eslint/types@4.28.0":
|
||||||
|
version "4.28.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.0.tgz#a33504e1ce7ac51fc39035f5fe6f15079d4dafb0"
|
||||||
|
integrity sha512-p16xMNKKoiJCVZY5PW/AfILw2xe1LfruTcfAKBj3a+wgNYP5I9ZEKNDOItoRt53p4EiPV6iRSICy8EPanG9ZVA==
|
||||||
|
|
||||||
"@typescript-eslint/typescript-estree@4.17.0":
|
"@typescript-eslint/typescript-estree@4.17.0":
|
||||||
version "4.17.0"
|
version "4.17.0"
|
||||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.17.0.tgz#b835d152804f0972b80dbda92477f9070a72ded1"
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.17.0.tgz#b835d152804f0972b80dbda92477f9070a72ded1"
|
||||||
@ -5542,6 +5583,19 @@
|
|||||||
semver "^7.3.2"
|
semver "^7.3.2"
|
||||||
tsutils "^3.17.1"
|
tsutils "^3.17.1"
|
||||||
|
|
||||||
|
"@typescript-eslint/typescript-estree@4.28.0":
|
||||||
|
version "4.28.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.0.tgz#e66d4e5aa2ede66fec8af434898fe61af10c71cf"
|
||||||
|
integrity sha512-m19UQTRtxMzKAm8QxfKpvh6OwQSXaW1CdZPoCaQuLwAq7VZMNuhJmZR4g5281s2ECt658sldnJfdpSZZaxUGMQ==
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types" "4.28.0"
|
||||||
|
"@typescript-eslint/visitor-keys" "4.28.0"
|
||||||
|
debug "^4.3.1"
|
||||||
|
globby "^11.0.3"
|
||||||
|
is-glob "^4.0.1"
|
||||||
|
semver "^7.3.5"
|
||||||
|
tsutils "^3.21.0"
|
||||||
|
|
||||||
"@typescript-eslint/visitor-keys@4.17.0":
|
"@typescript-eslint/visitor-keys@4.17.0":
|
||||||
version "4.17.0"
|
version "4.17.0"
|
||||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.17.0.tgz#9c304cfd20287c14a31d573195a709111849b14d"
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.17.0.tgz#9c304cfd20287c14a31d573195a709111849b14d"
|
||||||
@ -5558,6 +5612,14 @@
|
|||||||
"@typescript-eslint/types" "4.23.0"
|
"@typescript-eslint/types" "4.23.0"
|
||||||
eslint-visitor-keys "^2.0.0"
|
eslint-visitor-keys "^2.0.0"
|
||||||
|
|
||||||
|
"@typescript-eslint/visitor-keys@4.28.0":
|
||||||
|
version "4.28.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.0.tgz#255c67c966ec294104169a6939d96f91c8a89434"
|
||||||
|
integrity sha512-PjJyTWwrlrvM5jazxYF5ZPs/nl0kHDZMVbuIcbpawVXaDPelp3+S9zpOz5RmVUfS/fD5l5+ZXNKnWhNYjPzCvw==
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types" "4.28.0"
|
||||||
|
eslint-visitor-keys "^2.0.0"
|
||||||
|
|
||||||
"@verdaccio/commons-api@10.0.0", "@verdaccio/commons-api@^10.0.0":
|
"@verdaccio/commons-api@10.0.0", "@verdaccio/commons-api@^10.0.0":
|
||||||
version "10.0.0"
|
version "10.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@verdaccio/commons-api/-/commons-api-10.0.0.tgz#2d7de8722f94181f1a71891fe91198a7c14e6dea"
|
resolved "https://registry.yarnpkg.com/@verdaccio/commons-api/-/commons-api-10.0.0.tgz#2d7de8722f94181f1a71891fe91198a7c14e6dea"
|
||||||
@ -11580,6 +11642,21 @@ escodegen@^2.0.0:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
source-map "~0.6.1"
|
source-map "~0.6.1"
|
||||||
|
|
||||||
|
eslint-config-next@^11.0.1:
|
||||||
|
version "11.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-11.0.1.tgz#abdd2565a6fa5841556a89ba935f044bec173d0b"
|
||||||
|
integrity sha512-yy63K4Bmy8amE6VMb26CZK6G99cfVX3JaMTvuvmq/LL8/b8vKHcauUZREBTAQ+2DrIvlH4YrFXrkQ1vpYDL9Eg==
|
||||||
|
dependencies:
|
||||||
|
"@next/eslint-plugin-next" "11.0.1"
|
||||||
|
"@rushstack/eslint-patch" "^1.0.6"
|
||||||
|
"@typescript-eslint/parser" "^4.20.0"
|
||||||
|
eslint-import-resolver-node "^0.3.4"
|
||||||
|
eslint-import-resolver-typescript "^2.4.0"
|
||||||
|
eslint-plugin-import "^2.22.1"
|
||||||
|
eslint-plugin-jsx-a11y "^6.4.1"
|
||||||
|
eslint-plugin-react "^7.23.1"
|
||||||
|
eslint-plugin-react-hooks "^4.2.0"
|
||||||
|
|
||||||
eslint-config-prettier@8.3.0:
|
eslint-config-prettier@8.3.0:
|
||||||
version "8.3.0"
|
version "8.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a"
|
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a"
|
||||||
@ -11598,6 +11675,17 @@ eslint-import-resolver-node@^0.3.4:
|
|||||||
debug "^2.6.9"
|
debug "^2.6.9"
|
||||||
resolve "^1.13.1"
|
resolve "^1.13.1"
|
||||||
|
|
||||||
|
eslint-import-resolver-typescript@^2.4.0:
|
||||||
|
version "2.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.4.0.tgz#ec1e7063ebe807f0362a7320543aaed6fe1100e1"
|
||||||
|
integrity sha512-useJKURidCcldRLCNKWemr1fFQL1SzB3G4a0li6lFGvlc5xGe1hY343bvG07cbpCzPuM/lK19FIJB3XGFSkplA==
|
||||||
|
dependencies:
|
||||||
|
debug "^4.1.1"
|
||||||
|
glob "^7.1.6"
|
||||||
|
is-glob "^4.0.1"
|
||||||
|
resolve "^1.17.0"
|
||||||
|
tsconfig-paths "^3.9.0"
|
||||||
|
|
||||||
eslint-module-utils@^2.6.0:
|
eslint-module-utils@^2.6.0:
|
||||||
version "2.6.0"
|
version "2.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6"
|
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6"
|
||||||
@ -24615,7 +24703,7 @@ tsutils@^2.29.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tslib "^1.8.1"
|
tslib "^1.8.1"
|
||||||
|
|
||||||
tsutils@^3.17.1:
|
tsutils@^3.17.1, tsutils@^3.21.0:
|
||||||
version "3.21.0"
|
version "3.21.0"
|
||||||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
|
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
|
||||||
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
|
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user