@nx/web 24.0.0-beta.2 → 24.0.0-beta.4

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/dist/internal.js CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fileServerExecutor = exports.waitForPortOpen = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  // Curated internal API surface for other first-party Nx plugins (e.g. @nx/react,
6
- // @nx/angular, @nx/rspack, @nx/next, @nx/module-federation). Prefer
7
- // this over deep `@nx/web/src/*` imports — those are not part of the public API.
6
+ // @nx/angular, @nx/rspack, @nx/next). Prefer this over deep `@nx/web/src/*`
7
+ // imports — those are not part of the public API.
8
8
  var wait_for_port_open_1 = require("./src/utils/wait-for-port-open");
9
9
  Object.defineProperty(exports, "waitForPortOpen", { enumerable: true, get: function () { return wait_for_port_open_1.waitForPortOpen; } });
10
10
  var file_server_impl_1 = require("./src/executors/file-server/file-server.impl");
@@ -79,10 +79,6 @@ function createApplicationFiles(tree, options) {
79
79
  async function setupBundler(tree, options) {
80
80
  const main = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/main.ts');
81
81
  const tsConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
82
- const assets = [
83
- (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
84
- (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/assets'),
85
- ];
86
82
  if (options.bundler === 'webpack') {
87
83
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
88
84
  await configurationGenerator(tree, {
@@ -94,43 +90,7 @@ async function setupBundler(tree, options) {
94
90
  devServer: true,
95
91
  webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
96
92
  skipFormat: true,
97
- addPlugin: options.addPlugin,
98
93
  });
99
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
100
- // Only when asked: @nx/webpack:dev-server already defaults to 4200.
101
- if (options.port != null && project.targets?.serve) {
102
- project.targets.serve.options ??= {};
103
- project.targets.serve.options.port = options.port;
104
- (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
105
- }
106
- if (project.targets?.build) {
107
- const prodConfig = project.targets.build.configurations.production;
108
- const buildOptions = project.targets.build.options;
109
- buildOptions.assets = assets;
110
- buildOptions.index = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html');
111
- buildOptions.baseHref = '/';
112
- buildOptions.styles = [
113
- (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
114
- ];
115
- // We can delete that, because this projest is an application
116
- // and applications have a .babelrc file in their root dir.
117
- // So Nx will find it and use it
118
- delete buildOptions.babelUpwardRootMode;
119
- buildOptions.scripts = [];
120
- prodConfig.fileReplacements = [
121
- {
122
- replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.ts`),
123
- with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.prod.ts`),
124
- },
125
- ];
126
- prodConfig.optimization = true;
127
- prodConfig.outputHashing = 'all';
128
- prodConfig.sourceMap = false;
129
- prodConfig.namedChunks = false;
130
- prodConfig.extractLicenses = true;
131
- prodConfig.vendorChunk = false;
132
- (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
133
- }
134
94
  // TODO(jack): Flush this out... no bundler should be possible for web but the experience isn't holistic due to missing features (e.g. writing index.html).
135
95
  }
136
96
  else if (options.bundler === 'none') {
@@ -193,10 +153,7 @@ function setDefaults(tree, options) {
193
153
  (0, devkit_1.updateNxJson)(tree, nxJson);
194
154
  }
195
155
  async function applicationGenerator(host, schema) {
196
- return await applicationGeneratorInternal(host, {
197
- addPlugin: false,
198
- ...schema,
199
- });
156
+ return await applicationGeneratorInternal(host, schema);
200
157
  }
201
158
  async function applicationGeneratorInternal(host, schema) {
202
159
  const options = await normalizeOptions(host, schema);
@@ -227,7 +184,6 @@ async function applicationGeneratorInternal(host, schema) {
227
184
  linter: options.linter,
228
185
  project: options.projectName,
229
186
  unitTestRunner: options.unitTestRunner,
230
- addPlugin: options.addPlugin,
231
187
  }));
232
188
  }
233
189
  if (options.linter === 'eslint') {
@@ -245,7 +201,6 @@ async function applicationGeneratorInternal(host, schema) {
245
201
  unitTestRunner: options.unitTestRunner,
246
202
  skipFormat: true,
247
203
  enableTypedLinting,
248
- addPlugin: options.addPlugin,
249
204
  });
250
205
  tasks.push(lintTask);
251
206
  // Add out-tsc ignore pattern when using TS solution setup
@@ -267,7 +222,6 @@ async function applicationGeneratorInternal(host, schema) {
267
222
  includeVitest: options.unitTestRunner === 'vitest',
268
223
  inSourceTests: options.inSourceTests,
269
224
  skipFormat: true,
270
- addPlugin: options.addPlugin,
271
225
  port: options.port,
272
226
  });
273
227
  tasks.push(viteTask);
@@ -293,7 +247,6 @@ async function applicationGeneratorInternal(host, schema) {
293
247
  coverageProvider: 'v8',
294
248
  inSourceTests: options.inSourceTests,
295
249
  skipFormat: true,
296
- addPlugin: options.addPlugin,
297
250
  compiler: options.compiler,
298
251
  });
299
252
  tasks.push(vitestTask);
@@ -335,13 +288,13 @@ async function applicationGeneratorInternal(host, schema) {
335
288
  };
336
289
  if (options.bundler === 'webpack') {
337
290
  const { getWebpackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
338
- e2eWebServerInfo = await getWebpackE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.js`), options.addPlugin,
291
+ e2eWebServerInfo = await getWebpackE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.js`),
339
292
  // Undefined unless --port was passed, so targetDefaults still apply.
340
293
  options.port);
341
294
  }
342
295
  else if (options.bundler === 'vite') {
343
296
  const { getViteE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
344
- e2eWebServerInfo = await getViteE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.ts`), options.addPlugin, options.port ?? 4200,
297
+ e2eWebServerInfo = await getViteE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.ts`), options.port ?? 4200,
345
298
  // An explicit port serves both dev and preview, as in @nx/react:app.
346
299
  options.port);
347
300
  }
@@ -422,7 +375,6 @@ async function applicationGeneratorInternal(host, schema) {
422
375
  enableTypedLinting,
423
376
  webServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
424
377
  webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
425
- addPlugin: options.addPlugin,
426
378
  });
427
379
  tasks.push(playwrightTask);
428
380
  }
@@ -436,7 +388,6 @@ async function applicationGeneratorInternal(host, schema) {
436
388
  setupFile: 'none',
437
389
  compiler: options.compiler,
438
390
  skipFormat: true,
439
- addPlugin: options.addPlugin,
440
391
  });
441
392
  tasks.push(jestTask);
442
393
  }
@@ -485,10 +436,6 @@ async function normalizeOptions(host, options) {
485
436
  projectType: 'application',
486
437
  directory: options.directory,
487
438
  });
488
- const nxJson = (0, devkit_1.readNxJson)(host);
489
- const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
490
- nxJson.useInferencePlugins !== false;
491
- options.addPlugin ??= addPluginDefault;
492
439
  const isUsingTsSolutionConfig = (0, internal_2.isUsingTsSolutionSetup)(host);
493
440
  const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
494
441
  const e2eProjectName = `${appProjectName}-e2e`;
@@ -25,17 +25,10 @@ module.exports = {
25
25
  ],
26
26
  };
27
27
  <% } else { %>
28
- const { composePlugins, withNx, withWeb } = require('@nx/webpack');
28
+ const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
29
29
 
30
- // Nx plugins for webpack.
31
- module.exports = composePlugins(
32
- withNx(),
33
- withWeb(),
34
- (config) => {
35
- // Update the webpack config as needed here.
36
- // e.g. `config.plugins.push(new MyPlugin())`
37
- config.output.clean = true;
38
- return config;
39
- }
40
- );
30
+ module.exports = {
31
+ output: { clean: true },
32
+ plugins: [new NxAppWebpackPlugin()],
33
+ };
41
34
  <% } %>
@@ -20,7 +20,6 @@ export interface Schema {
20
20
  */
21
21
  setParserOptionsProject?: boolean;
22
22
  strict?: boolean;
23
- addPlugin?: boolean;
24
23
  useProjectJson?: boolean;
25
24
  port?: number;
26
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/web",
3
- "version": "24.0.0-beta.2",
3
+ "version": "24.0.0-beta.4",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -79,20 +79,20 @@
79
79
  "http-server": "^14.1.0",
80
80
  "picocolors": "^1.1.0",
81
81
  "tslib": "^2.3.0",
82
- "@nx/devkit": "24.0.0-beta.2",
83
- "@nx/js": "24.0.0-beta.2"
82
+ "@nx/devkit": "24.0.0-beta.4",
83
+ "@nx/js": "24.0.0-beta.4"
84
84
  },
85
85
  "devDependencies": {
86
- "nx": "24.0.0-beta.2",
87
- "@nx/vitest": "24.0.0-beta.2"
86
+ "nx": "24.0.0-beta.4",
87
+ "@nx/vitest": "24.0.0-beta.4"
88
88
  },
89
89
  "peerDependencies": {
90
- "@nx/cypress": "24.0.0-beta.2",
91
- "@nx/eslint": "24.0.0-beta.2",
92
- "@nx/jest": "24.0.0-beta.2",
93
- "@nx/playwright": "24.0.0-beta.2",
94
- "@nx/vite": "24.0.0-beta.2",
95
- "@nx/webpack": "24.0.0-beta.2"
90
+ "@nx/cypress": "24.0.0-beta.4",
91
+ "@nx/eslint": "24.0.0-beta.4",
92
+ "@nx/jest": "24.0.0-beta.4",
93
+ "@nx/playwright": "24.0.0-beta.4",
94
+ "@nx/vite": "24.0.0-beta.4",
95
+ "@nx/webpack": "24.0.0-beta.4"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@nx/cypress": {