@nx/next 20.4.0-beta.0 → 20.4.0-beta.1
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 +8 -8
- package/src/generators/application/application.js +7 -2
- package/src/generators/application/files/common/next-env.d.ts__tmpl__ +1 -1
- package/src/generators/application/lib/add-e2e.js +2 -2
- package/src/generators/init/init.js +11 -8
- package/src/generators/library/library.js +2 -0
- package/src/plugins/plugin.d.ts +3 -0
- package/src/plugins/plugin.js +3 -2
- package/src/utils/version-utils.d.ts +9 -0
- package/src/utils/version-utils.js +46 -0
- package/src/utils/versions.d.ts +2 -1
- package/src/utils/versions.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "20.4.0-beta.
|
|
3
|
+
"version": "20.4.0-beta.1",
|
|
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": {
|
|
@@ -35,20 +35,20 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "20.4.0-beta.
|
|
38
|
+
"@nx/devkit": "20.4.0-beta.1",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
|
-
"@svgr/webpack": "^8.0
|
|
40
|
+
"@svgr/webpack": "^8.1.0",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
42
42
|
"file-loader": "^6.2.0",
|
|
43
43
|
"ignore": "^5.0.4",
|
|
44
44
|
"semver": "^7.5.3",
|
|
45
45
|
"tslib": "^2.3.0",
|
|
46
46
|
"webpack-merge": "^5.8.0",
|
|
47
|
-
"@nx/js": "20.4.0-beta.
|
|
48
|
-
"@nx/eslint": "20.4.0-beta.
|
|
49
|
-
"@nx/react": "20.4.0-beta.
|
|
50
|
-
"@nx/web": "20.4.0-beta.
|
|
51
|
-
"@nx/webpack": "20.4.0-beta.
|
|
47
|
+
"@nx/js": "20.4.0-beta.1",
|
|
48
|
+
"@nx/eslint": "20.4.0-beta.1",
|
|
49
|
+
"@nx/react": "20.4.0-beta.1",
|
|
50
|
+
"@nx/web": "20.4.0-beta.1",
|
|
51
|
+
"@nx/webpack": "20.4.0-beta.1",
|
|
52
52
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -6,6 +6,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const react_1 = require("@nx/react");
|
|
8
8
|
const versions_1 = require("@nx/react/src/utils/versions");
|
|
9
|
+
const version_utils_1 = require("@nx/react/src/utils/version-utils");
|
|
9
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
11
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
11
12
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -22,6 +23,7 @@ const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
|
22
23
|
const versions_2 = require("../../utils/versions");
|
|
23
24
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
24
25
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
26
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
25
27
|
async function applicationGenerator(host, schema) {
|
|
26
28
|
return await applicationGeneratorInternal(host, {
|
|
27
29
|
addPlugin: false,
|
|
@@ -38,6 +40,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
38
40
|
skipFormat: true,
|
|
39
41
|
addTsPlugin: schema.useTsSolution,
|
|
40
42
|
formatter: schema.formatter,
|
|
43
|
+
platform: 'web',
|
|
41
44
|
});
|
|
42
45
|
tasks.push(jsInitTask);
|
|
43
46
|
const nextTask = await (0, init_1.nextInitGenerator)(host, {
|
|
@@ -74,9 +77,10 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
if (!options.skipPackageJson) {
|
|
80
|
+
const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
|
|
77
81
|
const devDependencies = {
|
|
78
|
-
'@types/react':
|
|
79
|
-
'@types/react-dom':
|
|
82
|
+
'@types/react': reactVersions['@types/react'],
|
|
83
|
+
'@types/react-dom': reactVersions['@types/react-dom'],
|
|
80
84
|
};
|
|
81
85
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
82
86
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
@@ -95,6 +99,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
95
99
|
if (options.useTsSolution) {
|
|
96
100
|
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
97
101
|
}
|
|
102
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
98
103
|
if (!options.skipFormat) {
|
|
99
104
|
await (0, devkit_1.formatFiles)(host);
|
|
100
105
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/// <reference types="next/image-types/global" />
|
|
3
3
|
|
|
4
4
|
// NOTE: This file should not be edited
|
|
5
|
-
// see https://nextjs.org/docs/<%- appDirType %>/
|
|
5
|
+
// see https://nextjs.org/docs/<%- appDirType %>/api-reference/config/typescript for more information.
|
|
@@ -144,11 +144,11 @@ async function getNextE2EWebServerInfo(tree, projectName, configFilePath, isPlug
|
|
|
144
144
|
return (0, e2e_web_server_info_utils_1.getE2EWebServerInfo)(tree, projectName, {
|
|
145
145
|
plugin: '@nx/next/plugin',
|
|
146
146
|
serveTargetName: 'devTargetName',
|
|
147
|
-
serveStaticTargetName: '
|
|
147
|
+
serveStaticTargetName: 'startTargetName',
|
|
148
148
|
configFilePath,
|
|
149
149
|
}, {
|
|
150
150
|
defaultServeTargetName: defaultServeTarget,
|
|
151
|
-
defaultServeStaticTargetName: '
|
|
151
|
+
defaultServeStaticTargetName: 'start',
|
|
152
152
|
defaultE2EWebServerAddress: `http://127.0.0.1:${e2ePort}`,
|
|
153
153
|
defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
|
|
154
154
|
defaultE2EPort: e2ePort,
|
|
@@ -4,18 +4,21 @@ exports.nextInitGenerator = nextInitGenerator;
|
|
|
4
4
|
exports.nextInitGeneratorInternal = nextInitGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
|
-
const
|
|
7
|
+
const version_utils_1 = require("@nx/react/src/utils/version-utils");
|
|
8
8
|
const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const versions_1 = require("../../utils/versions");
|
|
10
|
+
const version_utils_2 = require("../../utils/version-utils");
|
|
11
|
+
async function updateDependencies(host, schema) {
|
|
11
12
|
const tasks = [];
|
|
12
13
|
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/next'], []));
|
|
14
|
+
const versions = await (0, version_utils_2.getNextDependenciesVersionsToInstall)(host, await (0, version_utils_1.isReact18)(host));
|
|
15
|
+
const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
|
|
13
16
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
14
|
-
next:
|
|
15
|
-
react:
|
|
16
|
-
'react-dom':
|
|
17
|
+
next: versions.next,
|
|
18
|
+
react: reactVersions.react,
|
|
19
|
+
'react-dom': reactVersions['react-dom'],
|
|
17
20
|
}, {
|
|
18
|
-
'@nx/next':
|
|
21
|
+
'@nx/next': versions_1.nxVersion,
|
|
19
22
|
}, undefined, schema.keepExistingVersions));
|
|
20
23
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
24
|
}
|
|
@@ -53,7 +56,7 @@ async function nextInitGeneratorInternal(host, schema) {
|
|
|
53
56
|
(0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
|
|
54
57
|
let installTask = () => { };
|
|
55
58
|
if (!schema.skipPackageJson) {
|
|
56
|
-
installTask = updateDependencies(host, schema);
|
|
59
|
+
installTask = await updateDependencies(host, schema);
|
|
57
60
|
}
|
|
58
61
|
return installTask;
|
|
59
62
|
}
|
|
@@ -10,6 +10,7 @@ const init_1 = require("../init/init");
|
|
|
10
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
11
|
const versions_2 = require("../../utils/versions");
|
|
12
12
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
13
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
13
14
|
async function libraryGenerator(host, rawOptions) {
|
|
14
15
|
return await libraryGeneratorInternal(host, {
|
|
15
16
|
addPlugin: false,
|
|
@@ -96,6 +97,7 @@ async function libraryGeneratorInternal(host, rawOptions) {
|
|
|
96
97
|
if (options.isUsingTsSolutionConfig) {
|
|
97
98
|
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
98
99
|
}
|
|
100
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
|
|
99
101
|
if (!options.skipFormat) {
|
|
100
102
|
await (0, devkit_1.formatFiles)(host);
|
|
101
103
|
}
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export interface NextPluginOptions {
|
|
|
3
3
|
buildTargetName?: string;
|
|
4
4
|
devTargetName?: string;
|
|
5
5
|
startTargetName?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `startTargetName` instead.
|
|
8
|
+
*/
|
|
6
9
|
serveStaticTargetName?: string;
|
|
7
10
|
buildDepsTargetName?: string;
|
|
8
11
|
watchDepsTargetName?: string;
|
package/src/plugins/plugin.js
CHANGED
|
@@ -86,8 +86,9 @@ async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
|
|
|
86
86
|
const targets = {};
|
|
87
87
|
targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig);
|
|
88
88
|
targets[options.devTargetName] = getDevTargetConfig(projectRoot);
|
|
89
|
-
|
|
90
|
-
targets[options.
|
|
89
|
+
const startTarget = getStartTargetConfig(options, projectRoot);
|
|
90
|
+
targets[options.startTargetName] = startTarget;
|
|
91
|
+
targets[options.serveStaticTargetName] = startTarget;
|
|
91
92
|
(0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
|
|
92
93
|
return targets;
|
|
93
94
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
type NextDependenciesVersions = {
|
|
3
|
+
next: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function getNextDependenciesVersionsToInstall(tree: Tree, isReact18?: boolean): Promise<NextDependenciesVersions>;
|
|
6
|
+
export declare function isNext14(tree: Tree): Promise<boolean>;
|
|
7
|
+
export declare function getInstalledNextVersion(tree: Tree): string;
|
|
8
|
+
export declare function getInstalledNextVersionFromGraph(): Promise<string>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNextDependenciesVersionsToInstall = getNextDependenciesVersionsToInstall;
|
|
4
|
+
exports.isNext14 = isNext14;
|
|
5
|
+
exports.getInstalledNextVersion = getInstalledNextVersion;
|
|
6
|
+
exports.getInstalledNextVersionFromGraph = getInstalledNextVersionFromGraph;
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const semver_1 = require("semver");
|
|
9
|
+
const versions_1 = require("./versions");
|
|
10
|
+
async function getNextDependenciesVersionsToInstall(tree, isReact18 = false) {
|
|
11
|
+
if (await isNext14(tree)) {
|
|
12
|
+
return {
|
|
13
|
+
next: versions_1.next14Version,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return {
|
|
18
|
+
next: versions_1.nextVersion,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function isNext14(tree) {
|
|
23
|
+
let installedNextVersion = await getInstalledNextVersionFromGraph();
|
|
24
|
+
if (!installedNextVersion) {
|
|
25
|
+
installedNextVersion = getInstalledNextVersion(tree);
|
|
26
|
+
}
|
|
27
|
+
return (0, semver_1.major)(installedNextVersion) === 14;
|
|
28
|
+
}
|
|
29
|
+
function getInstalledNextVersion(tree) {
|
|
30
|
+
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
31
|
+
const installedNextVersion = pkgJson.dependencies && pkgJson.dependencies['next'];
|
|
32
|
+
if (!installedNextVersion ||
|
|
33
|
+
installedNextVersion === 'latest' ||
|
|
34
|
+
installedNextVersion === 'next') {
|
|
35
|
+
return (0, semver_1.clean)(versions_1.nextVersion) ?? (0, semver_1.coerce)(versions_1.nextVersion).version;
|
|
36
|
+
}
|
|
37
|
+
return (0, semver_1.clean)(installedNextVersion) ?? (0, semver_1.coerce)(installedNextVersion).version;
|
|
38
|
+
}
|
|
39
|
+
async function getInstalledNextVersionFromGraph() {
|
|
40
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
41
|
+
const nextDep = graph.externalNodes?.['npm:next'];
|
|
42
|
+
if (!nextDep) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return (0, semver_1.clean)(nextDep.data.version) ?? (0, semver_1.coerce)(nextDep.data.version).version;
|
|
46
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const nextVersion = "
|
|
2
|
+
export declare const nextVersion = "~15.1.4";
|
|
3
|
+
export declare const next14Version = "~14.2.16";
|
|
3
4
|
export declare const eslintConfigNextVersion = "14.2.16";
|
|
4
5
|
export declare const sassVersion = "1.62.1";
|
|
5
6
|
export declare const lessLoader = "11.1.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.nextVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.emotionServerVersion = exports.lessLoader = exports.sassVersion = exports.eslintConfigNextVersion = exports.next14Version = exports.nextVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.nextVersion = '
|
|
5
|
+
exports.nextVersion = '~15.1.4';
|
|
6
|
+
exports.next14Version = '~14.2.16';
|
|
6
7
|
exports.eslintConfigNextVersion = '14.2.16';
|
|
7
8
|
exports.sassVersion = '1.62.1';
|
|
8
9
|
exports.lessLoader = '11.1.0';
|