@nx/angular 23.1.0 → 23.1.2

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 (61) hide show
  1. package/dist/src/builders/dev-server/dev-server.impl.js +21 -16
  2. package/dist/src/builders/webpack-browser/webpack-browser.impl.js +15 -12
  3. package/dist/src/builders/webpack-server/webpack-server.impl.js +8 -4
  4. package/dist/src/executors/application/application.impl.js +2 -2
  5. package/dist/src/executors/browser-esbuild/browser-esbuild.impl.js +1 -1
  6. package/dist/src/executors/extract-i18n/extract-i18n.impl.js +4 -4
  7. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +8 -6
  8. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +8 -8
  9. package/dist/src/executors/unit-test/unit-test.impl.js +2 -2
  10. package/dist/src/executors/utilities/builder-package.d.ts +1 -1
  11. package/dist/src/executors/utilities/builder-package.js +10 -4
  12. package/dist/src/generators/add-linting/add-linting.js +18 -7
  13. package/dist/src/generators/add-linting/schema.d.ts +4 -0
  14. package/dist/src/generators/add-linting/schema.json +8 -2
  15. package/dist/src/generators/application/lib/add-e2e.js +3 -2
  16. package/dist/src/generators/application/lib/add-linting.js +2 -1
  17. package/dist/src/generators/application/lib/create-files.js +3 -3
  18. package/dist/src/generators/application/schema.d.ts +4 -0
  19. package/dist/src/generators/application/schema.json +8 -2
  20. package/dist/src/generators/host/host.js +2 -1
  21. package/dist/src/generators/host/schema.d.ts +4 -0
  22. package/dist/src/generators/host/schema.json +8 -2
  23. package/dist/src/generators/library/lib/create-files.js +3 -0
  24. package/dist/src/generators/library/lib/normalized-schema.d.ts +4 -0
  25. package/dist/src/generators/library/library.js +4 -3
  26. package/dist/src/generators/library/schema.d.ts +4 -0
  27. package/dist/src/generators/library/schema.json +8 -2
  28. package/dist/src/generators/ng-add/migrators/projects/lib.migrator.js +1 -2
  29. package/dist/src/generators/ng-add/utilities/format-files-task.js +2 -2
  30. package/dist/src/generators/ng-add/utilities/projects.js +2 -2
  31. package/dist/src/generators/ng-add/utilities/workspace.js +3 -4
  32. package/dist/src/generators/remote/remote.js +4 -3
  33. package/dist/src/generators/remote/schema.d.ts +4 -0
  34. package/dist/src/generators/remote/schema.json +8 -2
  35. package/dist/src/generators/scam-to-standalone/lib/get-component-data-from-ast.d.ts +1 -1
  36. package/dist/src/generators/scam-to-standalone/lib/get-target-project.d.ts +1 -1
  37. package/dist/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.d.ts +1 -1
  38. package/dist/src/generators/setup-mf/lib/generate-config.js +2 -1
  39. package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.js +3 -2
  40. package/dist/src/generators/setup-mf/schema.d.ts +4 -0
  41. package/dist/src/generators/setup-mf/schema.json +8 -2
  42. package/dist/src/generators/setup-mf/setup-mf.js +2 -0
  43. package/dist/src/generators/setup-ssr/lib/add-dependencies.d.ts +1 -1
  44. package/dist/src/generators/setup-ssr/lib/add-dependencies.js +6 -1
  45. package/dist/src/generators/setup-ssr/lib/normalize-options.js +15 -3
  46. package/dist/src/generators/setup-ssr/lib/update-project-config.js +1 -1
  47. package/dist/src/generators/setup-ssr/schema.d.ts +2 -0
  48. package/dist/src/generators/setup-ssr/setup-ssr.js +1 -1
  49. package/dist/src/generators/utils/add-vitest.js +1 -2
  50. package/dist/src/generators/utils/tsconfig-utils.js +2 -7
  51. package/dist/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +2 -3
  52. package/dist/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.js +3 -4
  53. package/dist/src/migrations/update-23-1-0/add-angular-build.md +1 -1
  54. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.d.ts +2 -0
  55. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.js +101 -0
  56. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.md +39 -0
  57. package/dist/src/plugins/plugin.js +2 -4
  58. package/dist/tailwind.d.ts +1 -1
  59. package/dist/tailwind.js +2 -2
  60. package/migrations.json +6 -0
  61. package/package.json +32 -13
@@ -3,20 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDevServerBuilder = executeDevServerBuilder;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const internal_1 = require("@nx/webpack/internal");
7
6
  const fs_1 = require("fs");
8
- const configuration_1 = require("nx/src/config/configuration");
9
- const operators_1 = require("nx/src/project-graph/operators");
10
- const project_graph_1 = require("nx/src/project-graph/project-graph");
11
7
  const path_1 = require("path");
12
8
  const rxjs_1 = require("rxjs");
13
- const operators_2 = require("rxjs/operators");
9
+ const operators_1 = require("rxjs/operators");
14
10
  const builder_package_1 = require("../../executors/utilities/builder-package");
15
11
  const esbuild_extensions_1 = require("../../executors/utilities/esbuild-extensions");
16
12
  const patch_builder_context_1 = require("../../executors/utilities/patch-builder-context");
17
13
  const buildable_libs_1 = require("../utilities/buildable-libs");
18
- const webpack_1 = require("../utilities/webpack");
19
14
  const lib_1 = require("./lib");
15
+ const internal_1 = require("@nx/devkit/internal");
20
16
  function executeDevServerBuilder(rawOptions, context) {
21
17
  (0, lib_1.validateOptions)(rawOptions);
22
18
  process.env.NX_TSCONFIG_PATH = (0, js_1.getRootTsConfigPath)();
@@ -28,10 +24,10 @@ function executeDevServerBuilder(rawOptions, context) {
28
24
  projectName: context.target.project,
29
25
  projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
30
26
  root: context.workspaceRoot,
31
- nxJsonConfiguration: (0, configuration_1.readNxJson)(devkit_1.workspaceRoot),
27
+ nxJsonConfiguration: (0, internal_1.readNxJsonFromDisk)(devkit_1.workspaceRoot),
32
28
  isVerbose: false,
33
29
  });
34
- const browserTargetProjectConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(parsedBuildTarget.project);
30
+ const browserTargetProjectConfiguration = (0, internal_1.readCachedProjectConfiguration)(parsedBuildTarget.project);
35
31
  const buildTarget = browserTargetProjectConfiguration.targets[parsedBuildTarget.target];
36
32
  const buildTargetOptions = {
37
33
  ...buildTarget.options,
@@ -102,32 +98,37 @@ function executeDevServerBuilder(rawOptions, context) {
102
98
  * handle `@nx/angular:*` executors.
103
99
  */
104
100
  (0, patch_builder_context_1.patchBuilderContext)(context, !isUsingWebpackBuilder, parsedBuildTarget);
105
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular-devkit/build-angular');
101
+ (0, builder_package_1.assertPackageIsInstalled)('@angular-devkit/build-angular', '@nx/angular:dev-server');
106
102
  return (0, rxjs_1.combineLatest)([
107
103
  (0, rxjs_1.from)(import('@angular-devkit/build-angular')),
108
104
  (0, rxjs_1.from)((0, esbuild_extensions_1.loadPlugins)(buildTargetOptions.plugins, buildTargetOptions.tsConfig)),
109
105
  (0, rxjs_1.from)((0, esbuild_extensions_1.loadMiddleware)(options.esbuildMiddleware, buildTargetOptions.tsConfig)),
110
106
  (0, rxjs_1.from)(loadIndexHtmlFileTransformer(pathToIndexFileTransformer, buildTargetOptions.tsConfig, context, isUsingWebpackBuilder)),
111
- ]).pipe((0, operators_2.switchMap)(([{ executeDevServerBuilder }, plugins, middleware, indexHtmlTransformer,]) => executeDevServerBuilder(delegateBuilderOptions, context, {
107
+ ]).pipe((0, operators_1.switchMap)(([{ executeDevServerBuilder }, plugins, middleware, indexHtmlTransformer,]) => executeDevServerBuilder(delegateBuilderOptions, context, {
112
108
  webpackConfiguration: isUsingWebpackBuilder
113
109
  ? async (baseWebpackConfig) => {
114
110
  if (!buildLibsFromSource) {
115
111
  const workspaceDependencies = dependencies
116
- .filter((dep) => !(0, operators_1.isNpmProject)(dep.node))
112
+ .filter((dep) => !(0, internal_1.isNpmProject)(dep.node))
117
113
  .map((dep) => dep.node.name);
118
114
  // default for `nx run-many` is --all projects
119
115
  // by passing an empty string for --projects, run-many will default to
120
116
  // run the target for all projects.
121
117
  // This will occur when workspaceDependencies = []
122
118
  if (workspaceDependencies.length > 0) {
123
- baseWebpackConfig.plugins.push(new internal_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${parsedBuildTarget.target} --projects=${workspaceDependencies.join(',')}`, { skipWatchingDeps: !options.watchDependencies }) // TODO(Colum): this can be removed when angular 20.2 is merged
119
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/webpack', '@nx/angular:dev-server');
120
+ const { WebpackNxBuildCoordinationPlugin } = await import('@nx/webpack/internal');
121
+ baseWebpackConfig.plugins.push(new WebpackNxBuildCoordinationPlugin(`nx run-many --target=${parsedBuildTarget.target} --projects=${workspaceDependencies.join(',')}`, { skipWatchingDeps: !options.watchDependencies }) // TODO(Colum): this can be removed when angular 20.2 is merged
124
122
  );
125
123
  }
126
124
  }
127
125
  if (!pathToWebpackConfig) {
128
126
  return baseWebpackConfig;
129
127
  }
130
- return (0, webpack_1.mergeCustomWebpackConfig)(baseWebpackConfig, pathToWebpackConfig, buildTargetOptions, context.target);
128
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/webpack', '@nx/angular:dev-server');
129
+ (0, builder_package_1.assertPackageIsInstalled)('webpack-merge', '@nx/angular:dev-server');
130
+ const { mergeCustomWebpackConfig } = await import('../utilities/webpack.js');
131
+ return mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig, buildTargetOptions, context.target);
131
132
  }
132
133
  : undefined,
133
134
  ...(indexHtmlTransformer
@@ -154,7 +155,11 @@ async function loadIndexHtmlFileTransformer(pathToIndexFileTransformer, tsConfig
154
155
  if (!pathToIndexFileTransformer) {
155
156
  return undefined;
156
157
  }
157
- return isUsingWebpackBuilder
158
- ? (0, webpack_1.resolveIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig, context.target)
159
- : await (0, esbuild_extensions_1.loadIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig);
158
+ if (isUsingWebpackBuilder) {
159
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/webpack', '@nx/angular:dev-server');
160
+ (0, builder_package_1.assertPackageIsInstalled)('webpack-merge', '@nx/angular:dev-server');
161
+ const { resolveIndexHtmlTransformer } = await import('../utilities/webpack.js');
162
+ return resolveIndexHtmlTransformer(pathToIndexFileTransformer, tsConfig, context.target);
163
+ }
164
+ return (0, esbuild_extensions_1.loadIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig);
160
165
  }
@@ -2,16 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeWebpackBrowserBuilder = executeWebpackBrowserBuilder;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const internal_1 = require("@nx/webpack/internal");
6
5
  const fs_1 = require("fs");
7
- const operators_1 = require("nx/src/project-graph/operators");
8
- const utils_1 = require("nx/src/tasks-runner/utils");
9
6
  const path_1 = require("path");
10
7
  const rxjs_1 = require("rxjs");
11
- const operators_2 = require("rxjs/operators");
8
+ const operators_1 = require("rxjs/operators");
12
9
  const builder_package_1 = require("../../executors/utilities/builder-package");
13
10
  const buildable_libs_1 = require("../utilities/buildable-libs");
14
- const webpack_1 = require("../utilities/webpack");
11
+ const internal_1 = require("@nx/devkit/internal");
15
12
  // This is required to ensure that the webpack version used by the Module Federation is the same as the one used by the builders.
16
13
  const Module = require('module');
17
14
  const originalResolveFilename = Module._resolveFilename;
@@ -36,11 +33,12 @@ function shouldSkipInitialTargetRun(projectGraph, project, target) {
36
33
  allTargetNames.add(targetName);
37
34
  }
38
35
  }
39
- const projectDependencyConfigs = (0, utils_1.getDependencyConfigs)({ project, target }, {}, projectGraph, Array.from(allTargetNames));
36
+ const projectDependencyConfigs = (0, internal_1.getDependencyConfigs)({ project, target }, {}, projectGraph, Array.from(allTargetNames));
40
37
  // if the task runner already ran the target, skip the initial run
41
38
  return projectDependencyConfigs.some((d) => d.target === target && d.projects === 'dependencies');
42
39
  }
43
40
  function executeWebpackBrowserBuilder(options, context) {
41
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/webpack', '@nx/angular:webpack-browser');
44
42
  options.buildLibsFromSource ??= true;
45
43
  options.watchDependencies ??= true;
46
44
  const { buildLibsFromSource, customWebpackConfig, indexHtmlTransformer, watchDependencies, ...delegateBuilderOptions } = options;
@@ -64,12 +62,17 @@ function executeWebpackBrowserBuilder(options, context) {
64
62
  dependencies = foundDependencies;
65
63
  delegateBuilderOptions.tsConfig = (0, devkit_1.normalizePath)((0, path_1.relative)(context.workspaceRoot, tsConfigPath));
66
64
  }
67
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular-devkit/build-angular');
68
- return (0, rxjs_1.from)(import('@angular-devkit/build-angular')).pipe((0, operators_2.switchMap)(({ executeBrowserBuilder }) => executeBrowserBuilder(delegateBuilderOptions, context, {
65
+ (0, builder_package_1.assertPackageIsInstalled)('@angular-devkit/build-angular', '@nx/angular:webpack-browser');
66
+ (0, builder_package_1.assertPackageIsInstalled)('webpack-merge', '@nx/angular:webpack-browser');
67
+ return (0, rxjs_1.from)(Promise.all([
68
+ import('@angular-devkit/build-angular'),
69
+ import('@nx/webpack/internal'),
70
+ import('../utilities/webpack.js'),
71
+ ])).pipe((0, operators_1.switchMap)(([{ executeBrowserBuilder }, { WebpackNxBuildCoordinationPlugin }, { mergeCustomWebpackConfig, resolveIndexHtmlTransformer },]) => executeBrowserBuilder(delegateBuilderOptions, context, {
69
72
  webpackConfiguration: (baseWebpackConfig) => {
70
73
  if (!buildLibsFromSource && delegateBuilderOptions.watch) {
71
74
  const workspaceDependencies = dependencies
72
- .filter((dep) => !(0, operators_1.isNpmProject)(dep.node))
75
+ .filter((dep) => !(0, internal_1.isNpmProject)(dep.node))
73
76
  .map((dep) => dep.node.name);
74
77
  // default for `nx run-many` is --all projects
75
78
  // by passing an empty string for --projects, run-many will default to
@@ -79,17 +82,17 @@ function executeWebpackBrowserBuilder(options, context) {
79
82
  const skipInitialRun = shouldSkipInitialTargetRun(projectGraph, context.target.project, context.target.target);
80
83
  baseWebpackConfig.plugins.push(
81
84
  // Cast away the angular/webpack plugin type difference (webpack versions).
82
- new internal_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${context.target.target} --projects=${workspaceDependencies.join(',')}`, { skipInitialRun, skipWatchingDeps: !watchDependencies }));
85
+ new WebpackNxBuildCoordinationPlugin(`nx run-many --target=${context.target.target} --projects=${workspaceDependencies.join(',')}`, { skipInitialRun, skipWatchingDeps: !watchDependencies }));
83
86
  }
84
87
  }
85
88
  if (!pathToWebpackConfig) {
86
89
  return baseWebpackConfig;
87
90
  }
88
- return (0, webpack_1.mergeCustomWebpackConfig)(baseWebpackConfig, pathToWebpackConfig, delegateBuilderOptions, context.target);
91
+ return mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig, delegateBuilderOptions, context.target);
89
92
  },
90
93
  ...(pathToIndexFileTransformer
91
94
  ? {
92
- indexHtml: (0, webpack_1.resolveIndexHtmlTransformer)(pathToIndexFileTransformer, delegateBuilderOptions.tsConfig, context.target),
95
+ indexHtml: resolveIndexHtmlTransformer(pathToIndexFileTransformer, delegateBuilderOptions.tsConfig, context.target),
93
96
  }
94
97
  : {}),
95
98
  })));
@@ -8,7 +8,6 @@ const rxjs_1 = require("rxjs");
8
8
  const operators_1 = require("rxjs/operators");
9
9
  const builder_package_1 = require("../../executors/utilities/builder-package");
10
10
  const buildable_libs_1 = require("../utilities/buildable-libs");
11
- const webpack_1 = require("../utilities/webpack");
12
11
  // This is required to ensure that the webpack version used by the Module Federation is the same as the one used by the builders.
13
12
  const Module = require('module');
14
13
  const originalResolveFilename = Module._resolveFilename;
@@ -26,7 +25,7 @@ Module._resolveFilename = function (request, parent, isMain, options) {
26
25
  return originalResolveFilename.call(this, request, parent, isMain, options);
27
26
  };
28
27
  function buildServerApp(options, context) {
29
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular-devkit/build-angular');
28
+ (0, builder_package_1.assertPackageIsInstalled)('@angular-devkit/build-angular', '@nx/angular:webpack-server');
30
29
  const { buildLibsFromSource, customWebpackConfig, ...delegateOptions } = options;
31
30
  // If there is a path to custom webpack config
32
31
  // Invoke our own support for custom webpack config
@@ -42,7 +41,11 @@ function buildServerApp(options, context) {
42
41
  return (0, rxjs_1.from)(import('@angular-devkit/build-angular')).pipe((0, operators_1.switchMap)(({ executeServerBuilder }) => executeServerBuilder(delegateOptions, context)));
43
42
  }
44
43
  function buildServerAppWithCustomWebpackConfiguration(options, context, pathToWebpackConfig) {
45
- return (0, rxjs_1.from)(import('@angular-devkit/build-angular')).pipe((0, operators_1.switchMap)(({ executeServerBuilder }) => executeServerBuilder(options, context, {
44
+ (0, builder_package_1.assertPackageIsInstalled)('webpack-merge', '@nx/angular:webpack-server');
45
+ return (0, rxjs_1.from)(Promise.all([
46
+ import('@angular-devkit/build-angular'),
47
+ import('../utilities/webpack.js'),
48
+ ])).pipe((0, operators_1.switchMap)(([{ executeServerBuilder }, { mergeCustomWebpackConfig }]) => executeServerBuilder(options, context, {
46
49
  webpackConfiguration: async (baseWebpackConfig) => {
47
50
  // Angular auto includes code from @angular/platform-server
48
51
  // This includes the code outside the shared scope created by ModuleFederation
@@ -50,7 +53,7 @@ function buildServerAppWithCustomWebpackConfiguration(options, context, pathToWe
50
53
  // maintaining it within the shared scope.
51
54
  // Therefore, if the build is an MF Server build, remove the auto-includes from
52
55
  // the base webpack config from Angular
53
- let mergedConfig = await (0, webpack_1.mergeCustomWebpackConfig)(baseWebpackConfig, pathToWebpackConfig, options, context.target);
56
+ let mergedConfig = await mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig, options, context.target);
54
57
  if (mergedConfig.target === 'async-node') {
55
58
  mergedConfig.entry.main = mergedConfig.entry.main.filter((m) => !m.startsWith('@angular/platform-server/init'));
56
59
  mergedConfig.module.rules = mergedConfig.module.rules.filter((m) => !m.loader
@@ -62,6 +65,7 @@ function buildServerAppWithCustomWebpackConfiguration(options, context, pathToWe
62
65
  })));
63
66
  }
64
67
  function executeWebpackServerBuilder(options, context) {
68
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/webpack', '@nx/angular:webpack-server');
65
69
  options.buildLibsFromSource ??= true;
66
70
  process.env.NX_BUILD_LIBS_FROM_SOURCE = `${options.buildLibsFromSource}`;
67
71
  process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({ ...context.target });
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = applicationExecutor;
4
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
5
4
  const buildable_libs_1 = require("../utilities/buildable-libs");
6
5
  const builder_package_1 = require("../utilities/builder-package");
7
6
  const esbuild_extensions_1 = require("../utilities/esbuild-extensions");
8
7
  const normalize_options_1 = require("./utils/normalize-options");
9
8
  const validate_options_1 = require("./utils/validate-options");
9
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
10
10
  async function* applicationExecutor(options, context) {
11
11
  (0, validate_options_1.validateOptions)(options);
12
12
  const { buildLibsFromSource = true, plugins: pluginPaths, indexHtmlTransformer: indexHtmlTransformerPath, ...delegateExecutorOptions } = (0, normalize_options_1.normalizeOptions)(options);
@@ -25,7 +25,7 @@ async function* applicationExecutor(options, context) {
25
25
  description: 'Build an application.',
26
26
  optionSchema: require('./schema.json'),
27
27
  }, context);
28
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular/build');
28
+ (0, builder_package_1.assertPackageIsInstalled)('@angular/build', '@nx/angular:application');
29
29
  const { buildApplication } = await import('@angular/build');
30
30
  return yield* buildApplication(delegateExecutorOptions, builderContext, {
31
31
  codePlugins: plugins,
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = esbuildExecutor;
4
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
5
4
  const buildable_libs_1 = require("../utilities/buildable-libs");
6
5
  const esbuild_extensions_1 = require("../utilities/esbuild-extensions");
6
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
7
7
  async function* esbuildExecutor(options, context) {
8
8
  options.buildLibsFromSource ??= true;
9
9
  const { buildLibsFromSource, plugins: pluginPaths, ...delegateExecutorOptions } = options;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = extractI18nExecutor;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
6
- const project_graph_1 = require("nx/src/project-graph/project-graph");
7
5
  const builder_package_1 = require("../utilities/builder-package");
8
6
  const patch_builder_context_1 = require("../utilities/patch-builder-context");
7
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
8
+ const internal_1 = require("@nx/devkit/internal");
9
9
  async function* extractI18nExecutor(options, context) {
10
10
  const parsedBuildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context);
11
- const buildTargetProjectConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(parsedBuildTarget.project);
11
+ const buildTargetProjectConfiguration = (0, internal_1.readCachedProjectConfiguration)(parsedBuildTarget.project);
12
12
  const buildTarget = buildTargetProjectConfiguration.targets[parsedBuildTarget.target];
13
13
  const isUsingEsbuildBuilder = [
14
14
  '@angular/build:application',
@@ -29,7 +29,7 @@ async function* extractI18nExecutor(options, context) {
29
29
  * handle `@nx/angular:*` executors.
30
30
  */
31
31
  (0, patch_builder_context_1.patchBuilderContext)(builderContext, isUsingEsbuildBuilder, parsedBuildTarget);
32
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular-devkit/build-angular');
32
+ (0, builder_package_1.assertPackageIsInstalled)('@angular-devkit/build-angular', '@nx/angular:extract-i18n');
33
33
  const { executeExtractI18nBuilder } = await import('@angular-devkit/build-angular');
34
34
  return await executeExtractI18nBuilder(options, builderContext);
35
35
  }
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moduleFederationDevServerExecutor = moduleFederationDevServerExecutor;
4
4
  const internal_1 = require("@nx/devkit/internal");
5
5
  const devkit_1 = require("@nx/devkit");
6
+ const builder_package_1 = require("../utilities/builder-package");
6
7
  const lib_1 = require("./lib");
7
- const internal_2 = require("@nx/module-federation/internal");
8
- const internal_3 = require("@nx/web/internal");
9
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
8
+ const internal_2 = require("@nx/web/internal");
10
9
  const dev_server_impl_1 = require("../../builders/dev-server/dev-server.impl");
11
10
  const module_federation_1 = require("../../builders/utilities/module-federation");
12
11
  const path_1 = require("path");
13
12
  const fs_1 = require("fs");
14
13
  const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
14
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
15
15
  // This is required to ensure that the webpack version used by the Module Federation is the same as the one used by the builders.
16
16
  const Module = require('module');
17
17
  const originalResolveFilename = Module._resolveFilename;
@@ -29,12 +29,14 @@ Module._resolveFilename = function (request, parent, isMain, options) {
29
29
  return originalResolveFilename.call(this, request, parent, isMain, options);
30
30
  };
31
31
  async function* moduleFederationDevServerExecutor(schema, context) {
32
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/module-federation', '@nx/angular:module-federation-dev-server');
33
+ const { startRemoteIterators } = await import('@nx/module-federation/internal');
32
34
  (0, module_federation_deprecation_1.warnAngularMfDevServerExecutorDeprecation)();
33
35
  const options = (0, lib_1.normalizeOptions)(schema);
34
36
  const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
35
37
  const project = workspaceProjects[context.projectName];
36
38
  const currIter = options.static
37
- ? (0, internal_3.fileServerExecutor)({
39
+ ? (0, internal_2.fileServerExecutor)({
38
40
  port: options.port,
39
41
  host: options.host,
40
42
  ssl: options.ssl,
@@ -68,7 +70,7 @@ async function* moduleFederationDevServerExecutor(schema, context) {
68
70
  pathToManifestFile = userPathToManifestFile;
69
71
  }
70
72
  (0, module_federation_1.validateDevRemotes)(options, workspaceProjects);
71
- const { remotes, staticRemotesIter, devRemoteIters } = await (0, internal_2.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'angular');
73
+ const { remotes, staticRemotesIter, devRemoteIters } = await startRemoteIterators(options, context, lib_1.startRemotes, pathToManifestFile, 'angular');
72
74
  const removeBaseUrlEmission = (iter) => (0, internal_1.mapAsyncIterable)(iter, (v) => ({
73
75
  ...v,
74
76
  baseUrl: undefined,
@@ -88,7 +90,7 @@ async function* moduleFederationDevServerExecutor(schema, context) {
88
90
  const portsToWaitFor = staticRemotesIter
89
91
  ? [options.staticRemotesPort, ...remotes.remotePorts]
90
92
  : [...remotes.remotePorts];
91
- await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
93
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_2.waitForPortOpen)(port, {
92
94
  retries: 480,
93
95
  retryDelay: 2500,
94
96
  host: 'localhost',
@@ -3,17 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moduleFederationSsrDevServerExecutor = moduleFederationSsrDevServerExecutor;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
- const internal_2 = require("@nx/module-federation/internal");
7
- const internal_3 = require("@nx/web/internal");
6
+ const internal_2 = require("@nx/web/internal");
8
7
  const fs_1 = require("fs");
9
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
10
- const project_graph_1 = require("nx/src/project-graph/project-graph");
11
8
  const path_1 = require("path");
12
9
  const module_federation_1 = require("../../builders/utilities/module-federation");
13
10
  const builder_package_1 = require("../utilities/builder-package");
14
11
  const normalize_options_1 = require("./lib/normalize-options");
15
12
  const start_dev_remotes_1 = require("./lib/start-dev-remotes");
16
13
  const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
14
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
17
15
  // This is required to ensure that the webpack version used by the Module Federation is the same as the one used by the builders.
18
16
  const Module = require('module');
19
17
  const originalResolveFilename = Module._resolveFilename;
@@ -31,9 +29,11 @@ Module._resolveFilename = function (request, parent, isMain, options) {
31
29
  return originalResolveFilename.call(this, request, parent, isMain, options);
32
30
  };
33
31
  async function* moduleFederationSsrDevServerExecutor(schema, context) {
32
+ (0, builder_package_1.assertPackageIsInstalled)('@nx/module-federation', '@nx/angular:module-federation-dev-ssr');
33
+ const { startRemoteIterators } = await import('@nx/module-federation/internal');
34
34
  (0, module_federation_deprecation_1.warnAngularMfDevSsrExecutorDeprecation)();
35
35
  const options = (0, normalize_options_1.normalizeOptions)(schema);
36
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular-devkit/build-angular');
36
+ (0, builder_package_1.assertPackageIsInstalled)('@angular-devkit/build-angular', '@nx/angular:module-federation-dev-ssr');
37
37
  const { executeSSRDevServerBuilder } = await import('@angular-devkit/build-angular');
38
38
  const currIter = (0, internal_1.eachValueFrom)(executeSSRDevServerBuilder(options, await (0, ngcli_adapter_1.createBuilderContext)({
39
39
  builderName: '@nx/angular:webpack-server',
@@ -43,7 +43,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
43
43
  if (options.isInitialHost === false) {
44
44
  return yield* currIter;
45
45
  }
46
- const { projects: workspaceProjects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
46
+ const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
47
47
  const project = workspaceProjects[context.projectName];
48
48
  let pathToManifestFile;
49
49
  if (options.pathToManifestFile) {
@@ -60,7 +60,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
60
60
  pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
61
61
  }
62
62
  (0, module_federation_1.validateDevRemotes)({ devRemotes: options.devRemotes }, workspaceProjects);
63
- const { remotes, staticRemotesIter, devRemoteIters } = await (0, internal_2.startRemoteIterators)(options, context, start_dev_remotes_1.startRemotes, pathToManifestFile, 'angular', true);
63
+ const { remotes, staticRemotesIter, devRemoteIters } = await startRemoteIterators(options, context, start_dev_remotes_1.startRemotes, pathToManifestFile, 'angular', true);
64
64
  const removeBaseUrlEmission = (iter) => (0, internal_1.mapAsyncIterable)(iter, (v) => ({
65
65
  ...v,
66
66
  baseUrl: undefined,
@@ -80,7 +80,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
80
80
  const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
81
81
  ? [options.staticRemotesPort, ...remotes.remotePorts]
82
82
  : [...remotes.remotePorts];
83
- await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
83
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_2.waitForPortOpen)(port, {
84
84
  retries: 480,
85
85
  retryDelay: 2500,
86
86
  host: 'localhost',
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = unitTestExecutor;
4
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
4
+ const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
5
5
  const targets_1 = require("../../utils/targets");
6
6
  const semver_1 = require("semver");
7
7
  const angular_version_utils_1 = require("../utilities/angular-version-utils");
@@ -22,7 +22,7 @@ async function* unitTestExecutor(options, context) {
22
22
  const buildTargetSpecifier = options.buildTarget ?? `::development`;
23
23
  const buildTarget = (0, targets_1.targetFromTargetString)(buildTargetSpecifier, context.projectName, 'build');
24
24
  patchBuilderContext(builderContext, buildTarget);
25
- (0, builder_package_1.assertBuilderPackageIsInstalled)('@angular/build');
25
+ (0, builder_package_1.assertPackageIsInstalled)('@angular/build', '@nx/angular:unit-test');
26
26
  const { executeUnitTestBuilder } = await import('@angular/build');
27
27
  return yield* executeUnitTestBuilder(delegateExecutorOptions, builderContext, {
28
28
  codePlugins: plugins,
@@ -1 +1 @@
1
- export declare function assertBuilderPackageIsInstalled(packageName: string): void;
1
+ export declare function assertPackageIsInstalled(packageName: string, requiredBy: string): void;
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertBuilderPackageIsInstalled = assertBuilderPackageIsInstalled;
4
- function assertBuilderPackageIsInstalled(packageName) {
3
+ exports.assertPackageIsInstalled = assertPackageIsInstalled;
4
+ function assertPackageIsInstalled(packageName, requiredBy) {
5
5
  try {
6
6
  require.resolve(packageName);
7
7
  }
8
- catch {
9
- throw new Error(`This executor requires the package ${packageName} to be installed. Please make sure it is installed and try again.`);
8
+ catch (e) {
9
+ // Only a missing module means "not installed"; surface other resolution
10
+ // errors (e.g. a malformed package's exports) as-is instead of mislabeling.
11
+ const code = e.code;
12
+ if (code !== 'MODULE_NOT_FOUND' && code !== 'ERR_MODULE_NOT_FOUND') {
13
+ throw e;
14
+ }
15
+ throw new Error(`The "${packageName}" package is required by "${requiredBy}" but is not installed. Please install it and try again.`);
10
16
  }
11
17
  }
@@ -19,7 +19,7 @@ async function addLintingGenerator(tree, options) {
19
19
  (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
20
20
  ],
21
21
  unitTestRunner: options.unitTestRunner,
22
- setParserOptionsProject: options.setParserOptionsProject,
22
+ enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(options),
23
23
  skipFormat: true,
24
24
  rootProject: rootProject,
25
25
  addPlugin: options.addPlugin ?? false,
@@ -28,11 +28,6 @@ async function addLintingGenerator(tree, options) {
28
28
  });
29
29
  tasks.push(lintTask);
30
30
  if ((0, internal_2.isEslintConfigSupported)(tree)) {
31
- const eslintFile = (0, internal_2.findEslintFile)(tree, options.projectRoot);
32
- // keep parser options if they exist
33
- const hasParserOptions = tree
34
- .read((0, devkit_1.joinPathFragments)(options.projectRoot, eslintFile), 'utf8')
35
- .includes(`${options.projectRoot}/tsconfig.*?.json`);
36
31
  if ((0, internal_2.useFlatConfig)(tree)) {
37
32
  (0, internal_2.addPredefinedConfigToFlatLintConfig)(tree, options.projectRoot, 'flat/angular', { checkBaseConfig: true });
38
33
  (0, internal_2.addPredefinedConfigToFlatLintConfig)(tree, options.projectRoot, 'flat/angular-template', { checkBaseConfig: true });
@@ -63,11 +58,27 @@ async function addLintingGenerator(tree, options) {
63
58
  });
64
59
  }
65
60
  else {
61
+ // Legacy `.eslintrc` overrides are fully replaced below, which would drop
62
+ // an existing `parserOptions.project`. Detect it first so we can carry it
63
+ // over. (Flat configs keep typed linting via `lintProjectGenerator`, so
64
+ // this is only needed on the legacy stack.)
65
+ const eslintFile = (0, internal_2.findEslintFile)(tree, options.projectRoot);
66
+ const eslintFileContent = eslintFile
67
+ ? tree.read((0, devkit_1.joinPathFragments)(options.projectRoot, eslintFile), 'utf8')
68
+ : null;
69
+ const typedLinting = eslintFileContent
70
+ ? (0, internal_2.inspectTypedLinting)(eslintFileContent)
71
+ : null;
72
+ // Only a `project` needs carrying over. A config running the project
73
+ // service needs no glob and typescript-eslint rejects one next to it.
74
+ const carryOverProject = !!typedLinting?.project && !typedLinting.projectService;
66
75
  (0, internal_2.replaceOverridesInLintConfig)(tree, options.projectRoot, [
67
76
  ...(rootProject ? [internal_2.typeScriptOverride, internal_2.javaScriptOverride] : []),
68
77
  {
69
78
  files: ['*.ts'],
70
- ...(hasParserOptions
79
+ // Legacy `.eslintrc` is JSON, which can't express the `__dirname`
80
+ // that `tsconfigRootDir` needs, so it keeps `parserOptions.project`.
81
+ ...(carryOverProject
71
82
  ? {
72
83
  parserOptions: {
73
84
  project: [`${options.projectRoot}/tsconfig.*?.json`],
@@ -2,6 +2,10 @@ export interface AddLintingGeneratorSchema {
2
2
  projectName: string;
3
3
  projectRoot: string;
4
4
  prefix: string;
5
+ enableTypedLinting?: boolean;
6
+ /**
7
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
8
+ */
5
9
  setParserOptionsProject?: boolean;
6
10
  skipFormat?: boolean;
7
11
  skipPackageJson?: boolean;
@@ -28,11 +28,17 @@
28
28
  "description": "The path to the root of the selected project.",
29
29
  "x-priority": "important"
30
30
  },
31
- "setParserOptionsProject": {
31
+ "enableTypedLinting": {
32
32
  "type": "boolean",
33
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
33
+ "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.",
34
34
  "default": false
35
35
  },
36
+ "setParserOptionsProject": {
37
+ "type": "boolean",
38
+ "description": "Deprecated alias for `enableTypedLinting`.",
39
+ "default": false,
40
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
41
+ },
36
42
  "skipFormat": {
37
43
  "type": "boolean",
38
44
  "description": "Skip formatting files.",
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addE2e = addE2e;
4
- const internal_1 = require("@nx/devkit/internal");
5
4
  const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/devkit/internal");
6
+ const internal_2 = require("@nx/eslint/internal");
6
7
  const versions_1 = require("../../../utils/versions");
7
8
  async function addE2e(tree, options) {
8
9
  // since e2e are separate projects, default to adding plugins
@@ -54,7 +55,7 @@ async function addE2e(tree, options) {
54
55
  directory: 'src',
55
56
  js: false,
56
57
  linter: options.linter,
57
- setParserOptionsProject: options.setParserOptionsProject,
58
+ enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(options),
58
59
  webServerCommand: e2eWebServerInfo.e2eWebServerCommand,
59
60
  webServerAddress: e2eWebServerInfo.e2eWebServerAddress,
60
61
  rootProject: options.rootProject,
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = addLinting;
4
4
  const tslib_1 = require("tslib");
5
+ const internal_1 = require("@nx/eslint/internal");
5
6
  const add_linting_1 = tslib_1.__importDefault(require("../../add-linting/add-linting"));
6
7
  async function addLinting(host, options) {
7
8
  if (options.linter === 'none') {
@@ -11,7 +12,7 @@ async function addLinting(host, options) {
11
12
  projectName: options.name,
12
13
  projectRoot: options.appProjectRoot,
13
14
  prefix: options.prefix,
14
- setParserOptionsProject: options.setParserOptionsProject,
15
+ enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
15
16
  skipPackageJson: options.skipPackageJson,
16
17
  unitTestRunner: options.unitTestRunner,
17
18
  skipFormat: true,
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = createFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
7
6
  const test_runners_1 = require("../../../utils/test-runners");
8
7
  const artifact_types_1 = require("../../utils/artifact-types");
9
8
  const selector_1 = require("../../utils/selector");
10
9
  const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
10
+ const internal_1 = require("@nx/devkit/internal");
11
11
  async function createFiles(tree, options, rootOffset) {
12
12
  const rootSelector = `${options.prefix}-root`;
13
13
  (0, selector_1.validateHtmlSelector)(rootSelector);
14
14
  const nxWelcomeSelector = `${options.prefix}-nx-welcome`;
15
15
  (0, selector_1.validateHtmlSelector)(nxWelcomeSelector);
16
- const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
16
+ const onBoardingStatus = await (0, internal_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
17
17
  const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
18
- (await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
18
+ (await (0, internal_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
19
19
  const componentType = (0, artifact_types_1.getComponentType)(tree);
20
20
  const componentFileSuffix = componentType ? `.${componentType}` : '';
21
21
  const moduleTypeSeparator = (0, artifact_types_1.getModuleTypeSeparator)(tree);
@@ -20,6 +20,10 @@ export interface Schema {
20
20
  backendProject?: string;
21
21
  strict?: boolean;
22
22
  port?: number;
23
+ enableTypedLinting?: boolean;
24
+ /**
25
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
26
+ */
23
27
  setParserOptionsProject?: boolean;
24
28
  skipPackageJson?: boolean;
25
29
  standalone?: boolean;
@@ -133,11 +133,17 @@
133
133
  "type": "number",
134
134
  "description": "The port at which the remote application should be served."
135
135
  },
136
- "setParserOptionsProject": {
136
+ "enableTypedLinting": {
137
137
  "type": "boolean",
138
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
138
+ "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.",
139
139
  "default": false
140
140
  },
141
+ "setParserOptionsProject": {
142
+ "type": "boolean",
143
+ "description": "Deprecated alias for `enableTypedLinting`.",
144
+ "default": false,
145
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
146
+ },
141
147
  "standalone": {
142
148
  "description": "Generate an application that is setup to use standalone components.",
143
149
  "type": "boolean",