@nx/next 23.3.0-pr.37068.f95e11e → 23.3.0-pr.37224.268062c
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/README.md +1 -1
- package/dist/src/executors/build/build.impl.js +1 -2
- package/dist/src/executors/server/server.impl.js +1 -2
- package/dist/src/generators/application/lib/add-linting.js +19 -12
- package/dist/src/generators/init/init.js +9 -0
- package/dist/src/plugins/plugin.js +17 -8
- package/dist/src/utils/add-swc-to-custom-server.js +1 -0
- package/dist/src/utils/styles.js +8 -0
- package/package.json +13 -13
- package/readme-template.md +18 -0
- package/dist/src/utils/create-cli-options.d.ts +0 -1
- package/dist/src/utils/create-cli-options.js +0 -15
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](<>)
|
|
13
13
|
[](http://commitizen.github.io/cz-cli/)
|
|
14
14
|
[](https://go.nx.dev/community)
|
|
15
|
-
[](https://nx.dev/nx-cloud)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -11,7 +11,6 @@ const update_package_json_1 = require("./lib/update-package-json");
|
|
|
11
11
|
const create_next_config_file_1 = require("./lib/create-next-config-file");
|
|
12
12
|
const check_project_1 = require("./lib/check-project");
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
|
-
const create_cli_options_1 = require("../../utils/create-cli-options");
|
|
15
14
|
const internal_1 = require("@nx/devkit/internal");
|
|
16
15
|
const runtime_version_utils_1 = require("../../utils/runtime-version-utils");
|
|
17
16
|
const deprecation_1 = require("../../utils/deprecation");
|
|
@@ -123,7 +122,7 @@ function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
|
123
122
|
devkit_1.logger.warn('The --webpack flag is only applicable in Next.js 16 and above. It will be ignored.');
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
const args = (0,
|
|
125
|
+
const args = (0, internal_1.createCliOptions)(cliOptions);
|
|
127
126
|
return new Promise((resolve, reject) => {
|
|
128
127
|
childProcess = (0, child_process_1.fork)(require.resolve('next/dist/bin/next'), ['build', ...args], {
|
|
129
128
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const custom_server_impl_1 = tslib_1.__importDefault(require("./custom-server.impl"));
|
|
10
|
-
const create_cli_options_1 = require("../../utils/create-cli-options");
|
|
11
10
|
const internal_2 = require("@nx/web/internal");
|
|
12
11
|
const runtime_version_utils_1 = require("../../utils/runtime-version-utils");
|
|
13
12
|
const deprecation_1 = require("../../utils/deprecation");
|
|
@@ -31,7 +30,7 @@ async function* serveExecutor(options, context) {
|
|
|
31
30
|
// Setting port that the custom server should use.
|
|
32
31
|
process.env.PORT = options.port ? `${options.port}` : process.env.PORT;
|
|
33
32
|
options.port = parseInt(process.env.PORT);
|
|
34
|
-
const args = (0,
|
|
33
|
+
const args = (0, internal_1.createCliOptions)({ port: options.port, hostname });
|
|
35
34
|
if (keepAliveTimeout && !options.dev) {
|
|
36
35
|
args.push(`--keepAliveTimeout=${keepAliveTimeout}`);
|
|
37
36
|
}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = addLinting;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const react_1 = require("@nx/react");
|
|
6
|
-
const
|
|
7
|
+
const internal_2 = require("@nx/eslint/internal");
|
|
7
8
|
const version_utils_1 = require("../../../utils/version-utils");
|
|
8
|
-
const
|
|
9
|
+
const internal_3 = require("@nx/js/internal");
|
|
9
10
|
async function addLinting(host, options) {
|
|
10
11
|
const tasks = [];
|
|
11
|
-
tasks.push(await (0,
|
|
12
|
+
tasks.push(await (0, internal_3.addLintingToProject)(host, {
|
|
12
13
|
oxlintPlugins: ['nextjs', 'react', 'react-perf', 'jsx-a11y'],
|
|
13
14
|
linter: options.linter,
|
|
14
15
|
project: options.projectName,
|
|
@@ -17,21 +18,21 @@ async function addLinting(host, options) {
|
|
|
17
18
|
],
|
|
18
19
|
unitTestRunner: options.unitTestRunner,
|
|
19
20
|
rootProject: options.rootProject,
|
|
20
|
-
enableTypedLinting: (0,
|
|
21
|
+
enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(options),
|
|
21
22
|
addPlugin: options.addPlugin,
|
|
22
23
|
skipPackageJson: options.skipPackageJson,
|
|
23
24
|
}));
|
|
24
25
|
// Everything below configures ESLint — predefined configs, `extends`, ignore
|
|
25
26
|
// entries — which have no equivalent in other linters.
|
|
26
|
-
if (options.linter === 'eslint' && (0,
|
|
27
|
-
if ((0,
|
|
28
|
-
(0,
|
|
27
|
+
if (options.linter === 'eslint' && (0, internal_2.isEslintConfigSupported)(host)) {
|
|
28
|
+
if ((0, internal_2.useFlatConfig)(host)) {
|
|
29
|
+
(0, internal_2.addPredefinedConfigToFlatLintConfig)(host, options.appProjectRoot, 'flat/react-typescript', { checkBaseConfig: true });
|
|
29
30
|
if (await (0, version_utils_1.isNext16)(host)) {
|
|
30
|
-
(0,
|
|
31
|
+
(0, internal_2.addPluginsToLintConfig)(host, options.appProjectRoot, ['@next/next']);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
// Since Next.js < 16 does not support flat configs yet, we need to use compat fixup.
|
|
34
|
-
const addExtendsTask = (0,
|
|
35
|
+
const addExtendsTask = (0, internal_2.addExtendsToLintConfig)(host, options.appProjectRoot, [
|
|
35
36
|
{ name: 'next', needCompatFixup: true },
|
|
36
37
|
{
|
|
37
38
|
name: 'next/core-web-vitals',
|
|
@@ -42,14 +43,14 @@ async function addLinting(host, options) {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
|
-
const addExtendsTask = (0,
|
|
46
|
+
const addExtendsTask = (0, internal_2.addExtendsToLintConfig)(host, options.appProjectRoot, [
|
|
46
47
|
'plugin:@nx/react-typescript',
|
|
47
48
|
{ name: 'next', needCompatFixup: true },
|
|
48
49
|
{ name: 'next/core-web-vitals', needCompatFixup: true },
|
|
49
50
|
]);
|
|
50
51
|
tasks.push(addExtendsTask);
|
|
51
52
|
}
|
|
52
|
-
(0,
|
|
53
|
+
(0, internal_2.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
|
|
53
54
|
o.files.some((f) => f.match(/\*\.ts$/)) &&
|
|
54
55
|
o.files.some((f) => f.match(/\*\.tsx$/)) &&
|
|
55
56
|
o.files.some((f) => f.match(/\*\.js$/)) &&
|
|
@@ -63,13 +64,19 @@ async function addLinting(host, options) {
|
|
|
63
64
|
],
|
|
64
65
|
},
|
|
65
66
|
}));
|
|
66
|
-
(0,
|
|
67
|
+
(0, internal_2.addIgnoresToLintConfig)(host, options.appProjectRoot, [
|
|
67
68
|
'.next/**/*',
|
|
68
69
|
...(options.isTsSolutionSetup ? ['**/out-tsc'] : []),
|
|
69
70
|
]);
|
|
70
71
|
}
|
|
71
72
|
if (options.linter === 'eslint' && !options.skipPackageJson) {
|
|
72
73
|
const eslintConfigNextVersion = await (0, version_utils_1.getEslintConfigNextDependenciesVersionsToInstall)(host);
|
|
74
|
+
// eslint-config-next pulls in unrs-resolver via
|
|
75
|
+
// eslint-import-resolver-typescript, whose postinstall only fetches a
|
|
76
|
+
// fallback binding for platforms its prebuilt optional dependencies miss.
|
|
77
|
+
(0, internal_1.acknowledgeBuildScripts)(host, (0, devkit_1.detectPackageManager)(host.root), {
|
|
78
|
+
'unrs-resolver': false,
|
|
79
|
+
});
|
|
73
80
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, react_1.extraEslintDependencies.dependencies, {
|
|
74
81
|
...react_1.extraEslintDependencies.devDependencies,
|
|
75
82
|
'eslint-config-next': eslintConfigNextVersion,
|
|
@@ -5,6 +5,7 @@ exports.nextInitGeneratorInternal = nextInitGeneratorInternal;
|
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const internal_2 = require("@nx/react/internal");
|
|
8
|
+
const semver_1 = require("semver");
|
|
8
9
|
const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
|
|
9
10
|
const versions_1 = require("../../utils/versions");
|
|
10
11
|
const version_utils_1 = require("../../utils/version-utils");
|
|
@@ -14,6 +15,14 @@ async function updateDependencies(host, schema) {
|
|
|
14
15
|
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/next'], []));
|
|
15
16
|
const versions = await (0, version_utils_1.getNextDependenciesVersionsToInstall)(host, await (0, internal_2.isReact18)(host));
|
|
16
17
|
const reactVersions = await (0, internal_2.getReactDependenciesVersionsToInstall)(host);
|
|
18
|
+
// next 15+ pulls in sharp, whose install script only compiles from source
|
|
19
|
+
// against a system libvips and is otherwise a no-op; the prebuilt binaries
|
|
20
|
+
// ship via optional dependencies, so skip it.
|
|
21
|
+
if ((0, semver_1.major)((0, semver_1.coerce)(versions.next)) >= 15) {
|
|
22
|
+
(0, internal_1.acknowledgeBuildScripts)(host, (0, devkit_1.detectPackageManager)(host.root), {
|
|
23
|
+
sharp: false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
17
26
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
18
27
|
next: versions.next,
|
|
19
28
|
react: reactVersions.react,
|
|
@@ -131,18 +131,27 @@ function getStartTargetConfig(namedInputs, options, projectRoot) {
|
|
|
131
131
|
return targetConfig;
|
|
132
132
|
}
|
|
133
133
|
async function getOutputs(projectRoot, nextConfig) {
|
|
134
|
-
let dir = '.next';
|
|
135
134
|
const { PHASE_PRODUCTION_BUILD } = require('next/constants');
|
|
135
|
+
let resolvedConfig;
|
|
136
136
|
if (typeof nextConfig === 'function') {
|
|
137
137
|
// Works for both async and sync functions.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
resolvedConfig = await Promise.resolve(nextConfig(PHASE_PRODUCTION_BUILD, { defaultConfig: {} }));
|
|
139
|
+
}
|
|
140
|
+
else if (typeof nextConfig === 'object') {
|
|
141
|
+
resolvedConfig = nextConfig;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
// Mirrors Next.js' own `hasCustomExportOutput` check. With `output: 'export'`,
|
|
144
|
+
// `next build` treats a custom `distDir` as the export directory and falls back
|
|
145
|
+
// to `out` otherwise, reusing `.next` internally for intermediate artifacts.
|
|
146
|
+
let dir;
|
|
147
|
+
if (resolvedConfig?.output === 'export') {
|
|
148
|
+
dir =
|
|
149
|
+
resolvedConfig.distDir && resolvedConfig.distDir !== '.next'
|
|
150
|
+
? resolvedConfig.distDir
|
|
151
|
+
: 'out';
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
dir = resolvedConfig?.distDir || '.next';
|
|
146
155
|
}
|
|
147
156
|
if (projectRoot === '.') {
|
|
148
157
|
return `{projectRoot}/${dir}`;
|
|
@@ -23,6 +23,7 @@ function configureForSwc(tree, projectRoot, swcConfigName = '.swcrc', additonalE
|
|
|
23
23
|
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
24
24
|
}
|
|
25
25
|
function addSwcDependencies(tree) {
|
|
26
|
+
(0, internal_1.acknowledgeSwcBuildScripts)(tree);
|
|
26
27
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
27
28
|
'@swc/helpers': internal_1.swcHelpersVersion,
|
|
28
29
|
}, {
|
package/dist/src/utils/styles.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addStyleDependencies = addStyleDependencies;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const versions_1 = require("./versions");
|
|
6
7
|
const nextSpecificStyleDependencies = {
|
|
7
8
|
css: {
|
|
@@ -15,6 +16,13 @@ const nextSpecificStyleDependencies = {
|
|
|
15
16
|
};
|
|
16
17
|
function addStyleDependencies(host, options) {
|
|
17
18
|
const extraDependencies = nextSpecificStyleDependencies[options.style];
|
|
19
|
+
if (options.style === 'scss') {
|
|
20
|
+
// sass pulls in @parcel/watcher, whose install script only builds from
|
|
21
|
+
// source when npm_config_build_from_source is set.
|
|
22
|
+
(0, internal_1.acknowledgeBuildScripts)(host, (0, devkit_1.detectPackageManager)(host.root), {
|
|
23
|
+
'@parcel/watcher': false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
18
26
|
return extraDependencies
|
|
19
27
|
? (0, devkit_1.addDependenciesToPackageJson)(host, extraDependencies.dependencies, extraDependencies.devDependencies, undefined, true)
|
|
20
28
|
: () => { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "23.3.0-pr.
|
|
3
|
+
"version": "23.3.0-pr.37224.268062c",
|
|
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.3.0-pr.
|
|
71
|
+
"@nx/webpack": "23.3.0-pr.37224.268062c"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
74
74
|
"@nx/webpack": {
|
|
@@ -76,26 +76,26 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
+
"@nx/devkit": "23.3.0-pr.37224.268062c",
|
|
79
80
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
80
81
|
"copy-webpack-plugin": "^14.0.0",
|
|
81
82
|
"ignore": "^7.0.5",
|
|
82
83
|
"semver": "^7.6.3",
|
|
83
84
|
"tslib": "^2.3.0",
|
|
84
85
|
"webpack-merge": "^5.8.0",
|
|
85
|
-
"@
|
|
86
|
-
"@nx/
|
|
87
|
-
"@nx/
|
|
88
|
-
"@nx/
|
|
89
|
-
"@
|
|
90
|
-
"@nx/web": "23.3.0-pr.37068.f95e11e"
|
|
86
|
+
"@nx/js": "23.3.0-pr.37224.268062c",
|
|
87
|
+
"@nx/eslint": "23.3.0-pr.37224.268062c",
|
|
88
|
+
"@nx/react": "23.3.0-pr.37224.268062c",
|
|
89
|
+
"@nx/web": "23.3.0-pr.37224.268062c",
|
|
90
|
+
"@phenomnomnominal/tsquery": "~6.2.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
+
"@nx/cypress": "23.3.0-pr.37224.268062c",
|
|
94
|
+
"@nx/playwright": "23.3.0-pr.37224.268062c",
|
|
95
|
+
"@nx/vitest": "23.3.0-pr.37224.268062c",
|
|
96
|
+
"@nx/webpack": "23.3.0-pr.37224.268062c",
|
|
93
97
|
"next": "15.5.25",
|
|
94
|
-
"
|
|
95
|
-
"@nx/playwright": "23.3.0-pr.37068.f95e11e",
|
|
96
|
-
"@nx/vitest": "23.3.0-pr.37068.f95e11e",
|
|
97
|
-
"@nx/webpack": "23.3.0-pr.37068.f95e11e",
|
|
98
|
-
"nx": "23.3.0-pr.37068.f95e11e"
|
|
98
|
+
"nx": "23.3.0-pr.37224.268062c"
|
|
99
99
|
},
|
|
100
100
|
"publishConfig": {
|
|
101
101
|
"access": "public"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
{{links}}
|
|
9
|
+
|
|
10
|
+
<hr>
|
|
11
|
+
|
|
12
|
+
# Nx: Smart Monorepos · Fast Builds
|
|
13
|
+
|
|
14
|
+
Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
|
|
15
|
+
|
|
16
|
+
This package is a [Next.js plugin for Nx](https://nx.dev/next/overview).
|
|
17
|
+
|
|
18
|
+
{{content}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createCliOptions(obj: Record<string, string | number | boolean>): string[];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCliOptions = createCliOptions;
|
|
4
|
-
function createCliOptions(obj) {
|
|
5
|
-
return Object.entries(obj).reduce((arr, [key, value]) => {
|
|
6
|
-
if (value !== undefined) {
|
|
7
|
-
const kebabCase = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
8
|
-
if (value === true || typeof value !== 'boolean') {
|
|
9
|
-
// Boolean flags don't need a value (e.g. --debug)
|
|
10
|
-
arr.push(`--${kebabCase}` + (typeof value !== 'boolean' ? `=${value}` : ''));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return arr;
|
|
14
|
-
}, []);
|
|
15
|
-
}
|