@nx/next 24.0.0-beta.2 → 24.0.0-beta.3
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/dist/plugins/component-testing.js +19 -62
- package/dist/plugins/with-nx.d.ts +14 -10
- package/dist/plugins/with-nx.js +24 -255
- package/dist/src/generators/application/application.js +1 -2
- package/dist/src/generators/application/files/common/next.config.js__tmpl__ +0 -22
- package/dist/src/generators/application/lib/add-e2e.js +5 -6
- package/dist/src/generators/application/lib/add-linting.js +0 -1
- package/dist/src/generators/application/lib/add-project.js +1 -46
- package/dist/src/generators/application/lib/add-vitest.js +0 -1
- package/dist/src/generators/application/lib/normalize-options.js +0 -4
- package/dist/src/generators/application/schema.d.ts +0 -1
- package/dist/src/generators/custom-server/custom-server.js +6 -25
- package/dist/src/generators/custom-server/files/server/main.ts__tmpl__ +3 -3
- package/dist/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +1 -1
- package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.js +1 -14
- package/dist/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/dist/src/generators/init/init.js +14 -28
- package/dist/src/generators/init/schema.d.ts +0 -1
- package/dist/src/generators/library/lib/add-rollup-server-entry.js +7 -16
- package/dist/src/generators/library/lib/normalize-options.js +0 -5
- package/dist/src/generators/library/library.js +1 -2
- package/dist/src/generators/library/schema.d.ts +0 -1
- package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +12 -0
- package/dist/src/migrations/update-24-0-0/migrate-config-helpers.md +80 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +18 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +89 -0
- package/dist/src/utils/compose-plugins.d.ts +6 -1
- package/dist/src/utils/compose-plugins.js +20 -29
- package/dist/src/utils/deprecation.d.ts +0 -5
- package/dist/src/utils/deprecation.js +9 -31
- package/executors.json +1 -12
- package/migrations.json +12 -0
- package/package.json +13 -13
- package/dist/src/executors/build/build.impl.d.ts +0 -5
- package/dist/src/executors/build/build.impl.js +0 -154
- package/dist/src/executors/build/lib/check-project.d.ts +0 -1
- package/dist/src/executors/build/lib/check-project.js +0 -11
- package/dist/src/executors/build/lib/create-next-config-file.d.ts +0 -14
- package/dist/src/executors/build/lib/create-next-config-file.js +0 -171
- package/dist/src/executors/build/lib/update-package-json.d.ts +0 -3
- package/dist/src/executors/build/lib/update-package-json.js +0 -31
- package/dist/src/executors/build/schema.json +0 -98
- package/dist/src/executors/server/custom-server.impl.d.ts +0 -6
- package/dist/src/executors/server/custom-server.impl.js +0 -37
- package/dist/src/executors/server/schema.json +0 -85
- package/dist/src/executors/server/server.impl.d.ts +0 -6
- package/dist/src/executors/server/server.impl.js +0 -115
- package/dist/src/utils/runtime-version-utils.d.ts +0 -7
- package/dist/src/utils/runtime-version-utils.js +0 -28
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 2,
|
|
3
|
-
"continuous": true,
|
|
4
|
-
"outputCapture": "pipe",
|
|
5
|
-
"cli": "nx",
|
|
6
|
-
"title": "Next Serve",
|
|
7
|
-
"description": "Serve a Next.js app.",
|
|
8
|
-
"type": "object",
|
|
9
|
-
"x-deprecated": "The `@nx/next:server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/next:convert-to-inferred` to migrate to the `@nx/next/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
|
|
10
|
-
"properties": {
|
|
11
|
-
"dev": {
|
|
12
|
-
"type": "boolean",
|
|
13
|
-
"description": "Serve the application in the dev mode.",
|
|
14
|
-
"default": true
|
|
15
|
-
},
|
|
16
|
-
"buildTarget": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "Target which builds the application.",
|
|
19
|
-
"x-priority": "important"
|
|
20
|
-
},
|
|
21
|
-
"port": {
|
|
22
|
-
"type": "number",
|
|
23
|
-
"description": "Port to listen on.",
|
|
24
|
-
"default": 4200,
|
|
25
|
-
"x-priority": "important"
|
|
26
|
-
},
|
|
27
|
-
"staticMarkup": {
|
|
28
|
-
"type": "boolean",
|
|
29
|
-
"description": "Static markup.",
|
|
30
|
-
"default": false
|
|
31
|
-
},
|
|
32
|
-
"quiet": {
|
|
33
|
-
"type": "boolean",
|
|
34
|
-
"description": "Hide error messages containing server information.",
|
|
35
|
-
"default": false
|
|
36
|
-
},
|
|
37
|
-
"customServerTarget": {
|
|
38
|
-
"type": "string",
|
|
39
|
-
"description": "Target which builds the custom server."
|
|
40
|
-
},
|
|
41
|
-
"hostname": {
|
|
42
|
-
"type": "string",
|
|
43
|
-
"description": "Hostname on which the application is served."
|
|
44
|
-
},
|
|
45
|
-
"buildLibsFromSource": {
|
|
46
|
-
"type": "boolean",
|
|
47
|
-
"description": "Read buildable libraries from source instead of building them separately.",
|
|
48
|
-
"default": true
|
|
49
|
-
},
|
|
50
|
-
"keepAliveTimeout": {
|
|
51
|
-
"type": "number",
|
|
52
|
-
"description": "Max milliseconds to wait before closing inactive connection."
|
|
53
|
-
},
|
|
54
|
-
"turbo": {
|
|
55
|
-
"type": "boolean",
|
|
56
|
-
"description": "Activate Turbopack for Next.js (Next.js 15 and below). In Next.js 16+, Turbopack is enabled by default for development mode."
|
|
57
|
-
},
|
|
58
|
-
"webpack": {
|
|
59
|
-
"type": "boolean",
|
|
60
|
-
"description": "Use webpack bundler instead of Turbopack (Next.js 16+ only). This flag is only applicable in Next.js 16 and above where Turbopack is the default for development mode."
|
|
61
|
-
},
|
|
62
|
-
"experimentalHttps": {
|
|
63
|
-
"type": "boolean",
|
|
64
|
-
"description": "Enable HTTPS support for the Next.js development server."
|
|
65
|
-
},
|
|
66
|
-
"experimentalHttpsKey": {
|
|
67
|
-
"type": "string",
|
|
68
|
-
"description": "Path to a HTTPS key file."
|
|
69
|
-
},
|
|
70
|
-
"experimentalHttpsCert": {
|
|
71
|
-
"type": "string",
|
|
72
|
-
"description": "Path to a HTTPS certificate file."
|
|
73
|
-
},
|
|
74
|
-
"experimentalHttpsCa": {
|
|
75
|
-
"type": "string",
|
|
76
|
-
"description": "Path to a HTTPS certificate authority file."
|
|
77
|
-
},
|
|
78
|
-
"customServerHttps:": {
|
|
79
|
-
"type": "boolean",
|
|
80
|
-
"description": "Enable HTTPS support for the custom server."
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"required": ["buildTarget"],
|
|
84
|
-
"examplesFile": "../../../docs/server-next-executor-examples.md"
|
|
85
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { NextServeBuilderOptions } from '../../utils/types';
|
|
3
|
-
export default function serveExecutor(options: NextServeBuilderOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
|
-
success: boolean;
|
|
5
|
-
baseUrl: string;
|
|
6
|
-
}, void, any>;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = serveExecutor;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const child_process_1 = require("child_process");
|
|
9
|
-
const custom_server_impl_1 = tslib_1.__importDefault(require("./custom-server.impl"));
|
|
10
|
-
const internal_2 = require("@nx/web/internal");
|
|
11
|
-
const runtime_version_utils_1 = require("../../utils/runtime-version-utils");
|
|
12
|
-
const deprecation_1 = require("../../utils/deprecation");
|
|
13
|
-
async function* serveExecutor(options, context) {
|
|
14
|
-
(0, deprecation_1.warnNextServerExecutorDeprecation)();
|
|
15
|
-
const buildOptions = (0, devkit_1.readTargetOptions)((0, devkit_1.parseTargetString)(options.buildTarget, context), context);
|
|
16
|
-
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
17
|
-
// This is required for the default custom server to work. See the @nx/next:app generator.
|
|
18
|
-
const nextDir = !options.dev && (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
19
|
-
process.env.NX_NEXT_DIR ??= options.dev ? projectRoot : nextDir;
|
|
20
|
-
if (options.customServerTarget) {
|
|
21
|
-
return yield* (0, custom_server_impl_1.default)(options, context);
|
|
22
|
-
}
|
|
23
|
-
const { keepAliveTimeout, hostname } = options;
|
|
24
|
-
// Cast to any to overwrite NODE_ENV
|
|
25
|
-
process.env.NODE_ENV = process.env.NODE_ENV
|
|
26
|
-
? process.env.NODE_ENV
|
|
27
|
-
: options.dev
|
|
28
|
-
? 'development'
|
|
29
|
-
: 'production';
|
|
30
|
-
// Setting port that the custom server should use.
|
|
31
|
-
process.env.PORT = options.port ? `${options.port}` : process.env.PORT;
|
|
32
|
-
options.port = parseInt(process.env.PORT);
|
|
33
|
-
const args = (0, internal_1.createCliOptions)({ port: options.port, hostname });
|
|
34
|
-
if (keepAliveTimeout && !options.dev) {
|
|
35
|
-
args.push(`--keepAliveTimeout=${keepAliveTimeout}`);
|
|
36
|
-
}
|
|
37
|
-
const mode = options.dev ? 'dev' : 'start';
|
|
38
|
-
// Determine bundler flag based on Next.js version and options
|
|
39
|
-
let bundlerFlag = '';
|
|
40
|
-
if (options.dev) {
|
|
41
|
-
// Check for conflicting flags
|
|
42
|
-
if (options.turbo && options.webpack) {
|
|
43
|
-
throw new Error('Cannot specify both --turbo and --webpack flags. Please use only one bundler option.');
|
|
44
|
-
}
|
|
45
|
-
const nextJsVersion = (0, runtime_version_utils_1.getInstalledNextVersionRuntime)();
|
|
46
|
-
const isNext16Plus = nextJsVersion !== null && nextJsVersion >= 16;
|
|
47
|
-
if (isNext16Plus) {
|
|
48
|
-
// Next.js 16+: Turbopack is default, use --webpack to opt-in to webpack
|
|
49
|
-
if (options.webpack) {
|
|
50
|
-
bundlerFlag = '--webpack';
|
|
51
|
-
devkit_1.logger.info('Using webpack bundler (Next.js 16+ detected)');
|
|
52
|
-
}
|
|
53
|
-
else if (options.turbo) {
|
|
54
|
-
devkit_1.logger.warn('The --turbo flag is redundant in Next.js 16+ as Turbopack is now the default bundler. You can remove this flag.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// Next.js 15 and below: webpack is default, use --turbo to opt-in to turbopack
|
|
59
|
-
if (options.turbo) {
|
|
60
|
-
bundlerFlag = '--turbo';
|
|
61
|
-
}
|
|
62
|
-
else if (options.webpack) {
|
|
63
|
-
devkit_1.logger.warn('The --webpack flag is only applicable in Next.js 16 and above. It will be ignored.');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const nextBin = require.resolve('next/dist/bin/next');
|
|
68
|
-
yield* (0, internal_1.createAsyncIterable)(async ({ done, next, error }) => {
|
|
69
|
-
const server = (0, child_process_1.fork)(nextBin, [
|
|
70
|
-
mode,
|
|
71
|
-
...args,
|
|
72
|
-
bundlerFlag,
|
|
73
|
-
...getExperimentalHttpsFlags(options),
|
|
74
|
-
].filter((arg) => arg !== ''), {
|
|
75
|
-
cwd: options.dev ? projectRoot : nextDir,
|
|
76
|
-
stdio: 'inherit',
|
|
77
|
-
});
|
|
78
|
-
server.once('exit', (code) => {
|
|
79
|
-
if (code === 0) {
|
|
80
|
-
done();
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
error(new Error(`Next.js app exited with code ${code}`));
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const killServer = () => {
|
|
87
|
-
if (server.connected) {
|
|
88
|
-
server.kill('SIGTERM');
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
process.on('exit', () => killServer());
|
|
92
|
-
process.on('SIGINT', () => killServer());
|
|
93
|
-
process.on('SIGTERM', () => killServer());
|
|
94
|
-
process.on('SIGHUP', () => killServer());
|
|
95
|
-
await (0, internal_2.waitForPortOpen)(options.port, { host: options.hostname });
|
|
96
|
-
next({
|
|
97
|
-
success: true,
|
|
98
|
-
baseUrl: `http://${options.hostname ?? 'localhost'}:${options.port}`,
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function getExperimentalHttpsFlags(options) {
|
|
103
|
-
if (!options.dev)
|
|
104
|
-
return [];
|
|
105
|
-
const flags = [];
|
|
106
|
-
if (options.experimentalHttps)
|
|
107
|
-
flags.push('--experimental-https');
|
|
108
|
-
if (options.experimentalHttpsKey)
|
|
109
|
-
flags.push(`--experimental-https-key=${options.experimentalHttpsKey}`);
|
|
110
|
-
if (options.experimentalHttpsCert)
|
|
111
|
-
flags.push(`--experimental-https-cert=${options.experimentalHttpsCert}`);
|
|
112
|
-
if (options.experimentalHttpsCa)
|
|
113
|
-
flags.push(`--experimental-https-ca=${options.experimentalHttpsCa}`);
|
|
114
|
-
return flags;
|
|
115
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the installed Next.js major version at runtime without requiring a Tree object.
|
|
3
|
-
* This is useful for executors that need to detect the Next.js version during execution.
|
|
4
|
-
*
|
|
5
|
-
* @returns The major version number of the installed Next.js package, or null if not found
|
|
6
|
-
*/
|
|
7
|
-
export declare function getInstalledNextVersionRuntime(): number | null;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInstalledNextVersionRuntime = getInstalledNextVersionRuntime;
|
|
4
|
-
const semver_1 = require("semver");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
/**
|
|
7
|
-
* Get the installed Next.js major version at runtime without requiring a Tree object.
|
|
8
|
-
* This is useful for executors that need to detect the Next.js version during execution.
|
|
9
|
-
*
|
|
10
|
-
* @returns The major version number of the installed Next.js package, or null if not found
|
|
11
|
-
*/
|
|
12
|
-
function getInstalledNextVersionRuntime() {
|
|
13
|
-
try {
|
|
14
|
-
const nextPackageJsonPath = require.resolve('next/package.json', {
|
|
15
|
-
paths: [process.cwd()],
|
|
16
|
-
});
|
|
17
|
-
const nextPackageJson = (0, devkit_1.readJsonFile)(nextPackageJsonPath);
|
|
18
|
-
const cleanedVersion = (0, semver_1.clean)(nextPackageJson.version) ??
|
|
19
|
-
(0, semver_1.coerce)(nextPackageJson.version)?.version;
|
|
20
|
-
if (!cleanedVersion) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return (0, semver_1.major)(cleanedVersion);
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|