@nx/webpack 21.0.0-beta.10 → 21.0.0-beta.12

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/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { useLegacyNxPlugin } from './src/plugins/use-legacy-nx-plugin/use-legacy
6
6
  export { configurationGenerator, convertConfigToWebpackPluginGenerator, useLegacyNxPlugin, };
7
7
  /** @deprecated Use `configurationGenerator` instead. */
8
8
  export declare const webpackProjectGenerator: typeof configurationGenerator;
9
- /** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
9
+ /** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
10
10
  export declare const NxWebpackPlugin: typeof NxAppWebpackPlugin;
11
11
  /** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
12
12
  export declare const NxTsconfigPathsWebpackPlugin: typeof _NxTsconfigPathsWebpackPlugin;
package/index.js CHANGED
@@ -13,8 +13,7 @@ Object.defineProperty(exports, "useLegacyNxPlugin", { enumerable: true, get: fun
13
13
  // Exported for backwards compatibility in case a plugin is using the old name.
14
14
  /** @deprecated Use `configurationGenerator` instead. */
15
15
  exports.webpackProjectGenerator = configuration_1.configurationGenerator;
16
- // TODO(v21): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
17
- /** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
16
+ /** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
18
17
  exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
19
18
  /** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
20
19
  exports.NxTsconfigPathsWebpackPlugin = nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin;
package/migrations.json CHANGED
@@ -5,6 +5,12 @@
5
5
  "version": "19.6.3-beta.0",
6
6
  "description": "Migrate proxy config files to match new format from webpack-dev-server v5.",
7
7
  "implementation": "./src/migrations/update-19-6-3/proxy-config"
8
+ },
9
+ "update-21-0-0-remove-isolated-config": {
10
+ "cli": "nx",
11
+ "version": "21.0.0-beta.11",
12
+ "description": "Remove isolatedConfig option for @nx/webpack:webpack",
13
+ "implementation": "./src/migrations/update-21-0-0/remove-isolated-config"
8
14
  }
9
15
  },
10
16
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "21.0.0-beta.10",
3
+ "version": "21.0.0-beta.12",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -66,8 +66,8 @@
66
66
  "webpack-dev-server": "^5.2.1",
67
67
  "webpack-node-externals": "^3.0.0",
68
68
  "webpack-subresource-integrity": "^5.1.0",
69
- "@nx/devkit": "21.0.0-beta.10",
70
- "@nx/js": "21.0.0-beta.10"
69
+ "@nx/devkit": "21.0.0-beta.12",
70
+ "@nx/js": "21.0.0-beta.12"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"
@@ -47,9 +47,6 @@ export interface WebpackExecutorOptions {
47
47
  extractLicenses?: boolean;
48
48
  fileReplacements?: FileReplacement[];
49
49
  generatePackageJson?: boolean;
50
- // TODO(v21): Remove this option
51
- /** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
52
- isolatedConfig?: boolean;
53
50
  standardWebpackConfigFunction?: boolean;
54
51
  main?: string;
55
52
  memoryLimit?: number;
@@ -254,12 +254,6 @@
254
254
  "type": "boolean",
255
255
  "description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or `<https://webpack.github.io/analyse>`."
256
256
  },
257
- "isolatedConfig": {
258
- "type": "boolean",
259
- "description": "Do not apply Nx webpack plugins automatically. Plugins need to be applied in the project's webpack.config.js file (e.g. withNx, withReact, etc.).",
260
- "default": true,
261
- "x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 20. See https://nx.dev/recipes/webpack/webpack-config-setup."
262
- },
263
257
  "standardWebpackConfigFunction": {
264
258
  "type": "boolean",
265
259
  "description": "Set to true if the webpack config exports a standard webpack function, not an Nx-specific one. See: https://webpack.js.org/configuration/configuration-types/#exporting-a-function",
@@ -11,13 +11,8 @@ const fs_1 = require("../../utils/fs");
11
11
  const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
12
12
  const normalize_options_1 = require("./lib/normalize-options");
13
13
  const config_1 = require("../../utils/config");
14
- const with_nx_1 = require("../../utils/with-nx");
15
14
  const js_1 = require("@nx/js");
16
- const with_web_1 = require("../../utils/with-web");
17
15
  async function getWebpackConfigs(options, context) {
18
- if (options.isolatedConfig && !options.webpackConfig) {
19
- throw new Error(`Using "isolatedConfig" without a "webpackConfig" is not supported.`);
20
- }
21
16
  let userDefinedWebpackConfig = null;
22
17
  if (options.webpackConfig) {
23
18
  userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(options.webpackConfig, (0, js_1.getRootTsConfigPath)());
@@ -25,11 +20,7 @@ async function getWebpackConfigs(options, context) {
25
20
  userDefinedWebpackConfig = await userDefinedWebpackConfig;
26
21
  }
27
22
  }
28
- const config = options.isolatedConfig
29
- ? {}
30
- : (options.target === 'web'
31
- ? (0, config_1.composePluginsSync)((0, with_nx_1.withNx)(options), (0, with_web_1.withWeb)(options))
32
- : (0, with_nx_1.withNx)(options))({}, { options, context });
23
+ const config = {};
33
24
  if (typeof userDefinedWebpackConfig === 'function' &&
34
25
  ((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
35
26
  !options.standardWebpackConfigFunction)) {
@@ -90,14 +90,6 @@ function extractPluginOptions(options, context, configName) {
90
90
  }
91
91
  delete options.memoryLimit;
92
92
  }
93
- else if (key === 'isolatedConfig') {
94
- context.logger.addLog({
95
- executorName: '@nx/webpack:webpack',
96
- log: `The 'isolatedConfig' option is deprecated and not supported by the NxAppWebpackPlugin. It was removed from your project configuration.`,
97
- project: context.projectName,
98
- });
99
- delete options.isolatedConfig;
100
- }
101
93
  else if (key === 'standardWebpackConfigFunction') {
102
94
  delete options.standardWebpackConfigFunction;
103
95
  }
@@ -15,7 +15,7 @@ async function webpackInitGeneratorInternal(tree, schema) {
15
15
  nxJson.useInferencePlugins !== false;
16
16
  schema.addPlugin ??= addPluginDefault;
17
17
  if (schema.addPlugin) {
18
- await (0, add_plugin_1.addPluginV1)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/webpack/plugin', plugin_1.createNodes, {
18
+ await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/webpack/plugin', plugin_1.createNodesV2, {
19
19
  buildTargetName: [
20
20
  'build',
21
21
  'webpack:build',
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
+ async function default_1(tree) {
7
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/webpack:webpack', (options, projectName, targetName, configurationName) => {
8
+ // Only handle webpack config for default configuration
9
+ if (configurationName)
10
+ return;
11
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
12
+ if (!options.webpackConfig) {
13
+ delete options['isolatedConfig'];
14
+ options.webpackConfig = `${projectConfiguration.root}/webpack.config.js`;
15
+ tree.write(options.webpackConfig, options.target === 'web'
16
+ ? `
17
+ const { composePlugins, withNx, withWeb } = require('@nx/webpack');
18
+
19
+ // Nx plugins for webpack.
20
+ module.exports = composePlugins(withNx(), withWeb(), (config) => {
21
+ // Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
22
+ // See: https://nx.dev/recipes/webpack/webpack-config-setup
23
+ return config;
24
+ });
25
+ `
26
+ : `
27
+ const { composePlugins, withNx } = require('@nx/webpack');
28
+
29
+ // Nx plugins for webpack.
30
+ module.exports = composePlugins(withNx(), (config) => {
31
+ // Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
32
+ // See: https://nx.dev/recipes/webpack/webpack-config-setup
33
+ return config;
34
+ });
35
+ `);
36
+ projectConfiguration.targets[targetName].options = options;
37
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
38
+ }
39
+ });
40
+ await (0, devkit_1.formatFiles)(tree);
41
+ }
@@ -359,6 +359,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
359
359
  },
360
360
  },
361
361
  },
362
+ // TODO(v22): Remove this but provide a migration in `@nx/react` to add @svgr/webpack in userland webpack config
362
363
  // SVG: same as image but we need to separate it so it can be swapped for SVGR in the React plugin.
363
364
  {
364
365
  test: /\.svg$/,