@nx/webpack 21.2.1 → 21.2.2

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": "21.2.1",
3
+ "version": "21.2.2",
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.2.1",
70
- "@nx/js": "21.2.1"
69
+ "@nx/devkit": "21.2.2",
70
+ "@nx/js": "21.2.2"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"
@@ -71,8 +71,28 @@ function applyNxIndependentConfig(options, config) {
71
71
  options.sourceMap === true ? 'source-map' : options.sourceMap;
72
72
  config.output = {
73
73
  ...config.output,
74
- libraryTarget: config.output?.libraryTarget ??
75
- (options.target === 'node' ? 'commonjs' : undefined),
74
+ libraryTarget: (() => {
75
+ const existingOutputConfig = config.output;
76
+ const existingLibraryTarget = existingOutputConfig?.libraryTarget;
77
+ const existingLibraryType = typeof existingOutputConfig?.library === 'object' &&
78
+ 'type' in existingOutputConfig?.library
79
+ ? existingOutputConfig?.library?.type
80
+ : undefined;
81
+ // If user is using modern library.type, don't set the deprecated libraryTarget
82
+ if (existingLibraryType !== undefined) {
83
+ return undefined;
84
+ }
85
+ // If user has set libraryTarget explicitly, use it
86
+ if (existingLibraryTarget !== undefined) {
87
+ return existingLibraryTarget;
88
+ }
89
+ // Set defaults based on target when user hasn't configured anything
90
+ if (options.target === 'node')
91
+ return 'commonjs';
92
+ if (options.target === 'async-node')
93
+ return 'commonjs-module';
94
+ return undefined;
95
+ })(),
76
96
  path: config.output?.path ??
77
97
  (options.outputPath
78
98
  ? // If path is relative, it is relative from project root (aka cwd).