@nx/web 23.2.0-beta.0 → 23.2.0-beta.10

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.
@@ -8,9 +8,6 @@ const pc = tslib_1.__importStar(require("picocolors"));
8
8
  const devkit_1 = require("@nx/devkit");
9
9
  const fs_1 = require("fs");
10
10
  const path_1 = require("path");
11
- const package_json_1 = require("nx/src/utils/package-json");
12
- const client_1 = require("nx/src/daemon/client/client");
13
- const utils_1 = require("nx/src/tasks-runner/utils");
14
11
  const internal_2 = require("@nx/js/internal");
15
12
  const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
16
13
  function getHttpServerArgs(options) {
@@ -79,7 +76,7 @@ function getBuildTargetOutputPath(options, context) {
79
76
  const buildTarget = project.data.targets[target.target];
80
77
  outputPath = buildTarget.outputs?.[0];
81
78
  if (outputPath) {
82
- outputPath = (0, utils_1.interpolate)(outputPath, {
79
+ outputPath = (0, internal_1.interpolate)(outputPath, {
83
80
  projectName: project.data.name,
84
81
  projectRoot: project.data.root,
85
82
  });
@@ -96,7 +93,7 @@ function getBuildTargetOutputPath(options, context) {
96
93
  return outputPath;
97
94
  }
98
95
  function createFileWatcher(project, changeHandler) {
99
- return client_1.daemonClient.registerFileWatcher({
96
+ return internal_1.daemonClient.registerFileWatcher({
100
97
  watchProjects: project ? [project] : 'all',
101
98
  includeGlobalWorkspaceFiles: true,
102
99
  includeDependencies: true,
@@ -159,12 +156,12 @@ async function* fileServerExecutor(options, context) {
159
156
  }
160
157
  }
161
158
  };
162
- if (!client_1.daemonClient.enabled() && options.watch) {
159
+ if (!internal_1.daemonClient.enabled() && options.watch) {
163
160
  devkit_1.output.warn({
164
161
  title: 'Nx Daemon is not enabled. Static server is not watching for changes.',
165
162
  });
166
163
  }
167
- if (client_1.daemonClient.enabled() && options.watch) {
164
+ if (internal_1.daemonClient.enabled() && options.watch) {
168
165
  disposeWatch = await createFileWatcher(context.projectName, run);
169
166
  }
170
167
  // perform initial run
@@ -182,7 +179,7 @@ async function* fileServerExecutor(options, context) {
182
179
  options.proxyUrl ??= `http${options.ssl ? 's' : ''}://localhost:${port}?`;
183
180
  }
184
181
  const args = getHttpServerArgs(options);
185
- const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
182
+ const { path: pathToHttpServerPkgJson, packageJson } = (0, internal_1.readModulePackageJson)('http-server', module.paths);
186
183
  const pathToHttpServerBin = packageJson.bin['http-server'];
187
184
  const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
188
185
  // detect port as close to when used to prevent port being used by another process
@@ -201,6 +201,7 @@ async function applicationGeneratorInternal(host, schema) {
201
201
  js: false,
202
202
  skipFormat: true,
203
203
  platform: 'web',
204
+ formatter: options.formatter,
204
205
  });
205
206
  tasks.push(jsInitTask);
206
207
  const webTask = await (0, init_1.webInitGenerator)(host, {
@@ -213,8 +214,21 @@ async function applicationGeneratorInternal(host, schema) {
213
214
  await setupBundler(host, options);
214
215
  }
215
216
  createApplicationFiles(host, options);
217
+ let enableTypedLinting = false;
218
+ if (options.linter !== 'eslint') {
219
+ tasks.push(await (0, internal_2.addLintingToProject)(host, {
220
+ linter: options.linter,
221
+ project: options.projectName,
222
+ unitTestRunner: options.unitTestRunner,
223
+ addPlugin: options.addPlugin,
224
+ }));
225
+ }
216
226
  if (options.linter === 'eslint') {
217
227
  const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
228
+ // CommonJS `require` instead of dynamic ESM `import`: `ensurePackage`
229
+ // exposes the temp install via `Module._initPaths`, which ESM ignores.
230
+ const { isTypedLintingEnabled, addIgnoresToLintConfig, } = require('@nx/eslint/internal');
231
+ enableTypedLinting = isTypedLintingEnabled(options);
218
232
  const lintTask = await lintProjectGenerator(host, {
219
233
  linter: options.linter,
220
234
  project: options.projectName,
@@ -223,15 +237,12 @@ async function applicationGeneratorInternal(host, schema) {
223
237
  ],
224
238
  unitTestRunner: options.unitTestRunner,
225
239
  skipFormat: true,
226
- setParserOptionsProject: options.setParserOptionsProject,
240
+ enableTypedLinting,
227
241
  addPlugin: options.addPlugin,
228
242
  });
229
243
  tasks.push(lintTask);
230
244
  // Add out-tsc ignore pattern when using TS solution setup
231
245
  if (options.isUsingTsSolutionConfig) {
232
- // CommonJS `require` instead of dynamic ESM `import` — `ensurePackage`
233
- // exposes the temp install via `Module._initPaths`, which ESM ignores.
234
- const { addIgnoresToLintConfig, } = require('@nx/eslint/internal');
235
246
  addIgnoresToLintConfig(host, options.appProjectRoot, ['**/out-tsc']);
236
247
  }
237
248
  }
@@ -263,7 +274,7 @@ async function applicationGeneratorInternal(host, schema) {
263
274
  if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
264
275
  const { createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
265
276
  (0, devkit_1.ensurePackage)('@nx/vitest', versions_1.nxVersion);
266
- // CommonJS `require` instead of dynamic ESM `import` `ensurePackage`
277
+ // CommonJS `require` instead of dynamic ESM `import`: `ensurePackage`
267
278
  // exposes the temp install via `Module._initPaths`, which ESM ignores.
268
279
  const { configurationGenerator, } = require('@nx/vitest/generators');
269
280
  const vitestTask = await configurationGenerator(host, {
@@ -351,6 +362,7 @@ async function applicationGeneratorInternal(host, schema) {
351
362
  baseUrl: e2eWebServerInfo.e2eWebServerAddress,
352
363
  directory: 'src',
353
364
  skipFormat: true,
365
+ enableTypedLinting,
354
366
  webServerCommands: {
355
367
  default: e2eWebServerInfo.e2eWebServerCommand,
356
368
  production: e2eWebServerInfo.e2eCiWebServerCommand,
@@ -392,7 +404,7 @@ async function applicationGeneratorInternal(host, schema) {
392
404
  directory: 'src',
393
405
  js: false,
394
406
  linter: options.linter,
395
- setParserOptionsProject: options.setParserOptionsProject,
407
+ enableTypedLinting,
396
408
  webServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
397
409
  webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
398
410
  addPlugin: options.addPlugin,
@@ -404,7 +416,9 @@ async function applicationGeneratorInternal(host, schema) {
404
416
  const jestTask = await configurationGenerator(host, {
405
417
  project: options.projectName,
406
418
  skipSerializers: true,
407
- setupFile: 'web-components',
419
+ // No setup file: the `web-components` one only ever held the
420
+ // `document-register-element` polyfill, which is long gone.
421
+ setupFile: 'none',
408
422
  compiler: options.compiler,
409
423
  skipFormat: true,
410
424
  addPlugin: options.addPlugin,
@@ -464,7 +478,7 @@ async function normalizeOptions(host, options) {
464
478
  ? options.tags.split(',').map((s) => s.trim())
465
479
  : [];
466
480
  options.style = options.style || 'css';
467
- options.linter = options.linter || 'eslint';
481
+ options.linter = await (0, internal_2.normalizeLinterOption)(host, options.linter);
468
482
  options.unitTestRunner = options.unitTestRunner || 'jest';
469
483
  options.e2eTestRunner = options.e2eTestRunner || 'playwright';
470
484
  return {
@@ -1,4 +1,4 @@
1
- import type { Linter, LinterType } from '@nx/eslint';
1
+ import type { LinterType } from '@nx/js';
2
2
 
3
3
  export interface Schema {
4
4
  directory: string;
@@ -12,7 +12,12 @@ export interface Schema {
12
12
  unitTestRunner?: 'jest' | 'vitest' | 'none';
13
13
  inSourceTests?: boolean;
14
14
  e2eTestRunner?: 'cypress' | 'playwright' | 'none';
15
- linter?: Linter | LinterType;
15
+ linter?: LinterType;
16
+ formatter?: 'none' | 'prettier' | 'oxfmt';
17
+ enableTypedLinting?: boolean;
18
+ /**
19
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
20
+ */
16
21
  setParserOptionsProject?: boolean;
17
22
  strict?: boolean;
18
23
  addPlugin?: boolean;
@@ -57,11 +57,14 @@
57
57
  "x-priority": "important"
58
58
  },
59
59
  "linter": {
60
- "description": "The tool to use for running lint checks.",
60
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
61
61
  "type": "string",
62
- "enum": ["eslint", "none"],
63
- "default": "none",
64
- "x-prompt": "Which linter would you like to use?"
62
+ "enum": ["eslint", "oxlint", "none"]
63
+ },
64
+ "formatter": {
65
+ "description": "The tool to use for code formatting.",
66
+ "type": "string",
67
+ "enum": ["none", "prettier", "oxfmt"]
65
68
  },
66
69
  "skipFormat": {
67
70
  "description": "Skip formatting files",
@@ -92,11 +95,17 @@
92
95
  "type": "string",
93
96
  "description": "Add tags to the application (used for linting)"
94
97
  },
95
- "setParserOptionsProject": {
98
+ "enableTypedLinting": {
96
99
  "type": "boolean",
97
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
100
+ "description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
98
101
  "default": false
99
102
  },
103
+ "setParserOptionsProject": {
104
+ "type": "boolean",
105
+ "description": "Deprecated alias for `enableTypedLinting`.",
106
+ "default": false,
107
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
108
+ },
100
109
  "strict": {
101
110
  "type": "boolean",
102
111
  "description": "Creates an application with strict mode and strict type checking.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/web",
3
- "version": "23.2.0-beta.0",
3
+ "version": "23.2.0-beta.10",
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": "23.2.0-beta.0",
83
- "@nx/js": "23.2.0-beta.0"
82
+ "@nx/devkit": "23.2.0-beta.10",
83
+ "@nx/js": "23.2.0-beta.10"
84
84
  },
85
85
  "devDependencies": {
86
- "nx": "23.2.0-beta.0",
87
- "@nx/vitest": "23.2.0-beta.0"
86
+ "@nx/vitest": "23.2.0-beta.10",
87
+ "nx": "23.2.0-beta.10"
88
88
  },
89
89
  "peerDependencies": {
90
- "@nx/cypress": "23.2.0-beta.0",
91
- "@nx/jest": "23.2.0-beta.0",
92
- "@nx/vite": "23.2.0-beta.0",
93
- "@nx/webpack": "23.2.0-beta.0",
94
- "@nx/playwright": "23.2.0-beta.0",
95
- "@nx/eslint": "23.2.0-beta.0"
90
+ "@nx/cypress": "23.2.0-beta.10",
91
+ "@nx/eslint": "23.2.0-beta.10",
92
+ "@nx/jest": "23.2.0-beta.10",
93
+ "@nx/webpack": "23.2.0-beta.10",
94
+ "@nx/vite": "23.2.0-beta.10",
95
+ "@nx/playwright": "23.2.0-beta.10"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@nx/cypress": {