@nx/next 23.2.0-beta.7 → 23.2.0-beta.9
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.
|
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const assert_supported_next_version_1 = require("../../utils/assert-supported-next-version");
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
9
|
const internal_2 = require("@nx/react/internal");
|
|
10
|
-
const internal_3 = require("@nx/react/internal");
|
|
11
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
12
11
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
13
12
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -20,7 +19,7 @@ const add_linting_1 = require("./lib/add-linting");
|
|
|
20
19
|
const custom_server_1 = require("../custom-server/custom-server");
|
|
21
20
|
const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
22
21
|
const versions_1 = require("../../utils/versions");
|
|
23
|
-
const
|
|
22
|
+
const internal_3 = require("@nx/js/internal");
|
|
24
23
|
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
25
24
|
const jest_config_util_1 = require("../../utils/jest-config-util");
|
|
26
25
|
async function applicationGenerator(host, schema) {
|
|
@@ -33,7 +32,7 @@ async function applicationGenerator(host, schema) {
|
|
|
33
32
|
async function applicationGeneratorInternal(host, schema) {
|
|
34
33
|
(0, assert_supported_next_version_1.assertSupportedNextVersion)(host);
|
|
35
34
|
const tasks = [];
|
|
36
|
-
const addTsPlugin = (0,
|
|
35
|
+
const addTsPlugin = (0, internal_3.shouldConfigureTsSolutionSetup)(host, schema.addPlugin, schema.useTsSolution);
|
|
37
36
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
38
37
|
js: schema.js,
|
|
39
38
|
skipPackageJson: schema.skipPackageJson,
|
|
@@ -54,7 +53,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
54
53
|
// If we are using the new TS solution
|
|
55
54
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
56
55
|
if (options.isTsSolutionSetup) {
|
|
57
|
-
await (0,
|
|
56
|
+
await (0, internal_3.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
58
57
|
}
|
|
59
58
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
60
59
|
tasks.push(lintTask);
|
|
@@ -81,7 +80,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
if (!options.skipPackageJson) {
|
|
84
|
-
const reactVersions = await (0,
|
|
83
|
+
const reactVersions = await (0, internal_2.getReactDependenciesVersionsToInstall)(host);
|
|
85
84
|
const devDependencies = {
|
|
86
85
|
'@types/react': reactVersions['@types/react'],
|
|
87
86
|
'@types/react-dom': reactVersions['@types/react-dom'],
|
|
@@ -92,14 +91,14 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
92
91
|
}
|
|
93
92
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_1.tsLibVersion }, devDependencies, undefined, true));
|
|
94
93
|
}
|
|
95
|
-
(0,
|
|
94
|
+
(0, internal_3.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.json', {
|
|
96
95
|
jsx: 'preserve',
|
|
97
96
|
module: 'esnext',
|
|
98
97
|
moduleResolution: 'bundler',
|
|
99
98
|
}, options.linter === 'eslint'
|
|
100
99
|
? ['.next', 'eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
101
100
|
: ['.next'], options.src ? 'src' : '.');
|
|
102
|
-
(0,
|
|
101
|
+
(0, internal_3.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
103
102
|
if (!options.skipFormat) {
|
|
104
103
|
await (0, devkit_1.formatFiles)(host);
|
|
105
104
|
}
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
"enum": ["eslint", "oxlint", "none"],
|
|
54
54
|
"x-priority": "important"
|
|
55
55
|
},
|
|
56
|
+
"formatter": {
|
|
57
|
+
"description": "The tool to use for code formatting.",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"enum": ["none", "prettier", "oxfmt"]
|
|
60
|
+
},
|
|
56
61
|
"skipFormat": {
|
|
57
62
|
"description": "Skip formatting files.",
|
|
58
63
|
"type": "boolean",
|
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.customServerGenerator = customServerGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
const devkit_2 = require("@nx/devkit");
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
9
8
|
const internal_2 = require("@nx/js/internal");
|
|
10
9
|
const assert_supported_next_version_1 = require("../../utils/assert-supported-next-version");
|
|
11
10
|
async function customServerGenerator(host, options) {
|
|
12
11
|
(0, assert_supported_next_version_1.assertSupportedNextVersion)(host);
|
|
13
|
-
const project = (0,
|
|
12
|
+
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
14
13
|
const swcServerName = '.server.swcrc';
|
|
15
|
-
const nxJson = (0,
|
|
14
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
15
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
17
16
|
? p === '@nx/next/plugin'
|
|
18
17
|
: p.plugin === '@nx/next/plugin');
|
|
19
18
|
if (project.targets?.build?.executor !== '@nx/next:build' && !hasPlugin) {
|
|
20
|
-
|
|
19
|
+
devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
@@ -28,22 +27,22 @@ async function customServerGenerator(host, options) {
|
|
|
28
27
|
!project.targets?.build?.configurations?.development ||
|
|
29
28
|
!project.targets?.build?.configurations?.production) &&
|
|
30
29
|
!hasPlugin) {
|
|
31
|
-
|
|
30
|
+
devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
if (project.targets?.['build-custom-server'] ||
|
|
35
34
|
project.targets?.['serve-custom-server']) {
|
|
36
|
-
|
|
35
|
+
devkit_1.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
38
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
40
39
|
// So we need ensure the mapping is correct from dist to the project root
|
|
41
40
|
const projectPathFromDist = hasPlugin
|
|
42
|
-
? `../../${(0,
|
|
43
|
-
: `${(0,
|
|
44
|
-
const offset = (0,
|
|
41
|
+
? `../../${(0, devkit_1.offsetFromRoot)(project.root)}${project.root}`
|
|
42
|
+
: `${(0, devkit_1.offsetFromRoot)(`dist/${project.root}`)}${project.root}`;
|
|
43
|
+
const offset = (0, devkit_1.offsetFromRoot)(project.root);
|
|
45
44
|
const isTsSolution = (0, internal_2.isUsingTsSolutionSetup)(host);
|
|
46
|
-
(0,
|
|
45
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
|
|
47
46
|
...options,
|
|
48
47
|
hasPlugin,
|
|
49
48
|
projectPathFromDist,
|
|
@@ -98,23 +97,23 @@ async function customServerGenerator(host, options) {
|
|
|
98
97
|
},
|
|
99
98
|
},
|
|
100
99
|
};
|
|
101
|
-
(0,
|
|
102
|
-
(0,
|
|
100
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.project, project);
|
|
101
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
103
102
|
if (!json.tasksRunnerOptions?.default?.options?.cacheableOperations?.includes('build-custom-server') &&
|
|
104
103
|
json.tasksRunnerOptions?.default?.options?.cacheableOperations) {
|
|
105
104
|
json.tasksRunnerOptions.default.options.cacheableOperations.push('build-custom-server');
|
|
106
105
|
}
|
|
107
106
|
return json;
|
|
108
107
|
});
|
|
109
|
-
const updatedNxJson = (0,
|
|
108
|
+
const updatedNxJson = (0, devkit_1.readNxJson)(host) ?? {};
|
|
110
109
|
(0, internal_1.upsertTargetDefault)(host, updatedNxJson, {
|
|
111
110
|
target: 'build-custom-server',
|
|
112
111
|
cache: true,
|
|
113
112
|
});
|
|
114
|
-
(0,
|
|
113
|
+
(0, devkit_1.updateNxJson)(host, updatedNxJson);
|
|
115
114
|
if (options.compiler === 'swc') {
|
|
116
115
|
// Update app swc to exlude server files
|
|
117
|
-
(0,
|
|
116
|
+
(0, devkit_1.updateJson)(host, (0, path_1.join)(project.root, '.swcrc'), (json) => {
|
|
118
117
|
json.exclude = [...(json.exclude ?? []), 'server/**'];
|
|
119
118
|
return json;
|
|
120
119
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace. \n\nWhen using Next.js in Nx, you get the out-of-the-box support for TypeScript, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"next": ">=14.0.0 <17.0.0",
|
|
71
|
-
"@nx/webpack": "23.2.0-beta.
|
|
71
|
+
"@nx/webpack": "23.2.0-beta.9"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
74
74
|
"@nx/webpack": {
|
|
@@ -83,17 +83,17 @@
|
|
|
83
83
|
"tslib": "^2.3.0",
|
|
84
84
|
"webpack-merge": "^5.8.0",
|
|
85
85
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
86
|
-
"@nx/devkit": "23.2.0-beta.
|
|
87
|
-
"@nx/js": "23.2.0-beta.
|
|
88
|
-
"@nx/eslint": "23.2.0-beta.
|
|
89
|
-
"@nx/
|
|
90
|
-
"@nx/
|
|
86
|
+
"@nx/devkit": "23.2.0-beta.9",
|
|
87
|
+
"@nx/js": "23.2.0-beta.9",
|
|
88
|
+
"@nx/eslint": "23.2.0-beta.9",
|
|
89
|
+
"@nx/web": "23.2.0-beta.9",
|
|
90
|
+
"@nx/react": "23.2.0-beta.9"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@nx/cypress": "23.2.0-beta.
|
|
94
|
-
"@nx/playwright": "23.2.0-beta.
|
|
95
|
-
"@nx/webpack": "23.2.0-beta.
|
|
96
|
-
"nx": "23.2.0-beta.
|
|
93
|
+
"@nx/cypress": "23.2.0-beta.9",
|
|
94
|
+
"@nx/playwright": "23.2.0-beta.9",
|
|
95
|
+
"@nx/webpack": "23.2.0-beta.9",
|
|
96
|
+
"nx": "23.2.0-beta.9"
|
|
97
97
|
},
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"access": "public"
|