@nx/webpack 23.2.0-beta.10 → 23.2.0-beta.11

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/README.md CHANGED
@@ -7,9 +7,9 @@
7
7
 
8
8
  <div style="text-align: center;">
9
9
 
10
- [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
10
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)](<>)
11
11
  [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
12
- [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
12
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](<>)
13
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
14
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
15
  [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
@@ -93,8 +93,7 @@ export interface WebpackExecutorOptions {
93
93
  rebaseRootRelative?: boolean;
94
94
  }
95
95
 
96
- export interface NormalizedWebpackExecutorOptions
97
- extends WebpackExecutorOptions {
96
+ export interface NormalizedWebpackExecutorOptions extends WebpackExecutorOptions {
98
97
  outputFileName: string;
99
98
  assets: AssetGlobPattern[];
100
99
  root: string;
@@ -24,6 +24,23 @@ const extensionAlias = {
24
24
  };
25
25
  const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
26
26
  const mainFields = ['module', 'main'];
27
+ /**
28
+ * `withNx` builds a raw config that webpack validates, and only the boolean is
29
+ * schema-valid before 5.110. `NxAppWebpackPlugin` instead mutates options that
30
+ * are already normalized, which 5.110 fills by setting `.javascript` on
31
+ * `minimize`, so a boolean throws there.
32
+ */
33
+ function setMinimizeValue(optimization, shouldMinify, configIsNormalized) {
34
+ if (!shouldMinify) {
35
+ optimization.minimize = false;
36
+ return;
37
+ }
38
+ if (configIsNormalized) {
39
+ optimization.minimize = {};
40
+ return;
41
+ }
42
+ optimization.minimize = true;
43
+ }
27
44
  function applyBaseConfig(options, config = {}, { useNormalizedEntry, } = {}) {
28
45
  // Defaults that was applied from executor schema previously.
29
46
  options.compiler ??= 'babel';
@@ -31,13 +48,13 @@ function applyBaseConfig(options, config = {}, { useNormalizedEntry, } = {}) {
31
48
  options.fileReplacements ??= [];
32
49
  options.memoryLimit ??= 2048;
33
50
  options.transformers ??= [];
34
- applyNxIndependentConfig(options, config);
51
+ applyNxIndependentConfig(options, config, !!useNormalizedEntry);
35
52
  // Some of the options only work during actual tasks, not when reading the webpack config during CreateNodes.
36
53
  if (global.NX_GRAPH_CREATION)
37
54
  return;
38
55
  applyNxDependentConfig(options, config, { useNormalizedEntry });
39
56
  }
40
- function applyNxIndependentConfig(options, config) {
57
+ function applyNxIndependentConfig(options, config, configIsNormalized) {
41
58
  const TerserPlugin = require('terser-webpack-plugin');
42
59
  const hashFormat = (0, hash_format_1.getOutputHashFormat)(options.outputHashing);
43
60
  config.context = path.join(options.root, options.projectRoot);
@@ -126,12 +143,12 @@ function applyNxIndependentConfig(options, config) {
126
143
  (x) => IGNORED_WEBPACK_WARNINGS.some((r) => typeof x === 'string' ? r.test(x) : r.test(x.message)),
127
144
  ...(config.ignoreWarnings ?? []),
128
145
  ];
146
+ const shouldMinify = typeof options.optimization === 'object'
147
+ ? !!options.optimization.scripts
148
+ : !!options.optimization;
129
149
  config.optimization = {
130
150
  ...config.optimization,
131
151
  sideEffects: true,
132
- minimize: typeof options.optimization === 'object'
133
- ? !!options.optimization.scripts
134
- : !!options.optimization,
135
152
  minimizer: [
136
153
  options.compiler !== 'swc'
137
154
  ? new TerserPlugin({
@@ -164,6 +181,7 @@ function applyNxIndependentConfig(options, config) {
164
181
  runtimeChunk: false,
165
182
  concatenateModules: true,
166
183
  };
184
+ setMinimizeValue(config.optimization, shouldMinify, configIsNormalized);
167
185
  config.stats = {
168
186
  hash: true,
169
187
  timings: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "23.2.0-beta.10",
3
+ "version": "23.2.0-beta.11",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -118,8 +118,8 @@
118
118
  "tslib": "^2.3.0",
119
119
  "webpack-node-externals": "^3.0.0",
120
120
  "webpack-subresource-integrity": "^5.1.0",
121
- "@nx/devkit": "23.2.0-beta.10",
122
- "@nx/js": "23.2.0-beta.10"
121
+ "@nx/devkit": "23.2.0-beta.11",
122
+ "@nx/js": "23.2.0-beta.11"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "webpack": "^5.0.0",
@@ -138,7 +138,7 @@
138
138
  }
139
139
  },
140
140
  "devDependencies": {
141
- "nx": "23.2.0-beta.10"
141
+ "nx": "23.2.0-beta.11"
142
142
  },
143
143
  "publishConfig": {
144
144
  "access": "public"