@nx/webpack 21.2.0 → 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.0",
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.0",
70
- "@nx/js": "21.2.0"
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).
@@ -168,6 +168,11 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
168
168
  spa: true,
169
169
  },
170
170
  };
171
+ // for `convert-to-inferred` we need to leave the port undefined or the options will not match
172
+ if (webpackConfig.devServer?.port && webpackConfig.devServer?.port !== 4200) {
173
+ targets[options.serveStaticTargetName].options.port =
174
+ webpackConfig.devServer.port;
175
+ }
171
176
  if (isTsSolutionSetup) {
172
177
  targets[options.buildTargetName].syncGenerators = [
173
178
  '@nx/js:typescript-sync',
@@ -19,7 +19,7 @@ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isP
19
19
  defaultServeTargetName: 'serve',
20
20
  defaultServeStaticTargetName: 'serve-static',
21
21
  defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
22
- defaultE2ECiBaseUrl: 'http://localhost:4200',
22
+ defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
23
23
  defaultE2EPort: e2ePort,
24
24
  }, isPluginBeingAdded);
25
25
  }