@nx/next 16.8.0-beta.4 → 16.8.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/plugins/component-testing.d.ts +0 -1
- package/plugins/component-testing.js +14 -8
- package/plugins/with-less.js +19 -14
- package/plugins/with-nx.js +27 -28
- package/plugins/with-stylus.js +18 -14
- package/src/executors/build/build.impl.js +60 -66
- package/src/executors/build/lib/create-next-config-file.js +2 -4
- package/src/executors/build/lib/update-package-json.js +2 -4
- package/src/executors/export/export.impl.js +29 -32
- package/src/executors/server/custom-server.impl.js +27 -45
- package/src/executors/server/server.impl.js +52 -56
- package/src/generators/application/application.js +38 -37
- package/src/generators/application/lib/add-e2e.js +35 -31
- package/src/generators/application/lib/add-jest.js +29 -26
- package/src/generators/application/lib/add-linting.js +50 -47
- package/src/generators/application/lib/add-project.js +3 -1
- package/src/generators/application/lib/create-application-files.js +26 -8
- package/src/generators/application/lib/normalize-options.js +40 -33
- package/src/generators/application/lib/set-defaults.js +5 -7
- package/src/generators/application/lib/update-cypress-tsconfig.js +4 -1
- package/src/generators/component/component.js +16 -13
- package/src/generators/custom-server/custom-server.js +66 -65
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +55 -57
- package/src/generators/init/init.js +36 -33
- package/src/generators/library/lib/normalize-options.js +14 -14
- package/src/generators/library/library.js +52 -47
- package/src/generators/page/page.js +21 -14
- package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.js +23 -24
- package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.js +13 -16
- package/src/migrations/update-13-0-0/update-emotion-setup.js +24 -27
- package/src/migrations/update-13-0-0/update-to-webpack-5.js +20 -23
- package/src/migrations/update-13-0-3/fix-less.js +15 -18
- package/src/migrations/update-13-1-1/enable-swc.js +28 -32
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +22 -27
- package/src/migrations/update-14-4-3/add-dev-output-path.js +11 -15
- package/src/migrations/update-14-5-3/add-gitignore-entry.js +3 -6
- package/src/migrations/update-14-5-3/update-dev-output-path.js +14 -19
- package/src/migrations/update-14-5-7/update-next-eslint.js +18 -22
- package/src/migrations/update-15-8-8/add-style-packages.js +14 -18
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-3-0/remove-root-build-option.js +10 -13
- package/src/migrations/update-16-4-0/update-nx-next-dependency.js +12 -15
- package/src/utils/compose-plugins.js +12 -15
- package/src/utils/create-copy-plugin.js +6 -4
- package/src/utils/generate-globs.js +1 -1
- package/src/utils/styles.js +31 -11
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
-
function normalizeOptions(host, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
callingGenerator: '@nx/next:library',
|
|
15
|
-
});
|
|
16
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
17
|
-
return Object.assign(Object.assign({}, options), { importPath,
|
|
18
|
-
projectRoot });
|
|
5
|
+
async function normalizeOptions(host, options) {
|
|
6
|
+
const { projectRoot, importPath, projectNameAndRootFormat } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
7
|
+
name: options.name,
|
|
8
|
+
projectType: 'library',
|
|
9
|
+
directory: options.directory,
|
|
10
|
+
importPath: options.importPath,
|
|
11
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
|
+
callingGenerator: '@nx/next:library',
|
|
19
13
|
});
|
|
14
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
+
return {
|
|
16
|
+
...options,
|
|
17
|
+
importPath,
|
|
18
|
+
projectRoot,
|
|
19
|
+
};
|
|
20
20
|
}
|
|
21
21
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -1,68 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.librarySchematic = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const library_1 = require("@nx/react/src/generators/library/library");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
8
7
|
const init_1 = require("../init/init");
|
|
9
8
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
|
-
function libraryGenerator(host, rawOptions) {
|
|
11
|
-
return
|
|
12
|
-
|
|
9
|
+
async function libraryGenerator(host, rawOptions) {
|
|
10
|
+
return await libraryGeneratorInternal(host, {
|
|
11
|
+
projectNameAndRootFormat: 'derived',
|
|
12
|
+
...rawOptions,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.libraryGenerator = libraryGenerator;
|
|
16
|
-
function libraryGeneratorInternal(host, rawOptions) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
async function libraryGeneratorInternal(host, rawOptions) {
|
|
17
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, rawOptions);
|
|
18
|
+
const tasks = [];
|
|
19
|
+
const initTask = await (0, init_1.nextInitGenerator)(host, {
|
|
20
|
+
...options,
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
});
|
|
23
|
+
tasks.push(initTask);
|
|
24
|
+
const libTask = await (0, library_1.libraryGenerator)(host, {
|
|
25
|
+
...options,
|
|
26
|
+
compiler: 'swc',
|
|
27
|
+
skipFormat: true,
|
|
28
|
+
});
|
|
29
|
+
tasks.push(libTask);
|
|
30
|
+
const indexPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', `index.${options.js ? 'js' : 'ts'}`);
|
|
31
|
+
const indexContent = host.read(indexPath, 'utf-8');
|
|
32
|
+
host.write(indexPath, `// Use this file to export React client components (e.g. those with 'use client' directive) or other non-server utilities\n${indexContent}`);
|
|
33
|
+
// Additional entry for Next.js libraries so React Server Components are exported from a separate entry point.
|
|
34
|
+
// This is needed because RSC exported from `src/index.ts` will mark the entire file as server-only and throw an error when used from a client component.
|
|
35
|
+
// See: https://github.com/nrwl/nx/issues/15830
|
|
36
|
+
const serverEntryPath = (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'server.' + (options.js ? 'js' : 'ts'));
|
|
37
|
+
host.write((0, devkit_1.joinPathFragments)(options.projectRoot, 'src', `server.${options.js ? 'js' : 'ts'}`), `// Use this file to export React server components
|
|
32
38
|
export * from './lib/hello-server';`);
|
|
33
|
-
|
|
39
|
+
host.write((0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', `hello-server.${options.js ? 'js' : 'tsx'}`), `// React server components are async so you make database or API calls.
|
|
34
40
|
export async function HelloServer() {
|
|
35
41
|
return <h1>Hello Server</h1>
|
|
36
42
|
}
|
|
37
43
|
`);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
json.compilerOptions.types = [
|
|
55
|
-
...json.compilerOptions.types,
|
|
56
|
-
'next',
|
|
57
|
-
'@nx/next/typings/image.d.ts',
|
|
58
|
-
];
|
|
59
|
-
return json;
|
|
60
|
-
});
|
|
61
|
-
if (!options.skipFormat) {
|
|
62
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
44
|
+
(0, js_1.addTsConfigPath)(host, `${options.importPath}/server`, [serverEntryPath]);
|
|
45
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
|
|
46
|
+
if (options.style === '@emotion/styled') {
|
|
47
|
+
json.compilerOptions.jsxImportSource = '@emotion/react';
|
|
48
|
+
}
|
|
49
|
+
return json;
|
|
50
|
+
});
|
|
51
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'), (json) => {
|
|
52
|
+
if (!json.compilerOptions) {
|
|
53
|
+
json.compilerOptions = {
|
|
54
|
+
types: [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (!json.compilerOptions.types) {
|
|
58
|
+
json.compilerOptions.types = [];
|
|
63
59
|
}
|
|
64
|
-
|
|
60
|
+
json.compilerOptions.types = [
|
|
61
|
+
...json.compilerOptions.types,
|
|
62
|
+
'next',
|
|
63
|
+
'@nx/next/typings/image.d.ts',
|
|
64
|
+
];
|
|
65
|
+
return json;
|
|
65
66
|
});
|
|
67
|
+
if (!options.skipFormat) {
|
|
68
|
+
await (0, devkit_1.formatFiles)(host);
|
|
69
|
+
}
|
|
70
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
66
71
|
}
|
|
67
72
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
68
73
|
exports.default = libraryGenerator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pageSchematic = exports.pageGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const react_1 = require("@nx/react");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const styles_1 = require("../../utils/styles");
|
|
@@ -10,19 +9,27 @@ const styles_1 = require("../../utils/styles");
|
|
|
10
9
|
* extra dependencies for css, sass, less, styl style options, and make sure
|
|
11
10
|
* it is under `pages` folder.
|
|
12
11
|
*/
|
|
13
|
-
function pageGenerator(host, schema) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
async function pageGenerator(host, schema) {
|
|
13
|
+
const options = normalizeOptions(host, schema);
|
|
14
|
+
const componentTask = await (0, react_1.componentGenerator)(host, {
|
|
15
|
+
...options,
|
|
16
|
+
project: schema.project,
|
|
17
|
+
pascalCaseFiles: false,
|
|
18
|
+
export: false,
|
|
19
|
+
classComponent: false,
|
|
20
|
+
routing: false,
|
|
21
|
+
skipTests: !options.withTests,
|
|
22
|
+
flat: !!options.flat,
|
|
23
|
+
skipFormat: true,
|
|
25
24
|
});
|
|
25
|
+
const styledTask = (0, styles_1.addStyleDependencies)(host, {
|
|
26
|
+
style: options.style,
|
|
27
|
+
swc: !host.exists((0, devkit_1.joinPathFragments)(options.project.root, '.babelrc')),
|
|
28
|
+
});
|
|
29
|
+
if (!options.skipFormat) {
|
|
30
|
+
await (0, devkit_1.formatFiles)(host);
|
|
31
|
+
}
|
|
32
|
+
return (0, devkit_1.runTasksInSerial)(componentTask, styledTask);
|
|
26
33
|
}
|
|
27
34
|
exports.pageGenerator = pageGenerator;
|
|
28
35
|
function normalizeOptions(host, options) {
|
|
@@ -34,7 +41,7 @@ function normalizeOptions(host, options) {
|
|
|
34
41
|
? `${routerDirectory}/${options.directory}`
|
|
35
42
|
: `${routerDirectory}`;
|
|
36
43
|
const fileName = isAppRouter ? 'page' : !options.flat ? 'index' : undefined;
|
|
37
|
-
return
|
|
44
|
+
return { ...options, project, directory, fileName };
|
|
38
45
|
}
|
|
39
46
|
exports.default = pageGenerator;
|
|
40
47
|
exports.pageSchematic = (0, devkit_1.convertNxGenerator)(pageGenerator);
|
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixPageDirForEslint = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function fixPageDirForEslint(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
async function fixPageDirForEslint(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
projects.forEach((project) => {
|
|
8
|
+
const eslintRcJson = (0, devkit_1.joinPathFragments)(project.root, '.eslintrc.json');
|
|
9
|
+
if (host.exists(eslintRcJson)) {
|
|
10
|
+
const config = (0, devkit_1.readJson)(host, eslintRcJson);
|
|
11
|
+
// Ignore non-nextjs projects
|
|
12
|
+
if (!config?.extends?.includes('next'))
|
|
13
|
+
return;
|
|
14
|
+
// Find the override that handles both TS and JS files.
|
|
15
|
+
const commonOverride = config.overrides?.find((o) => ['*.ts', '*.tsx', '*.js', '*.jsx'].every((ext) => o.files.includes(ext)));
|
|
16
|
+
if (commonOverride &&
|
|
17
|
+
!commonOverride.rules['@next/next/no-html-link-for-pages']) {
|
|
18
|
+
commonOverride.rules = {
|
|
19
|
+
...commonOverride.rules,
|
|
20
|
+
'@next/next/no-html-link-for-pages': [
|
|
21
|
+
'error',
|
|
22
|
+
`${project.root}/pages`,
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
(0, devkit_1.writeJson)(host, eslintRcJson, config);
|
|
27
26
|
}
|
|
28
|
-
}
|
|
29
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
27
|
+
}
|
|
30
28
|
});
|
|
29
|
+
await (0, devkit_1.formatFiles)(host);
|
|
31
30
|
}
|
|
32
31
|
exports.fixPageDirForEslint = fixPageDirForEslint;
|
|
33
32
|
exports.default = fixPageDirForEslint;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeStyledJsxBabelConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function removeStyledJsxBabelConfig(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
(0, devkit_1.writeJson)(host, babelRcPath, babelRcContent);
|
|
18
|
-
}
|
|
5
|
+
async function removeStyledJsxBabelConfig(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
projects.forEach((project) => {
|
|
8
|
+
const babelRcPath = (0, devkit_1.joinPathFragments)(project.root, '.babelrc');
|
|
9
|
+
if (host.exists(babelRcPath)) {
|
|
10
|
+
const babelRcContent = (0, devkit_1.readJson)(host, babelRcPath);
|
|
11
|
+
// check whether next.js project
|
|
12
|
+
if (babelRcContent.presets.includes('next/babel')) {
|
|
13
|
+
babelRcContent.plugins = babelRcContent.plugins.filter((x) => x !== 'styled-jsx/babel');
|
|
14
|
+
// update .babelrc
|
|
15
|
+
(0, devkit_1.writeJson)(host, babelRcPath, babelRcContent);
|
|
19
16
|
}
|
|
20
|
-
}
|
|
21
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
17
|
+
}
|
|
22
18
|
});
|
|
19
|
+
await (0, devkit_1.formatFiles)(host);
|
|
23
20
|
}
|
|
24
21
|
exports.removeStyledJsxBabelConfig = removeStyledJsxBabelConfig;
|
|
25
22
|
exports.default = removeStyledJsxBabelConfig;
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateEmotionSetup = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function updateEmotionSetup(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
5
|
+
async function updateEmotionSetup(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
projects.forEach((p) => {
|
|
8
|
+
let hasEmotion = false;
|
|
9
|
+
const babelrcPath = `${p.root}/.babelrc`;
|
|
10
|
+
const tsConfigPath = `${p.root}/tsconfig.json`;
|
|
11
|
+
if (host.exists(babelrcPath)) {
|
|
12
|
+
const babelrc = (0, devkit_1.readJson)(host, babelrcPath);
|
|
13
|
+
if (babelrc.presets) {
|
|
14
|
+
for (const [idx, preset] of babelrc.presets.entries()) {
|
|
15
|
+
if (Array.isArray(preset)) {
|
|
16
|
+
if (!preset[0].includes('@nrwl/next/babel'))
|
|
17
|
+
continue;
|
|
18
|
+
const emotionOptions = preset[1]['preset-react'];
|
|
19
|
+
hasEmotion = emotionOptions?.importSource === '@emotion/react';
|
|
20
|
+
break;
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
24
|
+
}
|
|
25
|
+
if (hasEmotion && host.exists(tsConfigPath)) {
|
|
26
|
+
(0, devkit_1.updateJson)(host, tsConfigPath, (json) => {
|
|
27
|
+
json.compilerOptions.jsxImportSource = '@emotion/react';
|
|
28
|
+
return json;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
35
31
|
});
|
|
32
|
+
await (0, devkit_1.formatFiles)(host);
|
|
36
33
|
}
|
|
37
34
|
exports.updateEmotionSetup = updateEmotionSetup;
|
|
38
35
|
exports.default = updateEmotionSetup;
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
host.write(configPath, updated);
|
|
25
|
-
});
|
|
26
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
27
|
-
return task;
|
|
5
|
+
async function update(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
let task = undefined;
|
|
8
|
+
projects.forEach((project) => {
|
|
9
|
+
const configPath = (0, devkit_1.joinPathFragments)(project.root, 'next.config.js');
|
|
10
|
+
if (!host.exists(configPath))
|
|
11
|
+
return;
|
|
12
|
+
const content = host.read(configPath).toString();
|
|
13
|
+
let updated = content.replace(/webpack5: false/, 'webpack5: true');
|
|
14
|
+
if (content.match(/@zeit\/next-less/)) {
|
|
15
|
+
updated = updated.replace('@zeit/next-less', 'next-with-less');
|
|
16
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(host, { 'next-with-less': '1.0.1' }, {});
|
|
17
|
+
}
|
|
18
|
+
if (content.match(/@zeit\/next-stylus/)) {
|
|
19
|
+
updated = updated.replace('@zeit/next-stylus', '@nrwl/next/plugins/with-stylus');
|
|
20
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(host, { 'stylus-loader': '6.2.0' }, {});
|
|
21
|
+
}
|
|
22
|
+
host.write(configPath, updated);
|
|
28
23
|
});
|
|
24
|
+
await (0, devkit_1.formatFiles)(host);
|
|
25
|
+
return task;
|
|
29
26
|
}
|
|
30
27
|
exports.update = update;
|
|
31
28
|
exports.default = update;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
22
|
-
return task;
|
|
5
|
+
async function update(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
let task = undefined;
|
|
8
|
+
projects.forEach((project) => {
|
|
9
|
+
const configPath = (0, devkit_1.joinPathFragments)(project.root, 'next.config.js');
|
|
10
|
+
if (!host.exists(configPath))
|
|
11
|
+
return;
|
|
12
|
+
const content = host.read(configPath).toString();
|
|
13
|
+
if (content.match(/next-with-less/)) {
|
|
14
|
+
const updated = content.replace('next-with-less', '@nrwl/next/plugins/with-less');
|
|
15
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(host, { 'less-loader': '10.2.0' }, {});
|
|
16
|
+
host.write(configPath, updated);
|
|
17
|
+
}
|
|
23
18
|
});
|
|
19
|
+
await (0, devkit_1.formatFiles)(host);
|
|
20
|
+
return task;
|
|
24
21
|
}
|
|
25
22
|
exports.update = update;
|
|
26
23
|
exports.default = update;
|
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (host
|
|
17
|
-
|
|
18
|
-
devkit_1.logger.info(`NX Custom .babelrc file detected, skipping deletion. You can delete this file yourself to enable SWC: ${babelConfigPath}`);
|
|
19
|
-
}
|
|
20
|
-
else if (host.exists(storybookMainPath)) {
|
|
21
|
-
devkit_1.logger.info(`NX Storybook configuration for project "${project.name}" detected, skipping deletion of .babelrc`);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// Deleting custom babel config enables SWC
|
|
25
|
-
host.delete(babelConfigPath);
|
|
26
|
-
}
|
|
5
|
+
async function update(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
projects.forEach((project) => {
|
|
8
|
+
const nextConfigPath = (0, devkit_1.joinPathFragments)(project.root, 'next.config.js');
|
|
9
|
+
const jestConfigPath = (0, devkit_1.joinPathFragments)(project.root, 'jest.config.js');
|
|
10
|
+
const babelConfigPath = (0, devkit_1.joinPathFragments)(project.root, '.babelrc');
|
|
11
|
+
const storybookMainPath = (0, devkit_1.joinPathFragments)(project.root, '.storybook/main.js');
|
|
12
|
+
if (!host.exists(nextConfigPath) || !host.exists(jestConfigPath))
|
|
13
|
+
return;
|
|
14
|
+
if (host.exists(babelConfigPath)) {
|
|
15
|
+
if (customBabelConfig(host, babelConfigPath)) {
|
|
16
|
+
devkit_1.logger.info(`NX Custom .babelrc file detected, skipping deletion. You can delete this file yourself to enable SWC: ${babelConfigPath}`);
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const updated = content.replace(/:\s+'babel-jest'/, `: ['babel-jest', { presets: ['@nrwl/next/babel'] }]`);
|
|
31
|
-
host.write(jestConfigPath, updated);
|
|
18
|
+
else if (host.exists(storybookMainPath)) {
|
|
19
|
+
devkit_1.logger.info(`NX Storybook configuration for project "${project.name}" detected, skipping deletion of .babelrc`);
|
|
32
20
|
}
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
else {
|
|
22
|
+
// Deleting custom babel config enables SWC
|
|
23
|
+
host.delete(babelConfigPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const content = host.read(jestConfigPath).toString();
|
|
27
|
+
if (content.match(/:\s+'babel-jest'/)) {
|
|
28
|
+
const updated = content.replace(/:\s+'babel-jest'/, `: ['babel-jest', { presets: ['@nrwl/next/babel'] }]`);
|
|
29
|
+
host.write(jestConfigPath, updated);
|
|
30
|
+
}
|
|
35
31
|
});
|
|
32
|
+
await (0, devkit_1.formatFiles)(host);
|
|
36
33
|
}
|
|
37
34
|
exports.update = update;
|
|
38
35
|
function customBabelConfig(host, configPath) {
|
|
39
|
-
var _a, _b, _c;
|
|
40
36
|
const json = (0, devkit_1.readJson)(host, configPath);
|
|
41
|
-
return !(
|
|
42
|
-
|
|
43
|
-
(
|
|
37
|
+
return !(json.presets?.length === 1 &&
|
|
38
|
+
json.presets?.[0] === '@nrwl/next/babel' &&
|
|
39
|
+
(json.plugins?.length === 0 || !json.plugins));
|
|
44
40
|
}
|
|
45
41
|
exports.default = update;
|
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (shouldUpdate)
|
|
29
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
30
|
-
});
|
|
31
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
projects.forEach((config, name) => {
|
|
8
|
+
let shouldUpdate = false;
|
|
9
|
+
if (config.targets?.build?.executor === '@nrwl/next:build') {
|
|
10
|
+
shouldUpdate = true;
|
|
11
|
+
config.targets.build.defaultConfiguration ??= 'production';
|
|
12
|
+
config.targets.build.configurations ??= {};
|
|
13
|
+
config.targets.build.configurations.development ??= {};
|
|
14
|
+
}
|
|
15
|
+
if (config.targets?.serve?.executor === '@nrwl/next:server') {
|
|
16
|
+
shouldUpdate = true;
|
|
17
|
+
config.targets.serve.defaultConfiguration ??= 'development';
|
|
18
|
+
config.targets.serve.configurations ??= {};
|
|
19
|
+
config.targets.serve.configurations.development ??= {
|
|
20
|
+
buildTarget: `${name}:build:development`,
|
|
21
|
+
dev: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (shouldUpdate)
|
|
25
|
+
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
32
26
|
});
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
33
28
|
}
|
|
34
29
|
exports.update = update;
|
|
35
30
|
exports.default = update;
|