@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.
Files changed (65) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/internal.d.ts +3 -0
  4. package/dist/internal.js +7 -1
  5. package/dist/ready-check.d.ts +1 -0
  6. package/dist/ready-check.js +9 -0
  7. package/dist/ready-signal.d.ts +1 -0
  8. package/dist/ready-signal.js +5 -0
  9. package/dist/src/executors/dev-server/dev-server.impl.js +38 -30
  10. package/dist/src/executors/ssr-dev-server/schema.json +2 -1
  11. package/dist/src/executors/ssr-dev-server/ssr-dev-server.impl.js +2 -0
  12. package/dist/src/generators/configuration/configuration.js +14 -132
  13. package/dist/src/generators/configuration/schema.d.ts +0 -1
  14. package/dist/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.js +97 -57
  15. package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts +2 -0
  16. package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.js +46 -2
  17. package/dist/src/generators/convert-config-to-webpack-plugin/schema.json +2 -2
  18. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +5 -4
  19. package/dist/src/generators/convert-to-inferred/utils/ast.d.ts +2 -0
  20. package/dist/src/generators/convert-to-inferred/utils/ast.js +13 -0
  21. package/dist/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +25 -5
  22. package/dist/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +13 -14
  23. package/dist/src/generators/init/init.js +45 -54
  24. package/dist/src/generators/init/schema.d.ts +0 -1
  25. package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +11 -0
  26. package/dist/src/migrations/update-24-0-0/inventory.d.ts +10 -0
  27. package/dist/src/migrations/update-24-0-0/inventory.js +55 -0
  28. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.d.ts +10 -0
  29. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.js +68 -0
  30. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.md +98 -0
  31. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
  32. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +39 -0
  33. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +92 -0
  34. package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +6 -0
  35. package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.js +29 -24
  36. package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts +2 -0
  37. package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +18 -1
  38. package/dist/src/plugins/plugin.js +18 -0
  39. package/dist/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +3 -0
  40. package/dist/src/utils/config.d.ts +8 -12
  41. package/dist/src/utils/config.js +15 -68
  42. package/dist/src/utils/deprecation.d.ts +3 -6
  43. package/dist/src/utils/deprecation.js +10 -27
  44. package/dist/src/utils/dev-server-ready-check.d.ts +36 -0
  45. package/dist/src/utils/dev-server-ready-check.js +255 -0
  46. package/dist/src/utils/dev-server-ready-signal.d.ts +29 -0
  47. package/dist/src/utils/dev-server-ready-signal.js +51 -0
  48. package/dist/src/utils/e2e-web-server-info-utils.d.ts +1 -1
  49. package/dist/src/utils/e2e-web-server-info-utils.js +2 -2
  50. package/dist/src/utils/webpack/read-webpack-options.d.ts +1 -1
  51. package/dist/src/utils/webpack/read-webpack-options.js +4 -4
  52. package/dist/src/utils/with-nx.d.ts +5 -9
  53. package/dist/src/utils/with-nx.js +5 -32
  54. package/dist/src/utils/with-web.d.ts +5 -9
  55. package/dist/src/utils/with-web.js +5 -24
  56. package/executors.json +0 -10
  57. package/migrations.json +13 -0
  58. package/package.json +20 -4
  59. package/dist/src/executors/webpack/lib/run-webpack.d.ts +0 -3
  60. package/dist/src/executors/webpack/lib/run-webpack.js +0 -36
  61. package/dist/src/executors/webpack/schema.json +0 -459
  62. package/dist/src/executors/webpack/webpack.impl.d.ts +0 -13
  63. package/dist/src/executors/webpack/webpack.impl.js +0 -117
  64. package/dist/src/utils/has-plugin.d.ts +0 -2
  65. package/dist/src/utils/has-plugin.js +0 -10
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseServeFlags = parseServeFlags;
4
+ exports.parseServeArgv = parseServeArgv;
5
+ exports.getDevServerAddress = getDevServerAddress;
6
+ exports.waitForWebpackDevServer = waitForWebpackDevServer;
7
+ const internal_1 = require("@nx/devkit/internal");
8
+ const module_1 = require("module");
9
+ const path_1 = require("path");
10
+ /** The flags of `webpack-cli serve` the check reads, from its parsed argv. */
11
+ function parseServeFlags(argv) {
12
+ const env = {};
13
+ for (const value of argv.env ?? [])
14
+ parseEnv(value, env);
15
+ return {
16
+ port: argv.port,
17
+ host: argv.host,
18
+ configNames: argv.configName ?? [],
19
+ configs: argv.config ?? [],
20
+ merge: !!argv.merge,
21
+ env,
22
+ extends: argv.extends ?? [],
23
+ };
24
+ }
25
+ const stringConfig = [{ type: 'string' }];
26
+ const flagConfig = [{ type: 'enum', values: [true] }];
27
+ // webpack-cli's own options in any of its majors
28
+ const CLI_OPTIONS = {
29
+ config: { alias: 'c', configs: stringConfig, multiple: true },
30
+ 'config-name': { configs: stringConfig, multiple: true },
31
+ merge: { alias: 'm', configs: flagConfig },
32
+ 'disable-interpret': { configs: flagConfig },
33
+ env: { configs: stringConfig, multiple: true },
34
+ 'node-env': { configs: stringConfig },
35
+ 'define-process-env-node-env': { configs: stringConfig },
36
+ 'config-node-env': { configs: stringConfig },
37
+ analyze: { configs: flagConfig },
38
+ progress: { configs: [...stringConfig, ...flagConfig] },
39
+ json: { alias: 'j', configs: [...stringConfig, ...flagConfig] },
40
+ 'fail-on-warnings': { configs: flagConfig },
41
+ extends: { alias: 'e', configs: stringConfig, multiple: true },
42
+ };
43
+ const CORE_ALIASES = {
44
+ devtool: 'd',
45
+ 'output-path': 'o',
46
+ target: 't',
47
+ watch: 'w',
48
+ };
49
+ const VALUE_TYPES = {
50
+ boolean: 'boolean',
51
+ reset: 'boolean',
52
+ number: 'number',
53
+ string: 'string',
54
+ path: 'string',
55
+ RegExp: 'string',
56
+ };
57
+ /**
58
+ * The options `webpack-cli serve` parses from the task's options, as
59
+ * run-commands forwards them. webpack-cli passes them to a function config as
60
+ * `argv`, with `env` parsed from the `--env` values. Parses the args with
61
+ * webpack-cli's commander and types each value by its argument in webpack-cli,
62
+ * webpack or webpack-dev-server.
63
+ */
64
+ function parseServeArgv(options) {
65
+ const tokens = (0, internal_1.getForwardedArgs)(options);
66
+ // Registers only the options the args can name, since only those set a value
67
+ const named = new Set(tokens.flatMap((token) => {
68
+ if (!token.startsWith('-'))
69
+ return [];
70
+ if (!token.startsWith('--'))
71
+ return [...token.slice(1)];
72
+ const name = token.slice(2).split('=')[0];
73
+ return [name, name.replace(/^no-/, '')];
74
+ }));
75
+ if (named.size === 0)
76
+ return {};
77
+ const cliRequire = createWebpackCliRequire();
78
+ const { Command, Option } = cliRequire('commander');
79
+ const webpack = cliRequire('webpack');
80
+ const args = {
81
+ ...webpack.cli.getArguments(),
82
+ ...webpack.cli.getArguments(cliRequire('webpack-dev-server').schema),
83
+ ...CLI_OPTIONS,
84
+ };
85
+ const command = new Command().exitOverride();
86
+ for (const [name, arg] of Object.entries(args)) {
87
+ const alias = arg.alias ?? CORE_ALIASES[name];
88
+ if (named.has(name) || named.has(alias)) {
89
+ addCliOption(command, Option, name, { ...arg, alias });
90
+ }
91
+ }
92
+ // webpack-cli's program parses the args at least twice before `serve` does,
93
+ // and each pass drops a `--` that comes before any option it doesn't know
94
+ const program = new Command().option('--color').option('--no-color');
95
+ let serveArgs = ['serve', ...tokens];
96
+ for (let pass = 0; pass < 2; pass++) {
97
+ const { operands, unknown } = program.parseOptions(serveArgs);
98
+ serveArgs = [...operands, ...unknown];
99
+ }
100
+ command.parseOptions(serveArgs.slice(1));
101
+ return command.opts();
102
+ }
103
+ // Ports webpack-cli's makeOption
104
+ function addCliOption(command, Option, name, { configs = [], multiple, alias }) {
105
+ const types = new Set();
106
+ let negatable = false;
107
+ for (const { type, values = [] } of configs) {
108
+ if (type === 'enum') {
109
+ for (const value of values) {
110
+ const valueType = VALUE_TYPES[typeof value];
111
+ if (value === false)
112
+ negatable = true;
113
+ else if (valueType)
114
+ types.add(valueType);
115
+ }
116
+ }
117
+ else if (VALUE_TYPES[type]) {
118
+ types.add(VALUE_TYPES[type]);
119
+ negatable ||= type === 'boolean';
120
+ }
121
+ }
122
+ if (types.size === 0 && !negatable)
123
+ return;
124
+ const takesValue = types.size > (types.has('boolean') ? 1 : 0);
125
+ const variadic = multiple ? '...' : '';
126
+ const placeholder = types.has('boolean')
127
+ ? ` [value${variadic}]`
128
+ : ` <value${variadic}>`;
129
+ const option = new Option(`${alias ? `-${alias}, ` : ''}--${name}${takesValue ? placeholder : ''}`);
130
+ if (takesValue) {
131
+ option.argParser((value, prev = []) => {
132
+ const number = Number(value);
133
+ if (types.has('number') && (types.size === 1 || !isNaN(number))) {
134
+ return multiple ? [prev, number].flat() : number;
135
+ }
136
+ return multiple && types.has('string') ? [prev, value].flat() : value;
137
+ });
138
+ }
139
+ command.addOption(option);
140
+ if (negatable)
141
+ command.addOption(new Option(`--no-${name}`));
142
+ }
143
+ // webpack-cli's `--env` parser, edge cases included
144
+ function parseEnv(value, env) {
145
+ const [allKeys, val] = value.split(/[=](.+)/, 2);
146
+ const splitKeys = allKeys.split(/\.(?!$)/);
147
+ let prevRef = env;
148
+ for (let [index, someKey] of splitKeys.entries()) {
149
+ if (someKey.endsWith('=')) {
150
+ someKey = someKey.slice(0, -1);
151
+ prevRef[someKey] = undefined;
152
+ continue;
153
+ }
154
+ if (!prevRef[someKey] || typeof prevRef[someKey] === 'string') {
155
+ prevRef[someKey] = {};
156
+ }
157
+ if (index === splitKeys.length - 1) {
158
+ prevRef[someKey] = typeof val === 'string' ? val : true;
159
+ }
160
+ prevRef = prevRef[someKey];
161
+ }
162
+ }
163
+ /**
164
+ * Where a dev server listens, or null when it picks its port or listens on a
165
+ * socket. Returns null for those, since nothing can be probed ahead of them.
166
+ */
167
+ function getDevServerAddress(devServer, flags, basePort) {
168
+ if (devServer?.ipc)
169
+ return null;
170
+ const host = flags.host ?? devServer?.host;
171
+ return (0, internal_1.getServerAddress)(flags.port ?? devServer?.port ?? basePort ?? 8080,
172
+ // `local-ip` and friends resolve to an interface address first, the way
173
+ // the dev server resolves them
174
+ typeof host === 'string' ? (0, internal_1.resolveStartupHost)(host) : undefined);
175
+ }
176
+ async function loadConfigExport(path) {
177
+ if (/\.(ts|mts|cts)$/.test(path)) {
178
+ const { getRootTsConfigPath } = require('@nx/js');
179
+ const { resolveUserDefinedWebpackConfig } = require('./webpack/resolve-user-defined-webpack-config');
180
+ return resolveUserDefinedWebpackConfig(path, getRootTsConfigPath());
181
+ }
182
+ const config = await (0, internal_1.loadConfigFile)(path);
183
+ // webpack-cli also unwraps a default export's own `default`
184
+ return config && typeof config === 'object' && 'default' in config
185
+ ? config.default
186
+ : config;
187
+ }
188
+ // webpack-cli runs from the task's cwd and loads its dependencies from its own
189
+ // location
190
+ function createWebpackCliRequire() {
191
+ return (0, module_1.createRequire)(require.resolve('webpack-cli', { paths: [process.cwd()] }));
192
+ }
193
+ function loadWebpackMerge() {
194
+ return createWebpackCliRequire()('webpack-merge').merge;
195
+ }
196
+ /**
197
+ * The readyWhen of the inferred serve targets when the config doesn't load the
198
+ * signal plugin. Runs in the env and with the options of the serve task, reads
199
+ * the config the way `webpack-cli serve` does, and waits for each dev server it
200
+ * starts.
201
+ */
202
+ async function waitForWebpackDevServer(configPath) {
203
+ await (0, internal_1.runReadyCheck)(async ({ options, root }) => {
204
+ const parsed = parseServeArgv(options);
205
+ const flags = parseServeFlags(parsed);
206
+ // Skips NxAppWebpackPlugin's option normalization, which nothing here uses
207
+ global.NX_GRAPH_CREATION = true;
208
+ const { readWebpackOptions } = require('./webpack/read-webpack-options');
209
+ const env = { WEBPACK_SERVE: true, ...flags.env };
210
+ const argv = { ...parsed, env };
211
+ const load = async (path) => readWebpackOptions(await loadConfigExport((0, path_1.resolve)(path)), env, argv);
212
+ let configs = (await Promise.all(
213
+ // The config's file name, in the cwd of the serve task
214
+ (flags.configs.length > 0
215
+ ? flags.configs
216
+ : [(0, path_1.resolve)(root, configPath)]).map(load)))
217
+ .flat()
218
+ .filter((config) => flags.configNames.length === 0 ||
219
+ flags.configNames.includes(config.name));
220
+ let webpackMerge;
221
+ const merge = (...configs) => (webpackMerge ??= loadWebpackMerge())(...configs);
222
+ const resolveExtends = async (config, extendsPaths, seen) => {
223
+ delete config.extends;
224
+ const paths = extendsPaths.map((path) => (0, path_1.resolve)(path));
225
+ if (paths.some((path) => seen.includes(path))) {
226
+ throw new Error('Recursive configuration detected.');
227
+ }
228
+ const extended = (await Promise.all(paths.map(load))).flat();
229
+ if (extended.length > 0)
230
+ config = merge(...extended, config);
231
+ return config.extends
232
+ ? resolveExtends(config, [config.extends].flat(), [...seen, ...paths])
233
+ : config;
234
+ };
235
+ configs = await Promise.all(configs.map((config) => flags.extends.length > 0
236
+ ? resolveExtends(config, flags.extends, [])
237
+ : config.extends
238
+ ? resolveExtends(config, [config.extends].flat(), [])
239
+ : config));
240
+ if (flags.merge) {
241
+ if (configs.length < 2) {
242
+ throw new Error('At least two configurations are required for merge.');
243
+ }
244
+ configs = [configs.reduce((merged, config) => merge(merged, config), {})];
245
+ }
246
+ // webpack-cli starts a dev server for every config with devServer, or for
247
+ // the first config when none has one
248
+ const withDevServer = configs.filter((config) => config.devServer);
249
+ const servers = withDevServer.length > 0 ? withDevServer : configs.slice(0, 1);
250
+ const addresses = servers
251
+ .filter((config) => config.devServer !== false)
252
+ .map((config) => getDevServerAddress(config.devServer, flags, process.env.WEBPACK_DEV_SERVER_BASE_PORT));
253
+ return addresses.some((address) => address === null) ? null : addresses;
254
+ });
255
+ }
@@ -0,0 +1,29 @@
1
+ import type { AddressInfo } from 'net';
2
+ import type { Compiler } from 'webpack';
3
+ export declare const READY_SIGNAL_PLUGIN: unique symbol;
4
+ /** Whether the dev server of this config will report its readiness. */
5
+ export declare function sendsReadySignal(config: {
6
+ devServer?: unknown;
7
+ plugins?: unknown[];
8
+ }): boolean;
9
+ /**
10
+ * Reports the dev server's address to an Nx task whose readyWhen is `signal`.
11
+ * `webpack-cli serve` reads `devServer` from the compiler after plugins apply,
12
+ * so wrapping `onListening` here reaches the server it starts.
13
+ */
14
+ export declare function applyDevServerReadySignal(compiler: Compiler): void;
15
+ /** Reports the dev server's address to an Nx task whose readyWhen is `signal`. */
16
+ export declare class NxReadySignalPlugin {
17
+ readonly [READY_SIGNAL_PLUGIN] = true;
18
+ apply(compiler: Compiler): void;
19
+ }
20
+ export declare function getDevServerUrl(server: {
21
+ server?: {
22
+ address(): AddressInfo | string | null;
23
+ };
24
+ options?: {
25
+ server?: string | {
26
+ type?: string;
27
+ };
28
+ };
29
+ }): string | undefined;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.NxReadySignalPlugin = exports.READY_SIGNAL_PLUGIN = void 0;
5
+ exports.sendsReadySignal = sendsReadySignal;
6
+ exports.applyDevServerReadySignal = applyDevServerReadySignal;
7
+ exports.getDevServerUrl = getDevServerUrl;
8
+ // Set on the plugins that report readiness, so inference can find them in a
9
+ // config it has loaded
10
+ exports.READY_SIGNAL_PLUGIN = Symbol.for('@nx/ready-signal-plugin');
11
+ /** Whether the dev server of this config will report its readiness. */
12
+ function sendsReadySignal(config) {
13
+ return (typeof config.devServer === 'object' &&
14
+ !!config.devServer &&
15
+ !!config.plugins?.some((plugin) => plugin?.[exports.READY_SIGNAL_PLUGIN]));
16
+ }
17
+ /**
18
+ * Reports the dev server's address to an Nx task whose readyWhen is `signal`.
19
+ * `webpack-cli serve` reads `devServer` from the compiler after plugins apply,
20
+ * so wrapping `onListening` here reaches the server it starts.
21
+ */
22
+ function applyDevServerReadySignal(compiler) {
23
+ const devServer = compiler.options.devServer;
24
+ if (!devServer || !process.env.NX_READY_SIGNAL_SOCKET) {
25
+ return;
26
+ }
27
+ const { emitReadySignal } = require('@nx/devkit');
28
+ const onListening = devServer.onListening;
29
+ devServer.onListening = (server) => {
30
+ onListening?.(server);
31
+ emitReadySignal(getDevServerUrl(server));
32
+ };
33
+ }
34
+ /** Reports the dev server's address to an Nx task whose readyWhen is `signal`. */
35
+ class NxReadySignalPlugin {
36
+ constructor() {
37
+ this[_a] = true;
38
+ }
39
+ apply(compiler) {
40
+ applyDevServerReadySignal(compiler);
41
+ }
42
+ }
43
+ exports.NxReadySignalPlugin = NxReadySignalPlugin;
44
+ _a = exports.READY_SIGNAL_PLUGIN;
45
+ function getDevServerUrl(server) {
46
+ const { getListeningUrl } = require('@nx/devkit/internal');
47
+ const type = typeof server.options?.server === 'string'
48
+ ? server.options.server
49
+ : server.options?.server?.type;
50
+ return getListeningUrl(server.server?.address(), !!type && type !== 'http');
51
+ }
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function getWebpackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
2
+ export declare function getWebpackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWebpackE2EWebServerInfo = getWebpackE2EWebServerInfo;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
- async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
6
+ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, e2ePortOverride) {
7
7
  const nxJson = (0, devkit_1.readNxJson)(tree);
8
8
  let e2ePort = e2ePortOverride ?? 4200;
9
9
  const servePort = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)
@@ -26,5 +26,5 @@ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isP
26
26
  defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
27
27
  defaultE2EPort: e2ePort,
28
28
  e2EPortIsExplicit: e2ePortOverride != null,
29
- }, isPluginBeingAdded);
29
+ });
30
30
  }
@@ -8,4 +8,4 @@ import type { Configuration } from 'webpack';
8
8
  *
9
9
  * @param webpackConfig
10
10
  */
11
- export declare function readWebpackOptions(webpackConfig: unknown): Promise<Configuration[]>;
11
+ export declare function readWebpackOptions(webpackConfig: unknown, env?: Record<string, unknown>, argv?: Record<string, unknown>): Promise<Configuration[]>;
@@ -13,7 +13,9 @@ const internal_1 = require("@nx/devkit/internal");
13
13
  *
14
14
  * @param webpackConfig
15
15
  */
16
- async function readWebpackOptions(webpackConfig) {
16
+ async function readWebpackOptions(webpackConfig,
17
+ // A function config gets the production build's env unless told otherwise
18
+ env = { production: true }, argv = {}) {
17
19
  const configs = [];
18
20
  const resolveConfig = async (config) => {
19
21
  if ((0, config_1.isNxWebpackComposablePlugin)(config)) {
@@ -39,9 +41,7 @@ async function readWebpackOptions(webpackConfig) {
39
41
  });
40
42
  }
41
43
  else if (typeof config === 'function') {
42
- const resolved = await config({
43
- production: true, // we want the production build options
44
- }, {});
44
+ const resolved = await config(env, argv);
45
45
  // If the resolved configuration is an array, resolve each configuration
46
46
  return Array.isArray(resolved)
47
47
  ? (await Promise.all(resolved.map(resolveConfig))).flat()
@@ -1,12 +1,8 @@
1
- import { NxComposableWebpackPlugin } from './config';
2
- import { NxAppWebpackPluginOptions } from '../plugins/nx-webpack-plugin/nx-app-webpack-plugin-options';
1
+ import type { NxComposableWebpackPlugin } from './config';
2
+ import type { NxAppWebpackPluginOptions } from '../plugins/nx-webpack-plugin/nx-app-webpack-plugin-options';
3
3
  export type WithNxOptions = Partial<NxAppWebpackPluginOptions>;
4
4
  /**
5
- * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
6
- * `@nx/webpack/app-plugin` in a standard webpack config and run
7
- * `nx g @nx/webpack:convert-to-inferred`. See
8
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
9
- * @param {WithNxOptions} pluginOptions
10
- * @returns {NxWebpackPlugin}
5
+ * @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
6
+ * This inert stub will be removed in Nx v25.
11
7
  */
12
- export declare function withNx(pluginOptions?: WithNxOptions): NxComposableWebpackPlugin;
8
+ export declare function withNx(_options?: WithNxOptions): NxComposableWebpackPlugin;
@@ -1,40 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNx = withNx;
4
- const normalize_options_1 = require("../plugins/nx-webpack-plugin/lib/normalize-options");
5
4
  const deprecation_1 = require("./deprecation");
6
- const processed = new Set();
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
7
6
  /**
8
- * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
9
- * `@nx/webpack/app-plugin` in a standard webpack config and run
10
- * `nx g @nx/webpack:convert-to-inferred`. See
11
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
12
- * @param {WithNxOptions} pluginOptions
13
- * @returns {NxWebpackPlugin}
7
+ * @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
8
+ * This inert stub will be removed in Nx v25.
14
9
  */
15
- function withNx(pluginOptions = {}) {
10
+ function withNx(_options = {}) {
16
11
  (0, deprecation_1.warnWebpackComposeHelpersDeprecation)();
17
- return function configure(config, { options, context }) {
18
- if (processed.has(config))
19
- return config;
20
- // Lazy-required so importing this module does not load the webpack bundler.
21
- const { applyBaseConfig } = require('../plugins/nx-webpack-plugin/lib/apply-base-config');
22
- applyBaseConfig({
23
- ...options,
24
- ...pluginOptions,
25
- target: options.target ?? 'web',
26
- assets: options.assets
27
- ? options.assets
28
- : pluginOptions.assets
29
- ? (0, normalize_options_1.normalizeAssets)(pluginOptions.assets, options.root, options.sourceRoot, options.projectRoot)
30
- : [],
31
- root: context.root,
32
- projectName: context.projectName,
33
- targetName: context.targetName,
34
- configurationName: context.configurationName,
35
- projectGraph: context.projectGraph,
36
- }, config);
37
- processed.add(config);
38
- return config;
39
- };
12
+ return (config) => config;
40
13
  }
@@ -1,5 +1,5 @@
1
- import { NxComposableWebpackPlugin } from './config';
2
- import { ExtraEntryPointClass, NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
1
+ import type { NxComposableWebpackPlugin } from './config';
2
+ import type { ExtraEntryPointClass, NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
3
3
  export interface WithWebOptions {
4
4
  baseHref?: string;
5
5
  crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
@@ -20,11 +20,7 @@ export interface WithWebOptions {
20
20
  }
21
21
  export type MergedOptions = Omit<NormalizedWebpackExecutorOptions, keyof WithWebOptions> & WithWebOptions;
22
22
  /**
23
- * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
24
- * `@nx/webpack/app-plugin` in a standard webpack config and run
25
- * `nx g @nx/webpack:convert-to-inferred`. See
26
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
27
- * @param {WithWebOptions} pluginOptions
28
- * @returns {NxWebpackPlugin}
23
+ * @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
24
+ * This inert stub will be removed in Nx v25.
29
25
  */
30
- export declare function withWeb(pluginOptions?: WithWebOptions): NxComposableWebpackPlugin;
26
+ export declare function withWeb(_options?: WithWebOptions): NxComposableWebpackPlugin;
@@ -2,31 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withWeb = withWeb;
4
4
  const deprecation_1 = require("./deprecation");
5
- const processed = new Set();
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
6
6
  /**
7
- * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
8
- * `@nx/webpack/app-plugin` in a standard webpack config and run
9
- * `nx g @nx/webpack:convert-to-inferred`. See
10
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
11
- * @param {WithWebOptions} pluginOptions
12
- * @returns {NxWebpackPlugin}
7
+ * @deprecated Use `NxAppWebpackPlugin` from `@nx/webpack/app-plugin`.
8
+ * This inert stub will be removed in Nx v25.
13
9
  */
14
- function withWeb(pluginOptions = {}) {
10
+ function withWeb(_options = {}) {
15
11
  (0, deprecation_1.warnWebpackComposeHelpersDeprecation)();
16
- return function configure(config, { options, context }) {
17
- if (processed.has(config))
18
- return config;
19
- // Lazy-required so importing this module does not load the webpack bundler.
20
- const { applyWebConfig } = require('../plugins/nx-webpack-plugin/lib/apply-web-config');
21
- applyWebConfig({
22
- ...options,
23
- ...pluginOptions,
24
- projectName: context.projectName,
25
- targetName: context.targetName,
26
- configurationName: context.configurationName,
27
- projectGraph: context.projectGraph,
28
- }, config);
29
- processed.add(config);
30
- return config;
31
- };
12
+ return (config) => config;
32
13
  }
package/executors.json CHANGED
@@ -1,15 +1,5 @@
1
1
  {
2
2
  "executors": {
3
- "webpack": {
4
- "implementation": "./dist/src/executors/webpack/webpack.impl",
5
- "schema": "./dist/src/executors/webpack/schema.json",
6
- "description": "Run webpack build."
7
- },
8
- "dev-server": {
9
- "implementation": "./dist/src/executors/dev-server/dev-server.impl",
10
- "schema": "./dist/src/executors/dev-server/schema.json",
11
- "description": "Serve a web application."
12
- },
13
3
  "ssr-dev-server": {
14
4
  "implementation": "./dist/src/executors/ssr-dev-server/ssr-dev-server.impl",
15
5
  "schema": "./dist/src/executors/ssr-dev-server/schema.json",
package/migrations.json CHANGED
@@ -30,6 +30,19 @@
30
30
  "description": "Rename imports of `createNodesV2` from `@nx/webpack/plugin` to the canonical `createNodes` export.",
31
31
  "implementation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes",
32
32
  "documentation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md"
33
+ },
34
+ "remove-deprecated-executors": {
35
+ "version": "24.0.0-beta.3",
36
+ "description": "Converts targets using the removed `@nx/webpack` executors to inferred tasks; an AI prompt finishes the targets the converter cannot convert safely and validates the project graph.",
37
+ "implementation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors",
38
+ "prompt": "./dist/src/migrations/update-24-0-0/finish-inferred-conversion.md",
39
+ "documentation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors.md"
40
+ },
41
+ "update-24-0-0-migrate-compose-plugins": {
42
+ "version": "24.0.0-beta.3",
43
+ "description": "Converts webpack configs that use the removed `composePlugins`, `withNx`, `withWeb` and `withReact` helpers with `@nx/webpack:convert-config-to-webpack-plugin`, then hands an AI prompt the projects it could not convert and the `.old` configs it left behind.",
44
+ "implementation": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins",
45
+ "prompt": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins.md"
33
46
  }
34
47
  },
35
48
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "24.0.0-pr.37405.acdaf31",
3
+ "version": "24.0.0-rc.0",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -38,6 +38,12 @@
38
38
  ],
39
39
  "internal": [
40
40
  "dist/internal.d.ts"
41
+ ],
42
+ "ready-check": [
43
+ "dist/ready-check.d.ts"
44
+ ],
45
+ "ready-signal": [
46
+ "dist/ready-signal.d.ts"
41
47
  ]
42
48
  }
43
49
  },
@@ -74,6 +80,16 @@
74
80
  "types": "./dist/plugin.d.ts",
75
81
  "default": "./dist/plugin.js"
76
82
  },
83
+ "./ready-check": {
84
+ "@nx/nx-source": "./ready-check.ts",
85
+ "types": "./dist/ready-check.d.ts",
86
+ "default": "./dist/ready-check.js"
87
+ },
88
+ "./ready-signal": {
89
+ "@nx/nx-source": "./ready-signal.ts",
90
+ "types": "./dist/ready-signal.d.ts",
91
+ "default": "./dist/ready-signal.js"
92
+ },
77
93
  "./tsconfig-paths-plugin": {
78
94
  "@nx/nx-source": "./tsconfig-paths-plugin.ts",
79
95
  "types": "./dist/tsconfig-paths-plugin.d.ts",
@@ -118,8 +134,8 @@
118
134
  "tslib": "^2.3.0",
119
135
  "webpack-node-externals": "^3.0.0",
120
136
  "webpack-subresource-integrity": "^5.1.0",
121
- "@nx/devkit": "24.0.0-pr.37405.acdaf31",
122
- "@nx/js": "24.0.0-pr.37405.acdaf31"
137
+ "@nx/devkit": "24.0.0-rc.0",
138
+ "@nx/js": "24.0.0-rc.0"
123
139
  },
124
140
  "peerDependencies": {
125
141
  "webpack": "^5.0.0",
@@ -138,7 +154,7 @@
138
154
  }
139
155
  },
140
156
  "devDependencies": {
141
- "nx": "24.0.0-pr.37405.acdaf31"
157
+ "nx": "24.0.0-rc.0"
142
158
  },
143
159
  "publishConfig": {
144
160
  "access": "public"
@@ -1,3 +0,0 @@
1
- import type webpack from 'webpack';
2
- import { Observable } from 'rxjs';
3
- export declare function runWebpack(config: webpack.Configuration): Observable<webpack.Stats>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runWebpack = runWebpack;
4
- const rxjs_1 = require("rxjs");
5
- // TODO(jack): move to dev-server executor
6
- function runWebpack(config) {
7
- // Lazy-loaded: `webpack` is an optional peer, absent during project-graph discovery.
8
- const webpackImpl = require('webpack');
9
- return new rxjs_1.Observable((subscriber) => {
10
- // Passing `watch` option here will result in a warning due to missing callback.
11
- // We manually call `.watch` or `.run` later so this option isn't needed here.
12
- const { watch, ...normalizedConfig } = config;
13
- const webpackCompiler = webpackImpl(normalizedConfig);
14
- const callback = (err, stats) => {
15
- if (err) {
16
- subscriber.error(err);
17
- }
18
- subscriber.next(stats);
19
- };
20
- if (config.watch) {
21
- const watchOptions = config.watchOptions || {};
22
- const watching = webpackCompiler.watch(watchOptions, callback);
23
- return () => watching.close(() => subscriber.complete());
24
- }
25
- else {
26
- webpackCompiler.run((err, stats) => {
27
- callback(err, stats);
28
- webpackCompiler.close((closeErr) => {
29
- if (closeErr)
30
- subscriber.error(closeErr);
31
- subscriber.complete();
32
- });
33
- });
34
- }
35
- });
36
- }