@nx/webpack 22.4.0-canary.20260113-246d4fd → 22.4.0-canary.20260114-45f2ae3

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": "22.4.0-canary.20260113-246d4fd",
3
+ "version": "22.4.0-canary.20260114-45f2ae3",
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": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/core": "^7.23.2",
34
- "@phenomnomnominal/tsquery": "~5.0.1",
34
+ "@phenomnomnominal/tsquery": "~6.1.4",
35
35
  "ajv": "^8.12.0",
36
36
  "autoprefixer": "^10.4.9",
37
37
  "babel-loader": "^9.1.2",
@@ -64,11 +64,11 @@
64
64
  "webpack-dev-server": "^5.2.1",
65
65
  "webpack-node-externals": "^3.0.0",
66
66
  "webpack-subresource-integrity": "^5.1.0",
67
- "@nx/devkit": "22.4.0-canary.20260113-246d4fd",
68
- "@nx/js": "22.4.0-canary.20260113-246d4fd"
67
+ "@nx/devkit": "22.4.0-canary.20260114-45f2ae3",
68
+ "@nx/js": "22.4.0-canary.20260114-45f2ae3"
69
69
  },
70
70
  "devDependencies": {
71
- "nx": "22.4.0-canary.20260113-246d4fd"
71
+ "nx": "22.4.0-canary.20260114-45f2ae3"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"extract-webpack-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/webpack/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM;;;EA4D1E"}
1
+ {"version":3,"file":"extract-webpack-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/webpack/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM;;;EA+D1E"}
@@ -5,13 +5,13 @@ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
5
  const ts = require("typescript");
6
6
  function extractWebpackOptions(tree, webpackConfigPath) {
7
7
  const source = tree.read(webpackConfigPath).toString('utf-8');
8
- const ast = tsquery_1.tsquery.ast(source);
8
+ const sourceFile = (0, tsquery_1.ast)(source);
9
9
  const withNxQuery = 'CallExpression:has(Identifier[name="withNx"])';
10
10
  const withReactQuery = 'CallExpression:has(Identifier[name="withReact"])';
11
11
  const withWebQuery = 'CallExpression:has(Identifier[name="withWeb"])';
12
- const withNxCall = (0, tsquery_1.tsquery)(ast, withNxQuery);
13
- const withReactCall = (0, tsquery_1.tsquery)(ast, withReactQuery);
14
- const withWebCall = (0, tsquery_1.tsquery)(ast, withWebQuery);
12
+ const withNxCall = (0, tsquery_1.query)(sourceFile, withNxQuery);
13
+ const withReactCall = (0, tsquery_1.query)(sourceFile, withReactQuery);
14
+ const withWebCall = (0, tsquery_1.query)(sourceFile, withWebQuery);
15
15
  // If the config is empty set to empty string to avoid undefined. Undefined is used to check if the withNx exists inside of the config file.
16
16
  let withNxConfig, withReactConfig;
17
17
  withWebCall.forEach((node) => {
@@ -44,14 +44,14 @@ function removeCallExpressions(source, functionNames) {
44
44
  let modifiedSource = source;
45
45
  functionNames.forEach((functionName) => {
46
46
  const callExpressionQuery = `CallExpression:has(Identifier[name="composePlugins"]) > CallExpression:has(Identifier[name="${functionName}"])`;
47
- modifiedSource = tsquery_1.tsquery.replace(modifiedSource, callExpressionQuery, () => {
47
+ modifiedSource = (0, tsquery_1.replace)(modifiedSource, callExpressionQuery, () => {
48
48
  return ''; // Removes the entire CallExpression
49
49
  });
50
50
  });
51
51
  return modifiedSource;
52
52
  }
53
53
  function removeImportDeclarations(source, importName, moduleName) {
54
- const sourceFile = tsquery_1.tsquery.ast(source);
54
+ const sourceFile = (0, tsquery_1.ast)(source);
55
55
  const modifiedStatements = sourceFile.statements
56
56
  .map((statement) => {
57
57
  if (!ts.isVariableStatement(statement))
@@ -70,14 +70,14 @@ function skipProjectFilterFactory(tree) {
70
70
  if (!webpackConfigPath) {
71
71
  return `The webpack config path is missing in the project configuration (${projectConfiguration.root}).`;
72
72
  }
73
- const sourceFile = tsquery_1.tsquery.ast(tree.read(webpackConfigPath, 'utf-8'));
73
+ const sourceFile = (0, tsquery_1.ast)(tree.read(webpackConfigPath, 'utf-8'));
74
74
  const composePluginsSelector = 'CallExpression:has(Identifier[name=composePlugins])';
75
- const composePlugins = (0, tsquery_1.tsquery)(sourceFile, composePluginsSelector)[0];
75
+ const composePlugins = (0, tsquery_1.query)(sourceFile, composePluginsSelector)[0];
76
76
  if (composePlugins) {
77
77
  return `The webpack config (${webpackConfigPath}) can only work with the "@nx/webpack:webpack" executor. Run the "@nx/webpack:convert-config-to-webpack-plugin" generator first.`;
78
78
  }
79
79
  const nxAppWebpackPluginSelector = 'PropertyAssignment:has(Identifier[name=plugins]) NewExpression:has(Identifier[name=NxAppWebpackPlugin])';
80
- const nxAppWebpackPlugin = (0, tsquery_1.tsquery)(sourceFile, nxAppWebpackPluginSelector)[0];
80
+ const nxAppWebpackPlugin = (0, tsquery_1.query)(sourceFile, nxAppWebpackPluginSelector)[0];
81
81
  if (!nxAppWebpackPlugin) {
82
82
  return `No "NxAppWebpackPlugin" found in the webpack config (${webpackConfigPath}). Its usage is required for the migration to work.`;
83
83
  }
@@ -105,7 +105,7 @@ function updateWebpackConfig(tree, webpackConfig, pluginOptions) {
105
105
  let webpackConfigText;
106
106
  const updateSources = () => {
107
107
  webpackConfigText = tree.read(webpackConfig, 'utf-8');
108
- sourceFile = tsquery_1.tsquery.ast(webpackConfigText);
108
+ sourceFile = (0, tsquery_1.ast)(webpackConfigText);
109
109
  };
110
110
  updateSources();
111
111
  setOptionsInWebpackConfig(tree, webpackConfigText, sourceFile, webpackConfig, pluginOptions);
@@ -117,11 +117,11 @@ function updateWebpackConfig(tree, webpackConfig, pluginOptions) {
117
117
  function setOptionsInWebpackConfig(tree, text, sourceFile, webpackConfig, pluginOptions) {
118
118
  const { default: defaultOptions, ...configurationOptions } = pluginOptions;
119
119
  const optionsSelector = 'VariableStatement:has(VariableDeclaration:has(Identifier[name=options]))';
120
- const optionsVariable = (0, tsquery_1.tsquery)(sourceFile, optionsSelector)[0];
120
+ const optionsVariable = (0, tsquery_1.query)(sourceFile, optionsSelector)[0];
121
121
  // This is assuming the `options` variable will be available since it's what the
122
122
  // `convert-config-to-webpack-plugin` generates
123
123
  let defaultOptionsObject;
124
- const optionsObject = (0, tsquery_1.tsquery)(optionsVariable, 'ObjectLiteralExpression')[0];
124
+ const optionsObject = (0, tsquery_1.query)(optionsVariable, 'ObjectLiteralExpression')[0];
125
125
  if (optionsObject.properties.length === 0) {
126
126
  defaultOptionsObject = ts.factory.createObjectLiteralExpression(Object.entries(defaultOptions).map(([key, value]) => (0, ast_1.toPropertyAssignment)(key, value)));
127
127
  }
@@ -176,7 +176,7 @@ function setOptionsInWebpackConfig(tree, text, sourceFile, webpackConfig, plugin
176
176
  }
177
177
  function setOptionsInNxWebpackPlugin(tree, text, sourceFile, webpackConfig) {
178
178
  const nxAppWebpackPluginSelector = 'PropertyAssignment:has(Identifier[name=plugins]) NewExpression:has(Identifier[name=NxAppWebpackPlugin])';
179
- const nxAppWebpackPlugin = (0, tsquery_1.tsquery)(sourceFile, nxAppWebpackPluginSelector)[0];
179
+ const nxAppWebpackPlugin = (0, tsquery_1.query)(sourceFile, nxAppWebpackPluginSelector)[0];
180
180
  // the NxAppWebpackPlugin must exists, otherwise, the migration doesn't run and we wouldn't reach this point
181
181
  const updatedNxAppWebpackPlugin = ts.factory.updateNewExpression(nxAppWebpackPlugin, nxAppWebpackPlugin.expression, undefined, [ts.factory.createIdentifier('buildOptions')]);
182
182
  text = `${text.slice(0, nxAppWebpackPlugin.getStart())}${ts
@@ -186,7 +186,7 @@ function setOptionsInNxWebpackPlugin(tree, text, sourceFile, webpackConfig) {
186
186
  }
187
187
  function setOptionsInLegacyNxPlugin(tree, text, sourceFile, webpackConfig) {
188
188
  const legacyNxPluginSelector = 'AwaitExpression CallExpression:has(Identifier[name=useLegacyNxPlugin])';
189
- const legacyNxPlugin = (0, tsquery_1.tsquery)(sourceFile, legacyNxPluginSelector)[0];
189
+ const legacyNxPlugin = (0, tsquery_1.query)(sourceFile, legacyNxPluginSelector)[0];
190
190
  // we're assuming the `useLegacyNxPlugin` function is being called since it's what the `convert-config-to-webpack-plugin` generates
191
191
  // we've already "ensured" that the `convert-config-to-webpack-plugin` was run by checking for the `NxAppWebpackPlugin` in the project validation
192
192
  const updatedLegacyNxPlugin = ts.factory.updateCallExpression(legacyNxPlugin, legacyNxPlugin.expression, undefined, [legacyNxPlugin.arguments[0], ts.factory.createIdentifier('buildOptions')]);
@@ -179,7 +179,7 @@ function updateWebpackConfig(tree, webpackConfigPath, devServerOptions, context)
179
179
  let webpackConfigText;
180
180
  const updateSources = () => {
181
181
  webpackConfigText = tree.read(webpackConfigPath, 'utf-8');
182
- sourceFile = tsquery_1.tsquery.ast(webpackConfigText);
182
+ sourceFile = (0, tsquery_1.ast)(webpackConfigText);
183
183
  };
184
184
  updateSources();
185
185
  setOptionsInWebpackConfig(tree, webpackConfigText, sourceFile, webpackConfigPath, devServerOptions);
@@ -189,7 +189,7 @@ function updateWebpackConfig(tree, webpackConfigPath, devServerOptions, context)
189
189
  function setOptionsInWebpackConfig(tree, text, sourceFile, webpackConfigPath, devServerOptions) {
190
190
  const { default: defaultOptions, ...configurationOptions } = devServerOptions;
191
191
  const configValuesSelector = 'VariableDeclaration:has(Identifier[name=configValues]) ObjectLiteralExpression';
192
- const configValuesObject = (0, tsquery_1.tsquery)(sourceFile, configValuesSelector)[0];
192
+ const configValuesObject = (0, tsquery_1.query)(sourceFile, configValuesSelector)[0];
193
193
  // configValues must exist at this point, we added it when processing the build target
194
194
  /**
195
195
  * const configValues = {
@@ -213,9 +213,9 @@ function setOptionsInWebpackConfig(tree, text, sourceFile, webpackConfigPath, de
213
213
  .createPrinter()
214
214
  .printNode(ts.EmitHint.Unspecified, updatedConfigValuesObject, sourceFile)}${text.slice(configValuesObject.getEnd())}`;
215
215
  tree.write(webpackConfigPath, text);
216
- sourceFile = tsquery_1.tsquery.ast(text);
216
+ sourceFile = (0, tsquery_1.ast)(text);
217
217
  const buildOptionsSelector = 'VariableStatement:has(VariableDeclaration:has(Identifier[name=buildOptions]))';
218
- const buildOptionsStatement = (0, tsquery_1.tsquery)(sourceFile, buildOptionsSelector)[0];
218
+ const buildOptionsStatement = (0, tsquery_1.query)(sourceFile, buildOptionsSelector)[0];
219
219
  text = `${text.slice(0, buildOptionsStatement.getEnd())}
220
220
  const devServerOptions = {
221
221
  ...configValues.serve.default,
@@ -225,7 +225,7 @@ function setOptionsInWebpackConfig(tree, text, sourceFile, webpackConfigPath, de
225
225
  }
226
226
  function setDevServerOptionsInWebpackConfig(tree, text, sourceFile, webpackConfigPath, context) {
227
227
  const webpackConfigDevServerSelector = 'ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=devServer])';
228
- const webpackConfigDevServer = (0, tsquery_1.tsquery)(sourceFile, webpackConfigDevServerSelector)[0];
228
+ const webpackConfigDevServer = (0, tsquery_1.query)(sourceFile, webpackConfigDevServerSelector)[0];
229
229
  if (webpackConfigDevServer) {
230
230
  context.logger.addLog({
231
231
  executorName: '@nx/webpack:dev-server',
@@ -240,7 +240,7 @@ function setDevServerOptionsInWebpackConfig(tree, text, sourceFile, webpackConfi
240
240
  return;
241
241
  }
242
242
  const webpackConfigSelector = 'ObjectLiteralExpression:has(PropertyAssignment:has(Identifier[name=plugins]))';
243
- const webpackConfig = (0, tsquery_1.tsquery)(sourceFile, webpackConfigSelector)[0];
243
+ const webpackConfig = (0, tsquery_1.query)(sourceFile, webpackConfigSelector)[0];
244
244
  const updatedWebpackConfig = ts.factory.updateObjectLiteralExpression(webpackConfig, [
245
245
  ts.factory.createPropertyAssignment('devServer', ts.factory.createIdentifier('devServerOptions')),
246
246
  ...webpackConfig.properties,