@nx/next 16.8.0-beta.3 → 16.8.0-beta.5
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.js +14 -8
- package/plugins/with-less.js +19 -14
- package/plugins/with-nx.js +67 -28
- package/plugins/with-stylus.js +18 -14
- package/src/executors/build/build.impl.js +60 -65
- 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 +68 -69
- 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,23 +1,19 @@
|
|
|
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
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
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
|
+
if (config.targets?.build?.executor === '@nrwl/next:build') {
|
|
9
|
+
config.targets.build.configurations ??= {};
|
|
10
|
+
config.targets.build.configurations.development ??= {};
|
|
11
|
+
config.targets.build.configurations.development.outputPath ??=
|
|
12
|
+
(0, devkit_1.joinPathFragments)('tmp', config.sourceRoot);
|
|
13
|
+
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
14
|
+
}
|
|
20
15
|
});
|
|
16
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
17
|
}
|
|
22
18
|
exports.update = update;
|
|
23
19
|
exports.default = update;
|
|
@@ -1,14 +1,11 @@
|
|
|
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
5
|
const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
|
|
7
|
-
function update(tree) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
11
|
-
});
|
|
6
|
+
async function update(tree) {
|
|
7
|
+
(0, add_gitignore_entry_1.addGitIgnoreEntry)(tree);
|
|
8
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
12
9
|
}
|
|
13
10
|
exports.update = update;
|
|
14
11
|
exports.default = update;
|
|
@@ -1,28 +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(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
config.
|
|
17
|
-
|
|
18
|
-
config.targets.build.configurations.development.outputPath =
|
|
19
|
-
config.root;
|
|
20
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
21
|
-
}
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
projects.forEach((config, name) => {
|
|
8
|
+
if (config.targets?.build?.executor === '@nrwl/next:build') {
|
|
9
|
+
config.targets.build.configurations ??= {};
|
|
10
|
+
config.targets.build.configurations.development ??= {};
|
|
11
|
+
if (!config.targets.build.configurations.development.outputPath ||
|
|
12
|
+
config.targets.build.configurations.development.outputPath ===
|
|
13
|
+
(0, devkit_1.joinPathFragments)('tmp', config.root)) {
|
|
14
|
+
config.targets.build.configurations.development.outputPath =
|
|
15
|
+
config.root;
|
|
16
|
+
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
22
17
|
}
|
|
23
|
-
}
|
|
24
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
18
|
+
}
|
|
25
19
|
});
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
26
21
|
}
|
|
27
22
|
exports.update = update;
|
|
28
23
|
exports.default = update;
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateNextEslint = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function updateNextEslint(host) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return eslintConfig;
|
|
25
|
-
});
|
|
5
|
+
async function updateNextEslint(host) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
7
|
+
projects.forEach((project) => {
|
|
8
|
+
if (project.targets?.build?.executor !== '@nrwl/next:build')
|
|
9
|
+
return;
|
|
10
|
+
const eslintPath = `${project.root}/.eslintrc.json`;
|
|
11
|
+
if (!host.exists(eslintPath))
|
|
12
|
+
return;
|
|
13
|
+
(0, devkit_1.updateJson)(host, eslintPath, (eslintConfig) => {
|
|
14
|
+
const nextIgnorePattern = '.next/**/*';
|
|
15
|
+
if (eslintConfig.ignorePatterns.indexOf(nextIgnorePattern) < 0) {
|
|
16
|
+
eslintConfig.ignorePatterns = [
|
|
17
|
+
...eslintConfig.ignorePatterns,
|
|
18
|
+
nextIgnorePattern,
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
return eslintConfig;
|
|
26
22
|
});
|
|
27
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
28
23
|
});
|
|
24
|
+
await (0, devkit_1.formatFiles)(host);
|
|
29
25
|
}
|
|
30
26
|
exports.updateNextEslint = updateNextEslint;
|
|
31
27
|
exports.default = updateNextEslint;
|
|
@@ -1,27 +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(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (nextConfigContent.includes('@nrwl/next/plugins/with-stylus')) {
|
|
19
|
-
missingDeps['stylus'] = '^0.55.0';
|
|
20
|
-
}
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
const missingDeps = {};
|
|
8
|
+
for (const [, config] of projects) {
|
|
9
|
+
if (config.targets?.build?.executor === '@nrwl/next:build' &&
|
|
10
|
+
tree.exists((0, devkit_1.joinPathFragments)(config.root, 'next.config.js'))) {
|
|
11
|
+
const nextConfigContent = tree.read((0, devkit_1.joinPathFragments)(config.root, 'next.config.js'), 'utf-8');
|
|
12
|
+
if (nextConfigContent.includes('@nrwl/next/plugins/with-less')) {
|
|
13
|
+
missingDeps['less'] = '3.12.2';
|
|
14
|
+
}
|
|
15
|
+
if (nextConfigContent.includes('@nrwl/next/plugins/with-stylus')) {
|
|
16
|
+
missingDeps['stylus'] = '^0.55.0';
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
});
|
|
19
|
+
}
|
|
20
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, missingDeps);
|
|
25
21
|
}
|
|
26
22
|
exports.update = update;
|
|
27
23
|
exports.default = update;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/next', '@nx/next');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
(0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(0,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
17
|
-
});
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/next:build', (options, projectName, targetName) => {
|
|
7
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
delete projectConfig.targets[targetName].options.root;
|
|
9
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
10
|
+
});
|
|
11
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/next:build', (options, projectName, targetName) => {
|
|
12
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
13
|
+
delete projectConfig.targets[targetName].options.root;
|
|
14
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
exports.default = update;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function update(tree) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
packageJson.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
18
|
-
});
|
|
4
|
+
async function update(tree) {
|
|
5
|
+
if (tree.exists('./package.json')) {
|
|
6
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
7
|
+
if (packageJson.dependencies['@nx/next']) {
|
|
8
|
+
packageJson.devDependencies['@nx/next'] =
|
|
9
|
+
packageJson.dependencies['@nx/next'];
|
|
10
|
+
delete packageJson.dependencies['@nx/next'];
|
|
11
|
+
}
|
|
12
|
+
return packageJson;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
16
|
}
|
|
20
17
|
exports.default = update;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.composePlugins = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
function composePlugins(...plugins) {
|
|
6
5
|
return function (baseConfig) {
|
|
7
|
-
return function combined(phase, context) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
config = yield configOrFn(phase, context);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
config = configOrFn;
|
|
18
|
-
}
|
|
6
|
+
return async function combined(phase, context) {
|
|
7
|
+
let config = baseConfig;
|
|
8
|
+
for (const plugin of plugins) {
|
|
9
|
+
const fn = await plugin;
|
|
10
|
+
const configOrFn = fn(config);
|
|
11
|
+
if (typeof configOrFn === 'function') {
|
|
12
|
+
config = await configOrFn(phase, context);
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
else {
|
|
15
|
+
config = configOrFn;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return config;
|
|
22
19
|
};
|
|
23
20
|
};
|
|
24
21
|
}
|
|
@@ -32,16 +32,18 @@ function normalizeAssets(assets, root, sourceRoot) {
|
|
|
32
32
|
}
|
|
33
33
|
const assetPath = (0, path_1.normalizePath)(asset.input);
|
|
34
34
|
const resolvedAssetPath = (0, path_2.resolve)(root, assetPath);
|
|
35
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
...asset,
|
|
37
|
+
input: resolvedAssetPath,
|
|
36
38
|
// Now we remove starting slash to make Webpack place it from the output root.
|
|
37
|
-
output: asset.output.replace(/^\//, '')
|
|
39
|
+
output: asset.output.replace(/^\//, ''),
|
|
40
|
+
};
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
function createCopyPlugin(assets, root, sourceRoot) {
|
|
42
45
|
return new CopyWebpackPlugin({
|
|
43
46
|
patterns: normalizeAssets(assets, root, sourceRoot).map((asset) => {
|
|
44
|
-
var _a;
|
|
45
47
|
return {
|
|
46
48
|
context: asset.input,
|
|
47
49
|
to: (0, path_2.join)('../public', asset.output),
|
|
@@ -51,7 +53,7 @@ function createCopyPlugin(assets, root, sourceRoot) {
|
|
|
51
53
|
'.gitkeep',
|
|
52
54
|
'**/.DS_Store',
|
|
53
55
|
'**/Thumbs.db',
|
|
54
|
-
...(
|
|
56
|
+
...(asset.ignore ?? []),
|
|
55
57
|
],
|
|
56
58
|
dot: true,
|
|
57
59
|
},
|
|
@@ -23,7 +23,7 @@ due to missing "sourceRoot" in the dependencies' project configuration
|
|
|
23
23
|
return projectDirs.map((sourceDir) => (0, path_1.resolve)(devkit_2.workspaceRoot, (0, devkit_1.joinPathFragments)(sourceDir, fileGlobPattern)));
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
throw new Error(`createGlobPatternsOfDependentProjects: Error when generating globs: ${e
|
|
26
|
+
throw new Error(`createGlobPatternsOfDependentProjects: Error when generating globs: ${e?.message}`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.createGlobPatternsOfDependentProjects = createGlobPatternsOfDependentProjects;
|
package/src/utils/styles.js
CHANGED
|
@@ -29,20 +29,40 @@ const nextSpecificStyleDependenciesCommon = {
|
|
|
29
29
|
devDependencies: {},
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
-
exports.nextSpecificStyleDependenciesBabel =
|
|
32
|
+
exports.nextSpecificStyleDependenciesBabel = {
|
|
33
|
+
...nextSpecificStyleDependenciesCommon,
|
|
34
|
+
'styled-components': {
|
|
33
35
|
dependencies: styled_1.cssInJsDependenciesBabel['styled-components'].dependencies,
|
|
34
|
-
devDependencies:
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
devDependencies: {
|
|
37
|
+
...styled_1.cssInJsDependenciesBabel['styled-components'].devDependencies,
|
|
38
|
+
'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
'@emotion/styled': {
|
|
42
|
+
dependencies: {
|
|
43
|
+
...styled_1.cssInJsDependenciesBabel['@emotion/styled'].dependencies,
|
|
44
|
+
'@emotion/server': versions_2.emotionServerVersion,
|
|
45
|
+
},
|
|
37
46
|
devDependencies: styled_1.cssInJsDependenciesBabel['@emotion/styled'].devDependencies,
|
|
38
|
-
}
|
|
39
|
-
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
exports.nextSpecificStyleDependenciesSwc = {
|
|
50
|
+
...nextSpecificStyleDependenciesCommon,
|
|
51
|
+
'styled-components': {
|
|
40
52
|
dependencies: styled_1.cssInJsDependenciesSwc['styled-components'].dependencies,
|
|
41
|
-
devDependencies:
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
devDependencies: {
|
|
54
|
+
...styled_1.cssInJsDependenciesSwc['styled-components'].devDependencies,
|
|
55
|
+
'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
'@emotion/styled': {
|
|
59
|
+
dependencies: {
|
|
60
|
+
...styled_1.cssInJsDependenciesSwc['@emotion/styled'].dependencies,
|
|
61
|
+
'@emotion/server': versions_2.emotionServerVersion,
|
|
62
|
+
},
|
|
44
63
|
devDependencies: styled_1.cssInJsDependenciesSwc['@emotion/styled'].devDependencies,
|
|
45
|
-
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
46
66
|
function addStyleDependencies(host, options) {
|
|
47
67
|
const extraDependencies = options.swc
|
|
48
68
|
? exports.nextSpecificStyleDependenciesSwc[options.style]
|
|
@@ -55,7 +75,7 @@ function addStyleDependencies(host, options) {
|
|
|
55
75
|
if (host.exists('pnpm-lock.yaml') &&
|
|
56
76
|
(options.style === 'less' || options.style === 'styl')) {
|
|
57
77
|
(0, devkit_1.updateJson)(host, `package.json`, (json) => {
|
|
58
|
-
json.resolutions =
|
|
78
|
+
json.resolutions = { ...json.resolutions, 'css-loader': '1.0.1' };
|
|
59
79
|
return json;
|
|
60
80
|
});
|
|
61
81
|
}
|