@nx/webpack 19.6.0-beta.0 → 19.6.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "19.6.0-beta.0",
3
+ "version": "19.6.0-beta.1",
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": {
@@ -69,9 +69,9 @@
69
69
  "webpack-dev-server": "^4.9.3",
70
70
  "webpack-node-externals": "^3.0.0",
71
71
  "webpack-subresource-integrity": "^5.1.0",
72
- "@nx/devkit": "19.6.0-beta.0",
73
- "@nx/js": "19.6.0-beta.0",
74
- "@nrwl/webpack": "19.6.0-beta.0"
72
+ "@nx/devkit": "19.6.0-beta.1",
73
+ "@nx/js": "19.6.0-beta.1",
74
+ "@nrwl/webpack": "19.6.0-beta.1"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public"
@@ -1,6 +1,6 @@
1
- import { NxWebpackExecutionContext } from '../../utils/config';
2
- import { NxAppWebpackPluginOptions } from '../nx-webpack-plugin/nx-app-webpack-plugin-options';
3
- import { Configuration } from 'webpack';
1
+ import type { NxWebpackExecutionContext } from '../../utils/config';
2
+ import type { NxAppWebpackPluginOptions } from '../nx-webpack-plugin/nx-app-webpack-plugin-options';
3
+ import type { Compiler, Configuration } from 'webpack';
4
4
  /**
5
5
  * This function is used to wrap the legacy plugin function to be used with the `composePlugins` function.
6
6
  * Initially the webpack config would be passed to the legacy plugin function and the options would be passed as a second argument.
@@ -26,4 +26,6 @@ module.exports = async () => ({
26
26
  * @param executorOptions The options passed usually inside the executor or the config file
27
27
  * @returns Webpack configuration
28
28
  */
29
- export declare function useLegacyNxPlugin(fn: (config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>, executorOptions: NxAppWebpackPluginOptions): Promise<(config: Configuration) => Promise<Configuration>>;
29
+ export declare function useLegacyNxPlugin(fn: (config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>, executorOptions: NxAppWebpackPluginOptions): Promise<{
30
+ apply(compiler: Compiler): void;
31
+ }>;
@@ -47,12 +47,24 @@ async function useLegacyNxPlugin(fn, executorOptions) {
47
47
  projectName: projectName,
48
48
  };
49
49
  const configuration = process.env.NX_TASK_TARGET_CONFIGURATION;
50
- return async (config) => {
51
- const ctx = {
52
- context,
53
- options: options,
54
- configuration,
55
- };
56
- return await fn(config, ctx);
50
+ const ctx = {
51
+ context,
52
+ options: options,
53
+ configuration,
54
+ };
55
+ return {
56
+ apply(compiler) {
57
+ compiler.hooks.beforeCompile.tapPromise('NxLegacyAsyncPlugin', () => {
58
+ return new Promise((resolve) => {
59
+ fn(compiler.options, ctx).then((updated) => {
60
+ // Merge options back shallowly since it's a fully functional configuration.
61
+ // Most likely, the user modified the config in place, but this guarantees that updates are applied if users did something like:
62
+ // `return { ...config, plugins: [...config.plugins, new MyPlugin()] }`
63
+ Object.assign(compiler.options, updated);
64
+ resolve();
65
+ });
66
+ });
67
+ });
68
+ },
57
69
  };
58
70
  }