@nx/webpack 24.0.0-pr.37405.acdaf31 → 24.0.0-rc.0
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +7 -1
- package/dist/ready-check.d.ts +1 -0
- package/dist/ready-check.js +9 -0
- package/dist/ready-signal.d.ts +1 -0
- package/dist/ready-signal.js +5 -0
- package/dist/src/executors/dev-server/dev-server.impl.js +38 -30
- package/dist/src/executors/ssr-dev-server/schema.json +2 -1
- package/dist/src/executors/ssr-dev-server/ssr-dev-server.impl.js +2 -0
- package/dist/src/generators/configuration/configuration.js +14 -132
- package/dist/src/generators/configuration/schema.d.ts +0 -1
- package/dist/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.js +97 -57
- package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts +2 -0
- package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.js +46 -2
- package/dist/src/generators/convert-config-to-webpack-plugin/schema.json +2 -2
- package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +5 -4
- package/dist/src/generators/convert-to-inferred/utils/ast.d.ts +2 -0
- package/dist/src/generators/convert-to-inferred/utils/ast.js +13 -0
- package/dist/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +25 -5
- package/dist/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +13 -14
- package/dist/src/generators/init/init.js +45 -54
- package/dist/src/generators/init/schema.d.ts +0 -1
- package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +11 -0
- package/dist/src/migrations/update-24-0-0/inventory.d.ts +10 -0
- package/dist/src/migrations/update-24-0-0/inventory.js +55 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.d.ts +10 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.js +68 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.md +98 -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 +39 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +92 -0
- package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +6 -0
- package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.js +29 -24
- package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts +2 -0
- package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +18 -1
- package/dist/src/plugins/plugin.js +18 -0
- package/dist/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +3 -0
- package/dist/src/utils/config.d.ts +8 -12
- package/dist/src/utils/config.js +15 -68
- package/dist/src/utils/deprecation.d.ts +3 -6
- package/dist/src/utils/deprecation.js +10 -27
- package/dist/src/utils/dev-server-ready-check.d.ts +36 -0
- package/dist/src/utils/dev-server-ready-check.js +255 -0
- package/dist/src/utils/dev-server-ready-signal.d.ts +29 -0
- package/dist/src/utils/dev-server-ready-signal.js +51 -0
- package/dist/src/utils/e2e-web-server-info-utils.d.ts +1 -1
- package/dist/src/utils/e2e-web-server-info-utils.js +2 -2
- package/dist/src/utils/webpack/read-webpack-options.d.ts +1 -1
- package/dist/src/utils/webpack/read-webpack-options.js +4 -4
- package/dist/src/utils/with-nx.d.ts +5 -9
- package/dist/src/utils/with-nx.js +5 -32
- package/dist/src/utils/with-web.d.ts +5 -9
- package/dist/src/utils/with-web.js +5 -24
- package/executors.json +0 -10
- package/migrations.json +13 -0
- package/package.json +20 -4
- package/dist/src/executors/webpack/lib/run-webpack.d.ts +0 -3
- package/dist/src/executors/webpack/lib/run-webpack.js +0 -36
- package/dist/src/executors/webpack/schema.json +0 -459
- package/dist/src/executors/webpack/webpack.impl.d.ts +0 -13
- package/dist/src/executors/webpack/webpack.impl.js +0 -117
- package/dist/src/utils/has-plugin.d.ts +0 -2
- package/dist/src/utils/has-plugin.js +0 -10
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#### Convert `@nx/webpack` build and dev-server targets to inferred tasks
|
|
2
|
+
|
|
3
|
+
Nx 24 removes the `@nx/webpack:webpack` and `@nx/webpack:dev-server` executors and their `@nrwl` aliases. The migration registers `@nx/webpack/plugin` in `nx.json` and converts the targets that use those executors to inferred tasks. It moves the executor options into `webpack.config.*`. A target with nothing left to override is removed from project configuration. When several projects share the same remaining options, those options move to a `targetDefaults` entry scoped to the plugin. `targetDefaults` entries keyed by a removed executor are removed once no target uses that executor.
|
|
4
|
+
|
|
5
|
+
The migration lists the targets the converter cannot convert safely. In agentic runs, an AI prompt finishes them and validates the project graph.
|
|
6
|
+
|
|
7
|
+
The `@nx/webpack:ssr-dev-server` executor stays.
|
|
8
|
+
|
|
9
|
+
#### Sample code changes
|
|
10
|
+
|
|
11
|
+
The example shows the `build` target. Its options move into `webpack.config.*`, so only the configuration names stay on the target.
|
|
12
|
+
|
|
13
|
+
##### Before
|
|
14
|
+
|
|
15
|
+
```json title="apps/app1/project.json"
|
|
16
|
+
{
|
|
17
|
+
"name": "app1",
|
|
18
|
+
"targets": {
|
|
19
|
+
"build": {
|
|
20
|
+
"executor": "@nx/webpack:webpack",
|
|
21
|
+
"options": {
|
|
22
|
+
"webpackConfig": "apps/app1/webpack.config.js",
|
|
23
|
+
"outputPath": "dist/apps/app1",
|
|
24
|
+
"index": "apps/app1/src/index.html",
|
|
25
|
+
"main": "apps/app1/src/main.tsx",
|
|
26
|
+
"tsConfig": "apps/app1/tsconfig.app.json",
|
|
27
|
+
"assets": ["apps/app1/src/favicon.ico", "apps/app1/src/assets"],
|
|
28
|
+
"styles": ["apps/app1/src/styles.scss"],
|
|
29
|
+
"scripts": [],
|
|
30
|
+
"compiler": "babel",
|
|
31
|
+
"baseHref": "/"
|
|
32
|
+
},
|
|
33
|
+
"configurations": {
|
|
34
|
+
"development": {
|
|
35
|
+
"extractLicenses": false,
|
|
36
|
+
"optimization": false,
|
|
37
|
+
"sourceMap": true,
|
|
38
|
+
"vendorChunk": true
|
|
39
|
+
},
|
|
40
|
+
"production": {
|
|
41
|
+
"fileReplacements": [
|
|
42
|
+
{
|
|
43
|
+
"replace": "apps/app1/src/environments/environment.ts",
|
|
44
|
+
"with": "apps/app1/src/environments/environment.prod.ts"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"optimization": true,
|
|
48
|
+
"outputHashing": "all",
|
|
49
|
+
"sourceMap": false,
|
|
50
|
+
"namedChunks": false,
|
|
51
|
+
"extractLicenses": true,
|
|
52
|
+
"vendorChunk": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"defaultConfiguration": "production"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
##### After
|
|
62
|
+
|
|
63
|
+
```json title="apps/app1/project.json"
|
|
64
|
+
{
|
|
65
|
+
"name": "app1",
|
|
66
|
+
"targets": {
|
|
67
|
+
"build": {
|
|
68
|
+
"configurations": {
|
|
69
|
+
"development": {},
|
|
70
|
+
"production": {}
|
|
71
|
+
},
|
|
72
|
+
"defaultConfiguration": "production"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```json title="nx.json"
|
|
79
|
+
{
|
|
80
|
+
"plugins": [
|
|
81
|
+
{
|
|
82
|
+
"plugin": "@nx/webpack/plugin",
|
|
83
|
+
"options": {
|
|
84
|
+
"buildTargetName": "build",
|
|
85
|
+
"previewTargetName": "preview",
|
|
86
|
+
"serveStaticTargetName": "serve-static",
|
|
87
|
+
"serveTargetName": "serve"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Target } from '@nx/devkit';
|
|
1
3
|
import { AssetGlobPattern, FileReplacement, NormalizedNxAppWebpackPluginOptions, NxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
4
|
+
export declare const webpackExecutorContext: AsyncLocalStorage<{
|
|
5
|
+
options: Partial<NxAppWebpackPluginOptions>;
|
|
6
|
+
target: Target;
|
|
7
|
+
}>;
|
|
2
8
|
export declare function normalizeOptions(options: NxAppWebpackPluginOptions): NormalizedNxAppWebpackPluginOptions;
|
|
3
9
|
export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string, resolveRelativePathsToProjectRoot?: boolean): AssetGlobPattern[];
|
|
4
10
|
export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webpackExecutorContext = void 0;
|
|
3
4
|
exports.normalizeOptions = normalizeOptions;
|
|
4
5
|
exports.normalizeAssets = normalizeAssets;
|
|
5
6
|
exports.normalizeFileReplacements = normalizeFileReplacements;
|
|
7
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
6
8
|
const devkit_1 = require("@nx/devkit");
|
|
7
9
|
const internal_1 = require("@nx/js/internal");
|
|
8
10
|
const fs_1 = require("fs");
|
|
9
11
|
const path_1 = require("path");
|
|
12
|
+
exports.webpackExecutorContext = new node_async_hooks_1.AsyncLocalStorage();
|
|
10
13
|
function normalizeOptions(options) {
|
|
11
14
|
const combinedPluginAndMaybeExecutorOptions = {};
|
|
12
15
|
const isProd = process.env.NODE_ENV === 'production';
|
|
13
16
|
// Since this is invoked by the executor, the graph has already been created and cached.
|
|
14
17
|
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const executorContext = exports.webpackExecutorContext.getStore();
|
|
19
|
+
const taskDetailsFromBuildTarget = executorContext?.target ??
|
|
20
|
+
(process.env.NX_BUILD_TARGET
|
|
21
|
+
? (0, devkit_1.parseTargetString)(process.env.NX_BUILD_TARGET, projectGraph)
|
|
22
|
+
: undefined);
|
|
18
23
|
const projectName = taskDetailsFromBuildTarget
|
|
19
24
|
? taskDetailsFromBuildTarget.project
|
|
20
25
|
: process.env.NX_TASK_TARGET_PROJECT;
|
|
@@ -29,26 +34,15 @@ function normalizeOptions(options) {
|
|
|
29
34
|
normalizeRelativePaths(projectNode.data.root, options);
|
|
30
35
|
// Merge options from `@nx/webpack:webpack` into plugin options.
|
|
31
36
|
// Options from `@nx/webpack:webpack` take precedence.
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Object.assign(buildTargetOptions, targetConfig.configurations?.[configurationName]);
|
|
42
|
-
}
|
|
43
|
-
Object.assign(combinedPluginAndMaybeExecutorOptions, options,
|
|
44
|
-
// executor options take precedence (especially for overriding with CLI args)
|
|
45
|
-
buildTargetOptions);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
Object.assign(combinedPluginAndMaybeExecutorOptions, options,
|
|
49
|
-
// executor options take precedence (especially for overriding with CLI args)
|
|
50
|
-
originalTargetOptions);
|
|
51
|
-
}
|
|
37
|
+
const targetOptions = {
|
|
38
|
+
...targetConfig.options,
|
|
39
|
+
...(configurationName
|
|
40
|
+
? targetConfig.configurations?.[configurationName]
|
|
41
|
+
: undefined),
|
|
42
|
+
};
|
|
43
|
+
Object.assign(combinedPluginAndMaybeExecutorOptions, options, targetOptions);
|
|
44
|
+
const executorOptions = executorContext?.options;
|
|
45
|
+
Object.assign(combinedPluginAndMaybeExecutorOptions, Object.fromEntries(Object.entries(executorOptions ?? {}).filter(([key, value]) => value !== undefined && !isExecutorSchemaDefault(key, value))));
|
|
52
46
|
const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectNode.data);
|
|
53
47
|
if (!combinedPluginAndMaybeExecutorOptions.main) {
|
|
54
48
|
throw new Error(`Missing "main" option for the entry file. Set this option in your Nx webpack plugin.`);
|
|
@@ -56,7 +50,7 @@ function normalizeOptions(options) {
|
|
|
56
50
|
return {
|
|
57
51
|
...combinedPluginAndMaybeExecutorOptions,
|
|
58
52
|
assets: combinedPluginAndMaybeExecutorOptions.assets
|
|
59
|
-
? normalizeAssets(combinedPluginAndMaybeExecutorOptions.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
|
|
53
|
+
? normalizeAssets(combinedPluginAndMaybeExecutorOptions.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root, executorOptions?.assets === undefined)
|
|
60
54
|
: [],
|
|
61
55
|
baseHref: combinedPluginAndMaybeExecutorOptions.baseHref ?? '/',
|
|
62
56
|
buildLibsFromSource: combinedPluginAndMaybeExecutorOptions.buildLibsFromSource ?? true,
|
|
@@ -163,6 +157,17 @@ function normalizeRelativePaths(projectRoot, options) {
|
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
159
|
}
|
|
160
|
+
// Executor-style callers pass options with the removed @nx/webpack:webpack
|
|
161
|
+
// schema defaults applied. Those defaults must not override the plugin's own
|
|
162
|
+
// options; target options still apply above.
|
|
163
|
+
const executorSchemaDefaults = {
|
|
164
|
+
outputFileName: 'main.js',
|
|
165
|
+
standardWebpackConfigFunction: false,
|
|
166
|
+
buildLibsFromSource: true,
|
|
167
|
+
};
|
|
168
|
+
function isExecutorSchemaDefault(key, value) {
|
|
169
|
+
return key in executorSchemaDefaults && executorSchemaDefaults[key] === value;
|
|
170
|
+
}
|
|
166
171
|
function isRelativePath(val) {
|
|
167
172
|
return (typeof val === 'string' &&
|
|
168
173
|
(val.startsWith('./') ||
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from 'webpack';
|
|
2
2
|
import { NxAppWebpackPluginOptions } from './nx-app-webpack-plugin-options';
|
|
3
|
+
import { READY_SIGNAL_PLUGIN } from '../../utils/dev-server-ready-signal';
|
|
3
4
|
/**
|
|
4
5
|
* This plugin provides features to build Node and Web applications.
|
|
5
6
|
* - TS support (including tsconfig paths)
|
|
@@ -12,6 +13,7 @@ import { NxAppWebpackPluginOptions } from './nx-app-webpack-plugin-options';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class NxAppWebpackPlugin {
|
|
14
15
|
private readonly options;
|
|
16
|
+
readonly [READY_SIGNAL_PLUGIN] = true;
|
|
15
17
|
constructor(options?: NxAppWebpackPluginOptions);
|
|
16
18
|
apply(compiler: Compiler): void;
|
|
17
19
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.NxAppWebpackPlugin = void 0;
|
|
4
5
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
6
|
+
const dev_server_ready_signal_1 = require("../../utils/dev-server-ready-signal");
|
|
5
7
|
/**
|
|
6
8
|
* This plugin provides features to build Node and Web applications.
|
|
7
9
|
* - TS support (including tsconfig paths)
|
|
@@ -14,6 +16,7 @@ const normalize_options_1 = require("./lib/normalize-options");
|
|
|
14
16
|
*/
|
|
15
17
|
class NxAppWebpackPlugin {
|
|
16
18
|
constructor(options = {}) {
|
|
19
|
+
this[_a] = true;
|
|
17
20
|
// If we're building inferred targets, skip normalizing build options.
|
|
18
21
|
if (!global.NX_GRAPH_CREATION) {
|
|
19
22
|
this.options = (0, normalize_options_1.normalizeOptions)(options);
|
|
@@ -23,19 +26,32 @@ class NxAppWebpackPlugin {
|
|
|
23
26
|
// Lazy-required so a generator can load this without the webpack bundler.
|
|
24
27
|
const { applyBaseConfig } = require('./lib/apply-base-config');
|
|
25
28
|
const { applyWebConfig } = require('./lib/apply-web-config');
|
|
29
|
+
const { applyDevServerReadySignal } = require('../../utils/dev-server-ready-signal');
|
|
30
|
+
applyDevServerReadySignal(compiler);
|
|
26
31
|
// Defaults to 'web' if not specified to match Webpack's default.
|
|
27
32
|
const target = this.options.target ?? compiler.options.target ?? 'web';
|
|
28
33
|
this.options.outputPath ??= compiler.options.output?.path;
|
|
29
34
|
if (typeof target === 'string') {
|
|
30
35
|
this.options.target = target;
|
|
31
36
|
}
|
|
37
|
+
// Cypress supplies its own `main` entry and index.html, and license
|
|
38
|
+
// extraction fails with ENOENT for buildable libraries under component
|
|
39
|
+
// testing.
|
|
40
|
+
if (process.env.NX_CYPRESS_COMPONENT_TEST === 'true') {
|
|
41
|
+
this.options.main = undefined;
|
|
42
|
+
this.options.generateIndexHtml = false;
|
|
43
|
+
this.options.extractLicenses = false;
|
|
44
|
+
}
|
|
32
45
|
applyBaseConfig(this.options, compiler.options, {
|
|
33
46
|
useNormalizedEntry: true,
|
|
34
47
|
});
|
|
48
|
+
compiler.context = compiler.options.context;
|
|
35
49
|
if (compiler.options.target) {
|
|
36
50
|
this.options.target = compiler.options.target;
|
|
37
51
|
}
|
|
38
|
-
if (this.options.target === 'web' ||
|
|
52
|
+
if (this.options.target === 'web' ||
|
|
53
|
+
this.options.target === 'webworker' ||
|
|
54
|
+
this.options.ssr) {
|
|
39
55
|
applyWebConfig(this.options, compiler.options, {
|
|
40
56
|
useNormalizedEntry: true,
|
|
41
57
|
});
|
|
@@ -43,3 +59,4 @@ class NxAppWebpackPlugin {
|
|
|
43
59
|
}
|
|
44
60
|
}
|
|
45
61
|
exports.NxAppWebpackPlugin = NxAppWebpackPlugin;
|
|
62
|
+
_a = dev_server_ready_signal_1.READY_SIGNAL_PLUGIN;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
const dev_server_ready_signal_1 = require("../utils/dev-server-ready-signal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const js_1 = require("@nx/js");
|
|
7
8
|
const internal_2 = require("@nx/js/internal");
|
|
@@ -121,6 +122,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
|
|
|
121
122
|
},
|
|
122
123
|
},
|
|
123
124
|
};
|
|
125
|
+
const devServerReadyWhen = getDevServerReadyWhen(configFilePath, webpackOptions);
|
|
124
126
|
targets[options.serveTargetName] = {
|
|
125
127
|
continuous: true,
|
|
126
128
|
inputs: [...buildInputs],
|
|
@@ -129,6 +131,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
|
|
|
129
131
|
cwd: projectRoot,
|
|
130
132
|
env: { NODE_ENV: 'development' },
|
|
131
133
|
},
|
|
134
|
+
readyWhen: devServerReadyWhen,
|
|
132
135
|
metadata: {
|
|
133
136
|
technologies: ['webpack'],
|
|
134
137
|
description: 'Starts Webpack dev server',
|
|
@@ -150,6 +153,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
|
|
|
150
153
|
cwd: projectRoot,
|
|
151
154
|
env: { NODE_ENV: 'production' },
|
|
152
155
|
},
|
|
156
|
+
readyWhen: devServerReadyWhen,
|
|
153
157
|
metadata: {
|
|
154
158
|
technologies: ['webpack'],
|
|
155
159
|
description: 'Starts Webpack dev server in production mode',
|
|
@@ -172,6 +176,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
|
|
|
172
176
|
buildTarget: options.buildTargetName,
|
|
173
177
|
spa: true,
|
|
174
178
|
},
|
|
179
|
+
readyWhen: { signal: true },
|
|
175
180
|
};
|
|
176
181
|
// for `convert-to-inferred` we need to leave the port undefined or the options will not match
|
|
177
182
|
if (webpackConfig.devServer?.port && webpackConfig.devServer?.port !== 4200) {
|
|
@@ -255,3 +260,16 @@ function normalizeOptions(options) {
|
|
|
255
260
|
watchDepsTargetName: 'watch-deps',
|
|
256
261
|
};
|
|
257
262
|
}
|
|
263
|
+
// A dev server whose config loads NxAppWebpackPlugin or NxReadySignalPlugin reports
|
|
264
|
+
// when it listens. Otherwise the check reads the config when the task runs,
|
|
265
|
+
// with the task's env and options, and waits for the dev server's port.
|
|
266
|
+
function getDevServerReadyWhen(configFilePath, configs) {
|
|
267
|
+
// webpack-cli starts a dev server for each config with devServer. Only the
|
|
268
|
+
// first one to listen would signal, so several get the check that waits
|
|
269
|
+
// for each of them.
|
|
270
|
+
const withDevServer = configs.filter((config) => config.devServer);
|
|
271
|
+
const signals = withDevServer.length === 1 && (0, dev_server_ready_signal_1.sendsReadySignal)(withDevServer[0]);
|
|
272
|
+
return signals
|
|
273
|
+
? { signal: true }
|
|
274
|
+
: (0, internal_1.getReadyCheckReadyWhen)('@nx/webpack/ready-check', (0, path_1.basename)(configFilePath));
|
|
275
|
+
}
|
|
@@ -59,6 +59,9 @@ async function useLegacyNxPlugin(fn, executorOptions) {
|
|
|
59
59
|
apply(compiler) {
|
|
60
60
|
compiler.hooks.beforeCompile.tapPromise('NxLegacyAsyncPlugin', () => {
|
|
61
61
|
return new Promise((resolve) => {
|
|
62
|
+
// Legacy functions are typed to take `Configuration` but mutate the
|
|
63
|
+
// normalized options in place. From webpack 5.111 the two types
|
|
64
|
+
// conflict (`output.copy`), and the public signature can't widen.
|
|
62
65
|
fn(compiler.options, ctx).then((updated) => {
|
|
63
66
|
// Merge options back shallowly since it's a fully functional configuration.
|
|
64
67
|
// Most likely, the user modified the config in place, but this guarantees that updates are applied if users did something like:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import type { Configuration } from 'webpack';
|
|
3
|
-
import { NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
|
|
3
|
+
import type { NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
|
|
4
4
|
export declare const nxWebpackComposablePlugin = "nxWebpackComposablePlugin";
|
|
5
5
|
export declare function isNxWebpackComposablePlugin(a: unknown): a is AsyncNxComposableWebpackPlugin;
|
|
6
6
|
export interface NxWebpackExecutionContext {
|
|
@@ -15,20 +15,16 @@ export interface AsyncNxComposableWebpackPlugin {
|
|
|
15
15
|
(config: Configuration, ctx: NxWebpackExecutionContext): Configuration | Promise<Configuration>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated
|
|
19
|
-
*
|
|
20
|
-
* `nx g @nx/webpack:convert-to-inferred`. See
|
|
21
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
18
|
+
* @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
|
|
19
|
+
* This inert stub will be removed in Nx v25.
|
|
22
20
|
*/
|
|
23
|
-
export declare function composePlugins(...
|
|
21
|
+
export declare function composePlugins(..._plugins: (NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin | Promise<NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin>)[]): ((config?: Configuration, ctx?: NxWebpackExecutionContext) => Promise<Configuration>) & {
|
|
24
22
|
nxWebpackComposablePlugin: boolean;
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
27
|
-
* @deprecated
|
|
28
|
-
*
|
|
29
|
-
* `nx g @nx/webpack:convert-to-inferred`. See
|
|
30
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
25
|
+
* @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
|
|
26
|
+
* This inert stub will be removed in Nx v25.
|
|
31
27
|
*/
|
|
32
|
-
export declare function composePluginsSync(...
|
|
28
|
+
export declare function composePluginsSync(..._plugins: NxComposableWebpackPlugin[]): ((config?: Configuration, ctx?: NxWebpackExecutionContext) => Configuration) & {
|
|
33
29
|
nxWebpackComposablePlugin: boolean;
|
|
34
30
|
};
|
package/dist/src/utils/config.js
CHANGED
|
@@ -4,84 +4,31 @@ exports.nxWebpackComposablePlugin = void 0;
|
|
|
4
4
|
exports.isNxWebpackComposablePlugin = isNxWebpackComposablePlugin;
|
|
5
5
|
exports.composePlugins = composePlugins;
|
|
6
6
|
exports.composePluginsSync = composePluginsSync;
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const internal_1 = require("@nx/js/internal");
|
|
9
7
|
const deprecation_1 = require("./deprecation");
|
|
10
|
-
const internal_2 = require("@nx/devkit/internal");
|
|
11
8
|
exports.nxWebpackComposablePlugin = 'nxWebpackComposablePlugin';
|
|
12
9
|
function isNxWebpackComposablePlugin(a) {
|
|
13
10
|
return a?.[exports.nxWebpackComposablePlugin] === true;
|
|
14
11
|
}
|
|
12
|
+
// TODO(v25): remove the inert config-helper stubs in this file.
|
|
15
13
|
/**
|
|
16
|
-
* @deprecated
|
|
17
|
-
*
|
|
18
|
-
* `nx g @nx/webpack:convert-to-inferred`. See
|
|
19
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
14
|
+
* @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
|
|
15
|
+
* This inert stub will be removed in Nx v25.
|
|
20
16
|
*/
|
|
21
|
-
function composePlugins(...
|
|
17
|
+
function composePlugins(..._plugins) {
|
|
22
18
|
(0, deprecation_1.warnWebpackComposeHelpersDeprecation)();
|
|
23
|
-
return Object.assign(async
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (ctx['env']) {
|
|
28
|
-
ensureNxWebpackExecutionContext(ctx);
|
|
29
|
-
// Build this from scratch since what webpack passes us is the env, not config,
|
|
30
|
-
// and `withNX()` creates a new config object anyway.
|
|
31
|
-
config = {};
|
|
32
|
-
}
|
|
33
|
-
for (const plugin of plugins) {
|
|
34
|
-
const fn = await plugin;
|
|
35
|
-
config = await fn(config, ctx);
|
|
36
|
-
}
|
|
37
|
-
return config;
|
|
38
|
-
}, {
|
|
39
|
-
[exports.nxWebpackComposablePlugin]: true,
|
|
40
|
-
});
|
|
19
|
+
return Object.assign(async (config = {}, ctx) => {
|
|
20
|
+
// Only the legacy Nx executor passes a config; CLIs pass (env, argv).
|
|
21
|
+
return ctx?.context && typeof ctx.context === 'object' ? config : {};
|
|
22
|
+
}, { [exports.nxWebpackComposablePlugin]: true });
|
|
41
23
|
}
|
|
42
24
|
/**
|
|
43
|
-
* @deprecated
|
|
44
|
-
*
|
|
45
|
-
* `nx g @nx/webpack:convert-to-inferred`. See
|
|
46
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
25
|
+
* @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
|
|
26
|
+
* This inert stub will be removed in Nx v25.
|
|
47
27
|
*/
|
|
48
|
-
function composePluginsSync(...
|
|
28
|
+
function composePluginsSync(..._plugins) {
|
|
49
29
|
(0, deprecation_1.warnWebpackComposeHelpersDeprecation)();
|
|
50
|
-
return Object.assign(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return config;
|
|
55
|
-
}, {
|
|
56
|
-
[exports.nxWebpackComposablePlugin]: true,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function ensureNxWebpackExecutionContext(ctx) {
|
|
60
|
-
const projectName = process.env.NX_TASK_TARGET_PROJECT;
|
|
61
|
-
const targetName = process.env.NX_TASK_TARGET_TARGET;
|
|
62
|
-
const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
|
|
63
|
-
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
64
|
-
const projectNode = projectGraph.nodes[projectName];
|
|
65
|
-
ctx.options ??= {
|
|
66
|
-
root: devkit_1.workspaceRoot,
|
|
67
|
-
projectRoot: projectNode.data.root,
|
|
68
|
-
sourceRoot: (0, internal_1.getProjectSourceRoot)(projectNode.data),
|
|
69
|
-
// These aren't actually needed since NxWebpackPlugin and withNx both support them being undefined.
|
|
70
|
-
assets: undefined,
|
|
71
|
-
outputPath: undefined,
|
|
72
|
-
tsConfig: undefined,
|
|
73
|
-
outputFileName: undefined,
|
|
74
|
-
useTsconfigPaths: undefined,
|
|
75
|
-
};
|
|
76
|
-
ctx.context ??= {
|
|
77
|
-
projectName,
|
|
78
|
-
targetName,
|
|
79
|
-
configurationName,
|
|
80
|
-
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
|
81
|
-
nxJsonConfiguration: (0, internal_2.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
82
|
-
cwd: process.cwd(),
|
|
83
|
-
root: devkit_1.workspaceRoot,
|
|
84
|
-
isVerbose: process.env['NX_VERBOSE_LOGGING'] === 'true',
|
|
85
|
-
projectGraph,
|
|
86
|
-
};
|
|
30
|
+
return Object.assign((config = {}, ctx) => {
|
|
31
|
+
// Only the legacy Nx executor passes a config; CLIs pass (env, argv).
|
|
32
|
+
return ctx?.context && typeof ctx.context === 'object' ? config : {};
|
|
33
|
+
}, { [exports.nxWebpackComposablePlugin]: true });
|
|
87
34
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const WEBPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/webpack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/webpack:convert-to-inferred` to migrate to the `@nx/webpack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
3
|
-
export declare function warnWebpackExecutorDeprecation(): void;
|
|
4
|
-
export declare function warnWebpackDevServerExecutorDeprecation(): void;
|
|
5
|
-
export declare function warnWebpackExecutorGenerating(): void;
|
|
6
|
-
export declare const WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The `composePlugins`, `withNx`, and `withWeb` config helpers from `@nx/webpack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/webpack:webpack` executor. Migrate to a standard webpack config that uses `NxAppWebpackPlugin` (from `@nx/webpack/app-plugin`) under the inferred `@nx/webpack/plugin` by running `nx g @nx/webpack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
1
|
+
export declare const WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The compose config helpers from `@nx/webpack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard webpack config using `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.";
|
|
7
2
|
export declare function suppressWebpackComposeHelperWarnings<T>(fn: () => T): T;
|
|
8
3
|
export declare function warnWebpackComposeHelpersDeprecation(): void;
|
|
4
|
+
export declare const WEBPACK_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/webpack:ssr-dev-server` executor is deprecated and will be removed in Nx v25. Run the server from source with the `@nx/js/tsx` plugin, with the browser build in watch mode as a continuous dependency. See https://nx.dev/docs/kb/replace-ssr-dev-server.";
|
|
5
|
+
export declare function warnWebpackSsrDevServerExecutorDeprecation(): void;
|
|
@@ -1,35 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.warnWebpackExecutorDeprecation = warnWebpackExecutorDeprecation;
|
|
5
|
-
exports.warnWebpackDevServerExecutorDeprecation = warnWebpackDevServerExecutorDeprecation;
|
|
6
|
-
exports.warnWebpackExecutorGenerating = warnWebpackExecutorGenerating;
|
|
3
|
+
exports.WEBPACK_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = void 0;
|
|
7
4
|
exports.suppressWebpackComposeHelperWarnings = suppressWebpackComposeHelperWarnings;
|
|
8
5
|
exports.warnWebpackComposeHelpersDeprecation = warnWebpackComposeHelpersDeprecation;
|
|
6
|
+
exports.warnWebpackSsrDevServerExecutorDeprecation = warnWebpackSsrDevServerExecutorDeprecation;
|
|
9
7
|
const devkit_1 = require("@nx/devkit");
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
exports.WEBPACK_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/webpack:webpack` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/webpack:convert-to-inferred` to migrate to the `@nx/webpack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
14
|
-
exports.WEBPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/webpack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/webpack:convert-to-inferred` to migrate to the `@nx/webpack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
15
|
-
function warnWebpackExecutorDeprecation() {
|
|
16
|
-
devkit_1.logger.warn(exports.WEBPACK_EXECUTOR_DEPRECATION_MESSAGE);
|
|
17
|
-
}
|
|
18
|
-
function warnWebpackDevServerExecutorDeprecation() {
|
|
19
|
-
devkit_1.logger.warn(exports.WEBPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
20
|
-
}
|
|
21
|
-
// Fired when the @nx/webpack:configuration generator is about to generate
|
|
22
|
-
// targets that use the deprecated executors — i.e. when @nx/webpack/plugin
|
|
23
|
-
// isn't registered in nx.json. Surfaces the deprecation at generation time
|
|
24
|
-
// rather than only when the user later runs the generated targets.
|
|
25
|
-
function warnWebpackExecutorGenerating() {
|
|
26
|
-
devkit_1.logger.warn('Generating targets that use the deprecated `@nx/webpack:webpack` and `@nx/webpack:dev-server` executors. These executors will be removed in Nx v24. Run `nx g @nx/webpack:convert-to-inferred` next to migrate these targets to the `@nx/webpack/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
27
|
-
}
|
|
28
|
-
// TODO(v24): Remove the composePlugins/withNx/withWeb config helpers. They emit
|
|
29
|
-
// an Nx-specific config function that only runs under the @nx/webpack:webpack
|
|
30
|
-
// executor; the inferred @nx/webpack/plugin works with standard webpack configs
|
|
31
|
-
// built around NxAppWebpackPlugin instead.
|
|
32
|
-
exports.WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The `composePlugins`, `withNx`, and `withWeb` config helpers from `@nx/webpack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/webpack:webpack` executor. Migrate to a standard webpack config that uses `NxAppWebpackPlugin` (from `@nx/webpack/app-plugin`) under the inferred `@nx/webpack/plugin` by running `nx g @nx/webpack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
8
|
+
// Helper behavior was removed in v24; exports remain only as inert stubs.
|
|
9
|
+
// Keep their exports loadable so old configs do not block graph creation.
|
|
10
|
+
exports.WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The compose config helpers from `@nx/webpack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard webpack config using `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.';
|
|
33
11
|
let composeHelpersWarned = false;
|
|
34
12
|
let suppressDepth = 0;
|
|
35
13
|
// Nx-internal entry points compose these helpers themselves (e.g. the rspack
|
|
@@ -53,3 +31,8 @@ function warnWebpackComposeHelpersDeprecation() {
|
|
|
53
31
|
composeHelpersWarned = true;
|
|
54
32
|
devkit_1.logger.warn(exports.WEBPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE);
|
|
55
33
|
}
|
|
34
|
+
// TODO(v25): remove with the deprecated ssr-dev-server executor
|
|
35
|
+
exports.WEBPACK_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/webpack:ssr-dev-server` executor is deprecated and will be removed in Nx v25. Run the server from source with the `@nx/js/tsx` plugin, with the browser build in watch mode as a continuous dependency. See https://nx.dev/docs/kb/replace-ssr-dev-server.';
|
|
36
|
+
function warnWebpackSsrDevServerExecutorDeprecation() {
|
|
37
|
+
devkit_1.logger.warn(exports.WEBPACK_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ServerAddress } from '@nx/devkit/internal';
|
|
2
|
+
export interface ServeFlags {
|
|
3
|
+
port?: number | string;
|
|
4
|
+
host?: string;
|
|
5
|
+
configNames: string[];
|
|
6
|
+
configs: string[];
|
|
7
|
+
merge: boolean;
|
|
8
|
+
env: Record<string, unknown>;
|
|
9
|
+
extends: string[];
|
|
10
|
+
}
|
|
11
|
+
/** The flags of `webpack-cli serve` the check reads, from its parsed argv. */
|
|
12
|
+
export declare function parseServeFlags(argv: Record<string, any>): ServeFlags;
|
|
13
|
+
/**
|
|
14
|
+
* The options `webpack-cli serve` parses from the task's options, as
|
|
15
|
+
* run-commands forwards them. webpack-cli passes them to a function config as
|
|
16
|
+
* `argv`, with `env` parsed from the `--env` values. Parses the args with
|
|
17
|
+
* webpack-cli's commander and types each value by its argument in webpack-cli,
|
|
18
|
+
* webpack or webpack-dev-server.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseServeArgv(options: Record<string, unknown>): Record<string, any>;
|
|
21
|
+
/**
|
|
22
|
+
* Where a dev server listens, or null when it picks its port or listens on a
|
|
23
|
+
* socket. Returns null for those, since nothing can be probed ahead of them.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getDevServerAddress(devServer: {
|
|
26
|
+
port?: unknown;
|
|
27
|
+
host?: unknown;
|
|
28
|
+
ipc?: unknown;
|
|
29
|
+
} | undefined, flags: ServeFlags, basePort: string | undefined): ServerAddress | null;
|
|
30
|
+
/**
|
|
31
|
+
* The readyWhen of the inferred serve targets when the config doesn't load the
|
|
32
|
+
* signal plugin. Runs in the env and with the options of the serve task, reads
|
|
33
|
+
* the config the way `webpack-cli serve` does, and waits for each dev server it
|
|
34
|
+
* starts.
|
|
35
|
+
*/
|
|
36
|
+
export declare function waitForWebpackDevServer(configPath: string): Promise<void>;
|