@nx/angular 18.1.0-beta.0 → 18.1.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.
Files changed (79) hide show
  1. package/executors.d.ts +1 -0
  2. package/executors.js +1 -0
  3. package/executors.json +5 -0
  4. package/migrations.json +88 -0
  5. package/package.json +12 -14
  6. package/src/builders/dev-server/dev-server.impl.js +2 -38
  7. package/src/builders/dev-server/lib/validate-options.js +4 -0
  8. package/src/builders/dev-server/schema.d.ts +1 -0
  9. package/src/builders/dev-server/schema.json +18 -0
  10. package/src/executors/application/application.impl.js +3 -3
  11. package/src/executors/application/schema.json +12 -0
  12. package/src/executors/application/utils/validate-options.js +31 -23
  13. package/src/executors/extract-i18n/extract-i18n.impl.d.ts +3 -0
  14. package/src/executors/extract-i18n/extract-i18n.impl.js +43 -0
  15. package/src/executors/extract-i18n/schema.d.ts +8 -0
  16. package/src/executors/extract-i18n/schema.json +45 -0
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +4 -2
  18. package/src/executors/module-federation-dev-server/schema.json +1 -1
  19. package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +2 -2
  20. package/src/executors/utilities/ng-packagr/stylesheet-processor.js +11 -2
  21. package/src/executors/utilities/patch-builder-context.d.ts +3 -0
  22. package/src/executors/utilities/patch-builder-context.js +41 -0
  23. package/src/generators/add-linting/add-linting.d.ts +1 -1
  24. package/src/generators/add-linting/add-linting.js +8 -12
  25. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.d.ts +2 -2
  26. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.js +9 -5
  27. package/src/generators/add-linting/lib/buildable-project.d.ts +2 -0
  28. package/src/generators/add-linting/lib/buildable-project.js +9 -0
  29. package/src/generators/add-linting/schema.d.ts +0 -1
  30. package/src/generators/application/application.js +0 -1
  31. package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -0
  32. package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +1 -1
  33. package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +1 -1
  34. package/src/generators/application/lib/add-e2e.js +10 -6
  35. package/src/generators/application/lib/add-linting.js +0 -1
  36. package/src/generators/application/lib/add-unit-test-runner.js +0 -1
  37. package/src/generators/application/lib/create-files.js +9 -10
  38. package/src/generators/application/lib/normalize-options.js +1 -5
  39. package/src/generators/application/lib/update-editor-tsconfig.d.ts +1 -1
  40. package/src/generators/application/lib/update-editor-tsconfig.js +11 -14
  41. package/src/generators/application/schema.d.ts +0 -1
  42. package/src/generators/application/schema.json +1 -0
  43. package/src/generators/component/lib/normalize-options.js +2 -2
  44. package/src/generators/component-test/component-test.js +4 -2
  45. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +16 -11
  46. package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  47. package/src/generators/directive/lib/normalize-options.js +2 -1
  48. package/src/generators/library/lib/add-project.js +23 -24
  49. package/src/generators/library/lib/normalize-options.js +1 -5
  50. package/src/generators/library/lib/update-tsconfig.js +3 -3
  51. package/src/generators/library/schema.d.ts +1 -0
  52. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +30 -23
  53. package/src/generators/ng-add/utilities/workspace.js +2 -4
  54. package/src/generators/setup-mf/lib/add-cypress-workaround.js +14 -6
  55. package/src/generators/setup-mf/lib/normalize-options.js +1 -1
  56. package/src/generators/storybook-configuration/lib/generate-stories.js +4 -2
  57. package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +2 -0
  58. package/src/generators/storybook-configuration/storybook-configuration.js +5 -0
  59. package/src/generators/utils/add-jest.d.ts +0 -1
  60. package/src/generators/utils/add-jest.js +4 -3
  61. package/src/generators/utils/add-mf-env-to-inputs.js +4 -1
  62. package/src/generators/utils/project.d.ts +0 -1
  63. package/src/generators/utils/project.js +2 -29
  64. package/src/generators/utils/selector.d.ts +2 -2
  65. package/src/generators/utils/selector.js +11 -4
  66. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.d.ts +2 -0
  67. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.js +23 -0
  68. package/src/generators/utils/update-project-root-tsconfig.d.ts +3 -0
  69. package/src/generators/utils/update-project-root-tsconfig.js +26 -0
  70. package/src/migrations/update-18-1-0/update-angular-cli.d.ts +3 -0
  71. package/src/migrations/update-18-1-0/update-angular-cli.js +23 -0
  72. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
  73. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
  74. package/src/utils/mf/with-module-federation-ssr.js +3 -0
  75. package/src/utils/mf/with-module-federation.js +3 -0
  76. package/src/utils/versions.d.ts +4 -4
  77. package/src/utils/versions.js +4 -4
  78. package/src/generators/utils/create-ts-config.d.ts +0 -9
  79. package/src/generators/utils/create-ts-config.js +0 -34
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.E2eMigrator = void 0;
4
- const cypress_1 = require("@nx/cypress");
5
- const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
6
- const cypress_version_1 = require("@nx/cypress/src/utils/cypress-version");
7
4
  const devkit_1 = require("@nx/devkit");
8
5
  const eslint_1 = require("@nx/eslint");
9
6
  const js_1 = require("@nx/js");
7
+ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
10
8
  const path_1 = require("path");
11
- const typescript_1 = require("typescript");
12
9
  const file_change_recorder_1 = require("../../../../utils/file-change-recorder");
10
+ const versions_1 = require("../../../../utils/versions");
13
11
  const project_migrator_1 = require("./project.migrator");
14
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
15
12
  const supportedTargets = {
16
13
  e2e: {
17
14
  acceptMultipleDefinitions: true,
@@ -175,7 +172,9 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
175
172
  };
176
173
  }
177
174
  else if (this.isCypressE2eProject()) {
178
- this.cypressInstalledVersion = (0, cypress_version_1.installedCypressVersion)();
175
+ (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
176
+ const { installedCypressVersion, } = require('@nx/cypress/src/utils/cypress-version');
177
+ this.cypressInstalledVersion = installedCypressVersion();
179
178
  this.project = {
180
179
  ...this.project,
181
180
  name,
@@ -235,14 +234,18 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
235
234
  tags: [],
236
235
  implicitDependencies: [this.appName],
237
236
  });
238
- await (0, cypress_1.configurationGenerator)(this.tree, {
237
+ const nxJson = (0, devkit_1.readNxJson)(this.tree) ?? {};
238
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
239
+ nxJson.useInferencePlugins !== false;
240
+ const { configurationGenerator } = await Promise.resolve().then(() => require('@nx/cypress'));
241
+ await configurationGenerator(this.tree, {
239
242
  project: this.project.name,
240
243
  linter: this.isProjectUsingEsLint ? eslint_1.Linter.EsLint : eslint_1.Linter.None,
241
244
  skipFormat: true,
242
245
  // any target would do, we replace it later with the target existing in the project being migrated
243
246
  devServerTarget: `${this.appName}:serve`,
244
247
  baseUrl: 'http://localhost:4200',
245
- addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
248
+ addPlugin,
246
249
  });
247
250
  const cypressConfigFilePath = this.updateOrCreateCypressConfigFile(oldCypressConfigFilePath);
248
251
  this.updateCypressProjectConfiguration(cypressConfigFilePath);
@@ -363,9 +366,10 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
363
366
  : undefined;
364
367
  }
365
368
  updateCypress10ConfigFile(configFilePath) {
366
- (0, ensure_typescript_1.ensureTypescript)();
369
+ const { isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
367
370
  const { tsquery } = require('@phenomnomnominal/tsquery');
368
- this.cypressPreset = (0, cypress_preset_1.nxE2EPreset)(configFilePath);
371
+ const { nxE2EPreset } = require('@nx/cypress/plugins/cypress-preset');
372
+ this.cypressPreset = nxE2EPreset(configFilePath);
369
373
  const fileContent = this.tree.read(configFilePath, 'utf-8');
370
374
  let sourceFile = tsquery.ast(fileContent);
371
375
  const recorder = new file_change_recorder_1.FileChangeRecorder(this.tree, configFilePath);
@@ -378,15 +382,15 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
378
382
  let componentNode;
379
383
  const globalConfig = {};
380
384
  defineConfigExpression.forEachChild((node) => {
381
- if ((0, typescript_1.isPropertyAssignment)(node) && node.name.getText() === 'component') {
385
+ if (isPropertyAssignment(node) && node.name.getText() === 'component') {
382
386
  componentNode = node;
383
387
  return;
384
388
  }
385
- if ((0, typescript_1.isPropertyAssignment)(node) && node.name.getText() === 'e2e') {
389
+ if (isPropertyAssignment(node) && node.name.getText() === 'e2e') {
386
390
  e2eNode = node;
387
391
  return;
388
392
  }
389
- if ((0, typescript_1.isPropertyAssignment)(node)) {
393
+ if (isPropertyAssignment(node)) {
390
394
  this.updateCypressConfigNodeValue(recorder, node, globalConfig);
391
395
  }
392
396
  });
@@ -398,14 +402,15 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
398
402
  if (!componentNode) {
399
403
  return;
400
404
  }
401
- if (!(0, typescript_1.isObjectLiteralExpression)(componentNode.initializer)) {
405
+ const { isObjectLiteralExpression, isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
406
+ if (!isObjectLiteralExpression(componentNode.initializer)) {
402
407
  this.logger.warn('The automatic migration only supports having an object literal in the "component" option of the Cypress configuration. ' +
403
408
  `The configuration won't be updated. Please make sure to update any paths you may have in the "component" option ` +
404
409
  'manually to point to the new location.');
405
410
  return;
406
411
  }
407
412
  componentNode.initializer.properties.forEach((node) => {
408
- if ((0, typescript_1.isPropertyAssignment)(node)) {
413
+ if (isPropertyAssignment(node)) {
409
414
  this.updateCypressConfigNodeValue(recorder, node);
410
415
  }
411
416
  });
@@ -428,7 +433,8 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
428
433
  recorder.insertRight(defineConfigNode.getStart() + 1, e2eAssignment);
429
434
  }
430
435
  else {
431
- if (!(0, typescript_1.isObjectLiteralExpression)(e2eNode.initializer)) {
436
+ const { isObjectLiteralExpression, isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
437
+ if (!isObjectLiteralExpression(e2eNode.initializer)) {
432
438
  this.logger.warn('The automatic migration only supports having an object literal in the "e2e" option of the Cypress configuration. ' +
433
439
  `The configuration won't be updated. Please make sure to update any paths you might have in the "e2e" option ` +
434
440
  'manually to point to the new location.');
@@ -436,7 +442,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
436
442
  }
437
443
  recorder.insertRight(e2eNode.initializer.getStart() + 1, presetSpreadAssignment);
438
444
  e2eNode.initializer.properties.forEach((node) => {
439
- if (!(0, typescript_1.isPropertyAssignment)(node)) {
445
+ if (!isPropertyAssignment(node)) {
440
446
  return;
441
447
  }
442
448
  let change = { type: 'ignore' };
@@ -515,7 +521,8 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
515
521
  }
516
522
  }
517
523
  isValidPathLikePropertyWithStringLiteralValue(node, properties) {
518
- if (!(0, typescript_1.isPropertyAssignment)(node)) {
524
+ const { isPropertyAssignment, isStringLiteralLike, isTemplateExpression, SyntaxKind, } = (0, ensure_typescript_1.ensureTypescript)();
525
+ if (!isPropertyAssignment(node)) {
519
526
  // TODO(leo): handle more scenarios (spread assignments, etc)
520
527
  return false;
521
528
  }
@@ -523,13 +530,13 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
523
530
  if (!property) {
524
531
  return false;
525
532
  }
526
- if (node.initializer.kind === typescript_1.SyntaxKind.UndefinedKeyword ||
527
- node.initializer.kind === typescript_1.SyntaxKind.NullKeyword ||
528
- node.initializer.kind === typescript_1.SyntaxKind.FalseKeyword) {
533
+ if (node.initializer.kind === SyntaxKind.UndefinedKeyword ||
534
+ node.initializer.kind === SyntaxKind.NullKeyword ||
535
+ node.initializer.kind === SyntaxKind.FalseKeyword) {
529
536
  return false;
530
537
  }
531
- if (!(0, typescript_1.isStringLiteralLike)(node.initializer)) {
532
- if ((0, typescript_1.isTemplateExpression)(node.initializer)) {
538
+ if (!isStringLiteralLike(node.initializer)) {
539
+ if (isTemplateExpression(node.initializer)) {
533
540
  this.logger.warn(`The "${node.name.getText()}" in the Cypress configuration file is set to a template expression ("${node.initializer.getText()}"). ` +
534
541
  `This is not supported by the automatic migration and its value won't be automatically migrated. ` +
535
542
  `Please make sure to update its value to match the new location if needed.`);
@@ -29,9 +29,7 @@ exports.validateWorkspace = validateWorkspace;
29
29
  function createNxJson(tree, options, defaultProject) {
30
30
  const targets = getWorkspaceCommonTargets(tree);
31
31
  (0, devkit_1.writeJson)(tree, 'nx.json', {
32
- affected: {
33
- defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
34
- },
32
+ defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
35
33
  namedInputs: {
36
34
  sharedGlobals: [],
37
35
  default: ['{projectRoot}/**/*', 'sharedGlobals'],
@@ -151,7 +149,7 @@ function updatePackageJson(tree) {
151
149
  exports.updatePackageJson = updatePackageJson;
152
150
  async function updateRootEsLintConfig(tree, existingEsLintConfig, unitTestRunner) {
153
151
  await (0, eslint_1.lintInitGenerator)(tree, {
154
- addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
152
+ addPlugin: false,
155
153
  });
156
154
  if (!existingEsLintConfig) {
157
155
  // There was no eslint config in the root, so we set it up and use it as-is
@@ -4,7 +4,6 @@
4
4
  // is attached to the index.html with type=module
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addCypressOnErrorWorkaround = void 0;
7
- const config_1 = require("@nx/cypress/src/utils/config");
8
7
  const devkit_1 = require("@nx/devkit");
9
8
  function addCypressOnErrorWorkaround(tree, schema) {
10
9
  if (!schema.e2eProjectName) {
@@ -23,11 +22,20 @@ function addCypressOnErrorWorkaround(tree, schema) {
23
22
  `);
24
23
  return;
25
24
  }
26
- if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress' &&
27
- !(0, devkit_1.glob)(tree, [`${e2eProject.root}/${config_1.CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
28
- .length) {
29
- // Not a cypress e2e project, skip
30
- return;
25
+ if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress') {
26
+ try {
27
+ // don't ensure package is installed, if it's not installed, we don't need to add the workaround
28
+ const { CYPRESS_CONFIG_FILE_NAME_PATTERN, } = require('@nx/cypress/src/utils/config');
29
+ if (!(0, devkit_1.glob)(tree, [`${e2eProject.root}/${CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
30
+ .length) {
31
+ // Not a cypress e2e project, skip
32
+ return;
33
+ }
34
+ }
35
+ catch {
36
+ // assume cypress is not installed
37
+ return;
38
+ }
31
39
  }
32
40
  const commandToAdd = `Cypress.on('uncaught:exception', err => {
33
41
  if (err.message.includes(\`Cannot use 'import.meta' outside a module\`)) {
@@ -7,7 +7,7 @@ function normalizeOptions(tree, options) {
7
7
  ...options,
8
8
  typescriptConfiguration: options.typescriptConfiguration ?? true,
9
9
  federationType: options.federationType ?? 'static',
10
- prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName),
10
+ prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName) ?? 'app',
11
11
  standalone: options.standalone ?? true,
12
12
  };
13
13
  }
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateStories = void 0;
4
- const project_name_1 = require("@nx/cypress/src/utils/project-name");
5
4
  const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../../utils/versions");
6
6
  const stories_1 = require("../../stories/stories");
7
7
  async function generateStories(tree, options) {
8
8
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
9
- const e2eProjectName = (0, project_name_1.getE2eProjectName)(options.project, project.root, options.cypressDirectory);
9
+ (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
10
+ const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
11
+ const e2eProjectName = getE2eProjectName(options.project, project.root, options.cypressDirectory);
10
12
  await (0, stories_1.angularStoriesGenerator)(tree, {
11
13
  name: options.project,
12
14
  generateCypressSpecs: options.configureCypress && options.generateCypressSpecs,
@@ -15,6 +15,8 @@ async function generateStorybookConfiguration(tree, options) {
15
15
  interactionTests: options.interactionTests,
16
16
  configureStaticServe: options.configureStaticServe,
17
17
  skipFormat: true,
18
+ addPlugin: false,
19
+ addExplicitTargets: true,
18
20
  });
19
21
  }
20
22
  exports.generateStorybookConfiguration = generateStorybookConfiguration;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storybookConfigurationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app-editor-tsconfig-excluded-files");
5
6
  const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-storybook-version");
6
7
  const generate_stories_1 = require("./lib/generate-stories");
7
8
  const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
@@ -22,6 +23,10 @@ async function storybookConfigurationGenerator(tree, options) {
22
23
  skipFormat: true,
23
24
  });
24
25
  }
26
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
27
+ if (project.projectType === 'application') {
28
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, project);
29
+ }
25
30
  if (!options.skipFormat) {
26
31
  await (0, devkit_1.formatFiles)(tree);
27
32
  }
@@ -4,6 +4,5 @@ export type AddJestOptions = {
4
4
  projectRoot: string;
5
5
  skipPackageJson: boolean;
6
6
  strict: boolean;
7
- addPlugin?: boolean;
8
7
  };
9
8
  export declare function addJest(tree: Tree, options: AddJestOptions): Promise<void>;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const jest_1 = require("@nx/jest");
6
5
  const versions_1 = require("../../utils/versions");
7
6
  const version_utils_1 = require("./version-utils");
8
7
  async function addJest(tree, options) {
@@ -10,14 +9,16 @@ async function addJest(tree, options) {
10
9
  process.env.npm_config_legacy_peer_deps ??= 'true';
11
10
  (0, version_utils_1.addDependenciesToPackageJsonIfDontExist)(tree, {}, { 'jest-preset-angular': versions_1.jestPresetAngularVersion });
12
11
  }
13
- await (0, jest_1.configurationGenerator)(tree, {
12
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
13
+ await configurationGenerator(tree, {
14
14
  project: options.name,
15
15
  setupFile: 'angular',
16
16
  supportTsx: false,
17
17
  skipSerializers: false,
18
18
  skipPackageJson: options.skipPackageJson,
19
19
  skipFormat: true,
20
- addPlugin: options.addPlugin,
20
+ addPlugin: false,
21
+ addExplicitTargets: true,
21
22
  });
22
23
  const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'test-setup.ts');
23
24
  if (options.strict && tree.exists(setupFile)) {
@@ -8,7 +8,10 @@ function addMfEnvToTargetDefaultInputs(tree) {
8
8
  const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
9
9
  nxJson.targetDefaults ??= {};
10
10
  nxJson.targetDefaults[webpackExecutor] ??= {};
11
- nxJson.targetDefaults[webpackExecutor].inputs ??= [];
11
+ nxJson.targetDefaults[webpackExecutor].inputs ??= [
12
+ 'production',
13
+ '^production',
14
+ ];
12
15
  let mfEnvVarExists = false;
13
16
  for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
14
17
  if (typeof input === 'object' && input['env'] === mfEnvVar) {
@@ -1,3 +1,2 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- export declare function normalizeNewProjectPrefix(prefix: string | undefined, npmScope: string | undefined, fallbackPrefix: string): string;
3
2
  export declare function getProjectPrefix(tree: Tree, project: string): string | undefined;
@@ -1,35 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProjectPrefix = exports.normalizeNewProjectPrefix = void 0;
3
+ exports.getProjectPrefix = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
6
- function normalizeNewProjectPrefix(prefix, npmScope, fallbackPrefix) {
7
- // Prefix needs to be a valid html selector, if npmScope it's not valid, we don't default
8
- // to it and let it fall through to the Angular schematic to handle it
9
- // https://github.com/angular/angular-cli/blob/aa9f0528f174e856a4923cb24861fdf6e6f96b48/packages/schematics/angular/component/index.ts#L64
10
- const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
11
- if (prefix) {
12
- if (!htmlSelectorRegex.test(prefix)) {
13
- throw new Error('The provided "prefix" is invalid. The prefix must start with a letter, and must contain only alphanumeric characters or dashes.');
14
- }
15
- return prefix;
16
- }
17
- if (npmScope && !htmlSelectorRegex.test(npmScope)) {
18
- throw new Error(`The "--prefix" option was not provided, therefore attempted to use the "npmScope" defined in "nx.json" to set the application's selector prefix, but it is invalid.
19
-
20
- There are two options that can be followed to resolve this issue:
21
- - Pass a valid "--prefix" option.
22
- - Update the "npmScope" in "nx.json" (Note: this can be an involved process, as other libraries and applications may need to be updated to match the new scope).
23
-
24
- If you encountered this error when creating a new Nx Workspace, the workspace name or "npmScope" is invalid to use as the selector prefix for the application being generated.
25
-
26
- Valid selector prefixes must start with a letter, and must contain only alphanumeric characters or dashes.`);
27
- }
28
- return npmScope || fallbackPrefix;
29
- }
30
- exports.normalizeNewProjectPrefix = normalizeNewProjectPrefix;
31
5
  function getProjectPrefix(tree, project) {
32
- return ((0, devkit_1.readProjectConfiguration)(tree, project)
33
- .prefix ?? (0, get_npm_scope_1.getNpmScope)(tree));
6
+ return (0, devkit_1.readProjectConfiguration)(tree, project).prefix;
34
7
  }
35
8
  exports.getProjectPrefix = getProjectPrefix;
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
2
1
  import { names } from '@nx/devkit';
3
- export declare function buildSelector(tree: Tree, name: string, prefix: string | undefined, projectPrefix: string | undefined, casing: keyof Pick<ReturnType<typeof names>, 'fileName' | 'propertyName'>): string;
2
+ export declare function buildSelector(name: string, prefix: string | undefined, projectPrefix: string | undefined, casing: keyof Pick<ReturnType<typeof names>, 'fileName' | 'propertyName'>): string;
3
+ export declare function validateHtmlSelector(selector: string): void;
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSelector = void 0;
3
+ exports.validateHtmlSelector = exports.buildSelector = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
6
- function buildSelector(tree, name, prefix, projectPrefix, casing) {
5
+ function buildSelector(name, prefix, projectPrefix, casing) {
7
6
  let selector = name;
8
- prefix ??= projectPrefix ?? (0, get_npm_scope_1.getNpmScope)(tree);
7
+ prefix ??= projectPrefix;
9
8
  if (prefix) {
10
9
  selector = `${prefix}-${selector}`;
11
10
  }
12
11
  return (0, devkit_1.names)(selector)[casing];
13
12
  }
14
13
  exports.buildSelector = buildSelector;
14
+ // https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/utility/validation.ts#L11-L14
15
+ const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
16
+ function validateHtmlSelector(selector) {
17
+ if (selector && !htmlSelectorRegex.test(selector)) {
18
+ throw new Error(`The selector "${selector}" is invalid.`);
19
+ }
20
+ }
21
+ exports.validateHtmlSelector = validateHtmlSelector;
@@ -0,0 +1,2 @@
1
+ import { type ProjectConfiguration, type Tree } from '@nx/devkit';
2
+ export declare function updateAppEditorTsConfigExcludedFiles(tree: Tree, projectConfig: ProjectConfiguration): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAppEditorTsConfigExcludedFiles = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function updateAppEditorTsConfigExcludedFiles(tree, projectConfig) {
6
+ if (projectConfig.projectType !== 'application') {
7
+ return;
8
+ }
9
+ const editorTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.editor.json');
10
+ const appTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.app.json');
11
+ if (!tree.exists(editorTsConfigPath) || !tree.exists(appTsConfigPath)) {
12
+ return;
13
+ }
14
+ const appTsConfig = (0, devkit_1.readJson)(tree, appTsConfigPath);
15
+ (0, devkit_1.updateJson)(tree, editorTsConfigPath, (json) => {
16
+ const exclude = [...(json.exclude ?? []), ...(appTsConfig.exclude ?? [])];
17
+ if (exclude.length) {
18
+ json.exclude = Array.from(new Set(exclude));
19
+ }
20
+ return json;
21
+ });
22
+ }
23
+ exports.updateAppEditorTsConfigExcludedFiles = updateAppEditorTsConfigExcludedFiles;
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export { extractTsConfigBase } from '@nx/js';
3
+ export declare function updateProjectRootTsConfig(host: Tree, projectRoot: string, relativePathToRootTsConfig: string, isRootProject?: boolean): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProjectRootTsConfig = exports.extractTsConfigBase = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ var js_2 = require("@nx/js");
7
+ Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
8
+ function updateProjectRootTsConfig(host, projectRoot, relativePathToRootTsConfig, isRootProject) {
9
+ (0, devkit_1.updateJson)(host, `${projectRoot}/tsconfig.json`, (json) => {
10
+ if (isRootProject) {
11
+ // inline tsconfig.base.json into the project
12
+ json.compileOnSave = false;
13
+ json.compilerOptions = {
14
+ ...js_1.tsConfigBaseOptions,
15
+ ...json.compilerOptions,
16
+ };
17
+ json.exclude = ['node_modules', 'tmp'];
18
+ delete json.extends;
19
+ }
20
+ else {
21
+ json.extends = relativePathToRootTsConfig;
22
+ }
23
+ return json;
24
+ });
25
+ }
26
+ exports.updateProjectRootTsConfig = updateProjectRootTsConfig;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare const angularCliVersion = "~17.2.0";
3
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.angularCliVersion = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ exports.angularCliVersion = '~17.2.0';
6
+ async function default_1(tree) {
7
+ let shouldFormat = false;
8
+ (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
9
+ if (json.devDependencies?.['@angular/cli']) {
10
+ json.devDependencies['@angular/cli'] = exports.angularCliVersion;
11
+ shouldFormat = true;
12
+ }
13
+ else if (json.dependencies?.['@angular/cli']) {
14
+ json.dependencies['@angular/cli'] = exports.angularCliVersion;
15
+ shouldFormat = true;
16
+ }
17
+ return json;
18
+ });
19
+ if (shouldFormat) {
20
+ await (0, devkit_1.formatFiles)(tree);
21
+ }
22
+ }
23
+ exports.default = default_1;
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ async function default_1(tree) {
5
+ if (!isWebpackBrowserUsed(tree)) {
6
+ return;
7
+ }
8
+ ensureTargetDefaultsContainProductionInputs(tree);
9
+ await (0, devkit_1.formatFiles)(tree);
10
+ }
11
+ exports.default = default_1;
12
+ function ensureTargetDefaultsContainProductionInputs(tree) {
13
+ const nxJson = (0, devkit_1.readNxJson)(tree);
14
+ const webpackExecutor = '@nx/angular:webpack-browser';
15
+ const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
16
+ nxJson.targetDefaults[webpackExecutor] ??= {};
17
+ nxJson.targetDefaults[webpackExecutor].inputs ??= [
18
+ 'production',
19
+ '^production',
20
+ { env: mfEnvVar },
21
+ ];
22
+ if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('production')) {
23
+ nxJson.targetDefaults[webpackExecutor].inputs.push('production');
24
+ }
25
+ if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('^production')) {
26
+ nxJson.targetDefaults[webpackExecutor].inputs.push('^production');
27
+ }
28
+ let mfEnvVarExists = false;
29
+ for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
30
+ if (typeof input === 'object' && input['env'] === mfEnvVar) {
31
+ mfEnvVarExists = true;
32
+ break;
33
+ }
34
+ }
35
+ if (!mfEnvVarExists) {
36
+ nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
37
+ }
38
+ (0, devkit_1.updateNxJson)(tree, nxJson);
39
+ }
40
+ function isWebpackBrowserUsed(tree) {
41
+ const projects = (0, devkit_1.getProjects)(tree);
42
+ for (const project of projects.values()) {
43
+ const targets = project.targets || {};
44
+ for (const [_, target] of Object.entries(targets)) {
45
+ if (target.executor === '@nx/angular:webpack-browser' &&
46
+ (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
47
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
48
+ return true;
49
+ }
50
+ }
51
+ }
52
+ return false;
53
+ }
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederationForSSR = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  async function withModuleFederationForSSR(options) {
6
+ if (global.NX_GRAPH_CREATION) {
7
+ return (config) => config;
8
+ }
6
9
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
7
10
  isServer: true,
8
11
  });
@@ -4,6 +4,9 @@ exports.withModuleFederation = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
6
6
  async function withModuleFederation(options) {
7
+ if (global.NX_GRAPH_CREATION) {
8
+ return (config) => config;
9
+ }
7
10
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
8
11
  return (config) => ({
9
12
  ...(config ?? {}),
@@ -1,7 +1,7 @@
1
1
  export declare const nxVersion: any;
2
- export declare const angularVersion = "~17.1.0";
3
- export declare const angularDevkitVersion = "~17.1.0";
4
- export declare const ngPackagrVersion = "~17.1.0";
2
+ export declare const angularVersion = "~17.2.0";
3
+ export declare const angularDevkitVersion = "~17.2.0";
4
+ export declare const ngPackagrVersion = "~17.2.0";
5
5
  export declare const ngrxVersion = "~17.0.0";
6
6
  export declare const rxjsVersion = "~7.8.0";
7
7
  export declare const zoneJsVersion = "~0.14.3";
@@ -19,7 +19,7 @@ export declare const postcssVersion = "^8.4.5";
19
19
  export declare const postcssUrlVersion = "~10.1.3";
20
20
  export declare const autoprefixerVersion = "^10.4.0";
21
21
  export declare const tsNodeVersion = "10.9.1";
22
- export declare const jestPresetAngularVersion = "~13.1.4";
22
+ export declare const jestPresetAngularVersion = "~14.0.3";
23
23
  export declare const typesNodeVersion = "18.16.9";
24
24
  export declare const jasmineMarblesVersion = "^0.9.2";
25
25
  export declare const jsoncEslintParserVersion = "^2.1.0";
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.angularEslintVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.angularVersion = '~17.1.0';
6
- exports.angularDevkitVersion = '~17.1.0';
7
- exports.ngPackagrVersion = '~17.1.0';
5
+ exports.angularVersion = '~17.2.0';
6
+ exports.angularDevkitVersion = '~17.2.0';
7
+ exports.ngPackagrVersion = '~17.2.0';
8
8
  exports.ngrxVersion = '~17.0.0';
9
9
  exports.rxjsVersion = '~7.8.0';
10
10
  exports.zoneJsVersion = '~0.14.3';
@@ -22,7 +22,7 @@ exports.postcssVersion = '^8.4.5';
22
22
  exports.postcssUrlVersion = '~10.1.3';
23
23
  exports.autoprefixerVersion = '^10.4.0';
24
24
  exports.tsNodeVersion = '10.9.1';
25
- exports.jestPresetAngularVersion = '~13.1.4';
25
+ exports.jestPresetAngularVersion = '~14.0.3';
26
26
  exports.typesNodeVersion = '18.16.9';
27
27
  exports.jasmineMarblesVersion = '^0.9.2';
28
28
  exports.jsoncEslintParserVersion = '^2.1.0';
@@ -1,9 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export { extractTsConfigBase } from '@nx/js';
3
- export declare function createTsConfig(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
4
- strict?: boolean;
5
- style?: string;
6
- bundler?: string;
7
- rootProject?: boolean;
8
- esModuleInterop?: boolean;
9
- }, relativePathToRootTsConfig: string): void;