@nx/angular 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba

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 (187) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/executors.d.ts +1 -1
  4. package/executors.json +9 -9
  5. package/migrations.json +209 -0
  6. package/package.json +18 -17
  7. package/plugins/component-testing.d.ts +2 -2
  8. package/plugins/component-testing.js +1 -1
  9. package/src/builders/dev-server/dev-server.impl.js +1 -1
  10. package/src/builders/dev-server/lib/validate-options.js +1 -1
  11. package/src/builders/dev-server/schema.json +3 -3
  12. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +9 -6
  13. package/src/builders/module-federation-dev-ssr/schema.json +1 -1
  14. package/src/builders/utilities/module-federation.d.ts +7 -2
  15. package/src/builders/utilities/module-federation.js +20 -4
  16. package/src/builders/webpack-browser/schema.d.ts +2 -2
  17. package/src/builders/webpack-browser/schema.json +10 -10
  18. package/src/builders/webpack-browser/webpack-browser.impl.js +2 -8
  19. package/src/builders/webpack-server/schema.json +13 -13
  20. package/src/builders/webpack-server/webpack-server.impl.js +3 -5
  21. package/src/executors/application/application.impl.d.ts +2 -1
  22. package/src/executors/application/application.impl.js +2 -2
  23. package/src/executors/application/schema.json +11 -6
  24. package/src/executors/application/utils/validate-options.js +5 -0
  25. package/src/executors/browser-esbuild/browser-esbuild.impl.d.ts +2 -7
  26. package/src/executors/browser-esbuild/browser-esbuild.impl.js +2 -2
  27. package/src/executors/browser-esbuild/schema.json +8 -8
  28. package/src/executors/extract-i18n/extract-i18n.impl.js +2 -2
  29. package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +11 -3
  30. package/src/executors/module-federation-dev-server/lib/normalize-options.js +1 -0
  31. package/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +1 -5
  32. package/src/executors/module-federation-dev-server/lib/start-dev-remotes.js +16 -15
  33. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +2 -1
  34. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +16 -8
  35. package/src/executors/module-federation-dev-server/schema.d.ts +4 -1
  36. package/src/executors/module-federation-dev-server/schema.json +22 -5
  37. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.js +6 -6
  38. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.transform.js +3 -2
  39. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.transform.js +2 -1
  40. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/options.di.js +3 -2
  41. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.d.ts +1 -2
  42. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.js +5 -4
  43. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.js +12 -12
  44. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/v17+/ng-package/entry-point/write-package.transform.js +2 -1
  45. package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +1 -1
  46. package/src/executors/ng-packagr-lite/schema.json +1 -1
  47. package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +5 -4
  48. package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +3 -2
  49. package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +4 -4
  50. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.d.ts +1 -2
  51. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +5 -4
  52. package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +12 -12
  53. package/src/executors/package/package.impl.js +1 -1
  54. package/src/executors/package/schema.json +1 -1
  55. package/src/executors/utilities/esbuild-extensions.d.ts +2 -4
  56. package/src/executors/utilities/module-loader.d.ts +1 -2
  57. package/src/executors/utilities/ng-packagr/stylesheet-processor.d.ts +22 -0
  58. package/src/executors/utilities/ng-packagr/stylesheet-processor.di.d.ts +1 -1
  59. package/src/executors/utilities/ng-packagr/stylesheet-processor.di.js +7 -1
  60. package/src/executors/utilities/ng-packagr/stylesheet-processor.js +100 -7
  61. package/src/executors/utilities/typescript.d.ts +1 -2
  62. package/src/executors/utilities/typescript.js +4 -3
  63. package/src/generators/add-linting/add-linting.d.ts +1 -1
  64. package/src/generators/add-linting/add-linting.js +7 -11
  65. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.d.ts +2 -2
  66. package/src/generators/add-linting/lib/add-angular-eslint-dependencies.js +15 -6
  67. package/src/generators/add-linting/lib/buildable-project.d.ts +2 -0
  68. package/src/generators/add-linting/lib/buildable-project.js +9 -0
  69. package/src/generators/add-linting/lib/create-eslint-configuration.d.ts +2 -2
  70. package/src/generators/add-linting/schema.json +1 -1
  71. package/src/generators/application/application.js +4 -1
  72. package/src/generators/application/files/base-pre18/src/favicon.ico +0 -0
  73. package/src/generators/application/files/ng-module/src/main.ts__tpl__ +3 -1
  74. package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +2 -2
  75. package/src/generators/application/lib/add-e2e.js +9 -6
  76. package/src/generators/application/lib/add-linting.js +2 -1
  77. package/src/generators/application/lib/create-files.js +7 -0
  78. package/src/generators/application/lib/create-project.js +12 -5
  79. package/src/generators/application/lib/normalize-options.js +15 -1
  80. package/src/generators/application/lib/normalized-schema.d.ts +3 -0
  81. package/src/generators/application/schema.json +2 -2
  82. package/src/generators/component/schema.d.ts +3 -3
  83. package/src/generators/component/schema.json +2 -2
  84. package/src/generators/component-test/component-test.js +1 -1
  85. package/src/generators/convert-to-application-executor/convert-to-application-executor.js +6 -4
  86. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +3 -3
  87. package/src/generators/directive/schema.d.ts +3 -3
  88. package/src/generators/directive/schema.json +2 -2
  89. package/src/generators/federate-module/lib/add-remote.js +2 -1
  90. package/src/generators/host/host.js +14 -2
  91. package/src/generators/host/lib/update-ssr-setup.js +9 -7
  92. package/src/generators/host/schema.json +2 -2
  93. package/src/generators/library/files/base/package.json__tpl__ +0 -3
  94. package/src/generators/library/library.js +17 -8
  95. package/src/generators/ng-add/migrators/builders/angular-devkit-karma.migrator.js +3 -2
  96. package/src/generators/ng-add/migrators/migrator.d.ts +1 -1
  97. package/src/generators/ng-add/migrators/migrator.js +7 -7
  98. package/src/generators/ng-add/migrators/projects/app.migrator.js +2 -2
  99. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -1
  100. package/src/generators/ng-add/utilities/validation-logging.js +2 -1
  101. package/src/generators/ngrx-root-store/ngrx-root-store.js +2 -1
  102. package/src/generators/pipe/schema.d.ts +3 -3
  103. package/src/generators/pipe/schema.json +2 -2
  104. package/src/generators/remote/lib/update-ssr-setup.d.ts +2 -1
  105. package/src/generators/remote/lib/update-ssr-setup.js +10 -8
  106. package/src/generators/remote/remote.js +8 -4
  107. package/src/generators/remote/schema.json +2 -2
  108. package/src/generators/scam/schema.d.ts +3 -3
  109. package/src/generators/scam/schema.json +2 -2
  110. package/src/generators/scam-directive/schema.d.ts +3 -3
  111. package/src/generators/scam-directive/schema.json +2 -2
  112. package/src/generators/scam-pipe/schema.d.ts +3 -3
  113. package/src/generators/scam-pipe/schema.json +2 -2
  114. package/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +1 -1
  115. package/src/generators/setup-mf/files/webpack/module-federation.config.js__tmpl__ +1 -1
  116. package/src/generators/setup-mf/lib/add-remote-to-host.d.ts +7 -2
  117. package/src/generators/setup-mf/lib/add-remote-to-host.js +15 -19
  118. package/src/generators/setup-mf/lib/fix-bootstrap.d.ts +1 -1
  119. package/src/generators/setup-mf/lib/fix-bootstrap.js +12 -5
  120. package/src/generators/setup-mf/lib/generate-config.js +1 -0
  121. package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +5 -1
  122. package/src/generators/setup-mf/lib/update-host-app-routes.js +1 -4
  123. package/src/generators/setup-mf/setup-mf.js +21 -4
  124. package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +4 -3
  125. package/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ +4 -3
  126. package/src/generators/setup-ssr/lib/add-dependencies.js +2 -1
  127. package/src/generators/setup-ssr/lib/generate-files.js +1 -7
  128. package/src/generators/setup-ssr/lib/index.d.ts +0 -1
  129. package/src/generators/setup-ssr/lib/index.js +0 -1
  130. package/src/generators/setup-ssr/lib/validate-options.js +0 -13
  131. package/src/generators/setup-ssr/schema.d.ts +1 -0
  132. package/src/generators/setup-ssr/schema.json +10 -3
  133. package/src/generators/setup-ssr/setup-ssr.js +3 -4
  134. package/src/generators/stories/stories.js +3 -2
  135. package/src/generators/storybook-configuration/lib/generate-stories.js +1 -1
  136. package/src/generators/storybook-configuration/schema.json +3 -3
  137. package/src/generators/utils/add-jest.js +1 -2
  138. package/src/generators/utils/add-mf-env-to-inputs.js +4 -1
  139. package/src/generators/utils/ensure-angular-dependencies.d.ts +1 -1
  140. package/src/generators/utils/ensure-angular-dependencies.js +44 -27
  141. package/src/generators/utils/storybook-ast/tree-utilities.js +2 -1
  142. package/src/generators/utils/testing.js +0 -17
  143. package/src/generators/utils/version-utils.d.ts +1 -2
  144. package/src/generators/utils/version-utils.js +5 -16
  145. package/src/migrations/update-15-2-0/remove-browserlist-config.d.ts +1 -0
  146. package/src/migrations/update-15-2-0/remove-browserlist-config.js +2 -1
  147. package/src/migrations/update-15-2-0/remove-platform-server-exports.js +2 -1
  148. package/src/migrations/update-15-2-0/update-karma-main-file.js +2 -1
  149. package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +2 -1
  150. package/src/migrations/update-16-1-0/update-server-executor-config.js +2 -2
  151. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
  152. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
  153. package/src/migrations/update-18-2-0/update-angular-cli.d.ts +3 -0
  154. package/src/migrations/update-18-2-0/update-angular-cli.js +23 -0
  155. package/src/migrations/update-19-1-0/update-angular-cli.d.ts +3 -0
  156. package/src/migrations/update-19-1-0/update-angular-cli.js +23 -0
  157. package/src/migrations/update-19-2-1/add-typescript-eslint-utils.d.ts +3 -0
  158. package/src/migrations/update-19-2-1/add-typescript-eslint-utils.js +19 -0
  159. package/src/utils/backward-compatible-versions.d.ts +10 -5
  160. package/src/utils/backward-compatible-versions.js +18 -19
  161. package/src/utils/file-change-recorder.js +2 -1
  162. package/src/utils/{public-api.d.ts → index.d.ts} +5 -0
  163. package/src/utils/{public-api.js → index.js} +5 -0
  164. package/src/utils/mf/utils.js +1 -0
  165. package/src/utils/mf/with-module-federation-ssr.js +3 -0
  166. package/src/utils/mf/with-module-federation.js +6 -2
  167. package/src/utils/version-utils.d.ts +2 -2
  168. package/src/utils/version-utils.js +2 -1
  169. package/src/utils/versions.d.ts +6 -5
  170. package/src/utils/versions.js +7 -6
  171. package/index.js +0 -8
  172. package/mf/index.js +0 -7
  173. package/mf/mf.js +0 -53
  174. package/src/builders/webpack-server/validate-options.d.ts +0 -2
  175. package/src/builders/webpack-server/validate-options.js +0 -33
  176. package/src/executors/utilities/ng-compiler-cli.d.ts +0 -1
  177. package/src/executors/utilities/ng-compiler-cli.js +0 -8
  178. package/src/generators/setup-ssr/files/ngmodule/pre-v15-2/src/main.ts__tpl__ +0 -14
  179. package/src/generators/setup-ssr/lib/update-app-module.d.ts +0 -3
  180. package/src/generators/setup-ssr/lib/update-app-module.js +0 -27
  181. package/src/runtime/nx/data-persistence.js +0 -350
  182. package/testing/index.js +0 -6
  183. package/testing/src/testing-utils.js +0 -40
  184. /package/src/generators/application/files/{base/src → base-18+/public}/favicon.ico +0 -0
  185. /package/src/generators/application/files/{base → base-pre18}/src/assets/.gitkeep__tpl__ +0 -0
  186. /package/src/generators/setup-ssr/files/ngmodule/{base/src → src}/__main__ +0 -0
  187. /package/src/generators/setup-ssr/files/ngmodule/{base/src → src}/app/__rootModuleFileName__ +0 -0
@@ -25,3 +25,25 @@ export declare class StylesheetProcessor {
25
25
  destroy(): void;
26
26
  private createRenderWorker;
27
27
  }
28
+ /**
29
+ * This class is used when ng-packagr version is 17.2.0. The async `loadPostcssConfiguration` function
30
+ * introduced in ng-packagr 17.2.0 causes a memory leak due to multiple workers being created. We must
31
+ * keep this class to support any workspace that might be using ng-packagr 17.2.0 where that function
32
+ * need to be awaited.
33
+ */
34
+ export declare class AsyncStylesheetProcessor {
35
+ private readonly projectBasePath;
36
+ private readonly basePath;
37
+ private readonly cssUrl?;
38
+ private readonly includePaths?;
39
+ private readonly cacheDirectory?;
40
+ private renderWorker;
41
+ constructor(projectBasePath: string, basePath: string, cssUrl?: CssUrl, includePaths?: string[], cacheDirectory?: string | false);
42
+ process({ filePath, content, }: {
43
+ filePath: string;
44
+ content: string;
45
+ }): Promise<string>;
46
+ /** Destory workers in pool. */
47
+ destroy(): void;
48
+ private createRenderWorker;
49
+ }
@@ -1,2 +1,2 @@
1
- import { FactoryProvider } from 'injection-js';
1
+ import type { FactoryProvider } from 'injection-js';
2
2
  export declare const STYLESHEET_PROCESSOR: FactoryProvider;
@@ -2,9 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.STYLESHEET_PROCESSOR = void 0;
4
4
  const stylesheet_processor_di_1 = require("ng-packagr/lib/styles/stylesheet-processor.di");
5
+ const angular_version_utils_1 = require("../angular-version-utils");
5
6
  const stylesheet_processor_1 = require("./stylesheet-processor");
6
7
  exports.STYLESHEET_PROCESSOR = {
7
8
  provide: stylesheet_processor_di_1.STYLESHEET_PROCESSOR_TOKEN,
8
- useFactory: () => stylesheet_processor_1.StylesheetProcessor,
9
+ useFactory: () => {
10
+ const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
11
+ return ngPackagrVersion !== '17.2.0'
12
+ ? stylesheet_processor_1.StylesheetProcessor
13
+ : stylesheet_processor_1.AsyncStylesheetProcessor;
14
+ },
9
15
  deps: [],
10
16
  };
@@ -7,8 +7,9 @@
7
7
  * config at the root of the workspace.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.StylesheetProcessor = exports.CssUrl = void 0;
11
- const browserslist = require("browserslist");
10
+ exports.AsyncStylesheetProcessor = exports.StylesheetProcessor = exports.CssUrl = void 0;
11
+ const tslib_1 = require("tslib");
12
+ const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
12
13
  const fs_1 = require("fs");
13
14
  const path_1 = require("path");
14
15
  const Piscina = require('piscina');
@@ -38,7 +39,98 @@ class StylesheetProcessor {
38
39
  // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
39
40
  // We change the default query to browsers that Angular support.
40
41
  // https://angular.io/guide/browser-support
41
- browserslist.defaults = [
42
+ browserslist_1.default.defaults = [
43
+ 'last 2 Chrome versions',
44
+ 'last 1 Firefox version',
45
+ 'last 2 Edge major versions',
46
+ 'last 2 Safari major versions',
47
+ 'last 2 iOS major versions',
48
+ 'Firefox ESR',
49
+ ];
50
+ }
51
+ async process({ filePath, content, }) {
52
+ this.createRenderWorker();
53
+ return this.renderWorker.run({ content, filePath });
54
+ }
55
+ /** Destory workers in pool. */
56
+ destroy() {
57
+ void this.renderWorker?.destroy();
58
+ }
59
+ createRenderWorker() {
60
+ if (this.renderWorker) {
61
+ return;
62
+ }
63
+ const styleIncludePaths = [...this.includePaths];
64
+ let prevDir = null;
65
+ let currentDir = this.basePath;
66
+ while (currentDir !== prevDir) {
67
+ const p = (0, path_1.join)(currentDir, 'node_modules');
68
+ if ((0, fs_1.existsSync)(p)) {
69
+ styleIncludePaths.push(p);
70
+ }
71
+ prevDir = currentDir;
72
+ currentDir = (0, path_1.dirname)(prevDir);
73
+ }
74
+ const browserslistData = (0, browserslist_1.default)(undefined, { path: this.basePath });
75
+ const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
76
+ let tailwindConfigPath;
77
+ let postcssConfiguration;
78
+ if ((0, semver_1.gte)(ngPackagrVersion, '18.0.0')) {
79
+ const { findTailwindConfiguration, generateSearchDirectories, loadPostcssConfiguration, } = require('ng-packagr/lib/styles/postcss-configuration');
80
+ let searchDirs = generateSearchDirectories([this.projectBasePath]);
81
+ postcssConfiguration = loadPostcssConfiguration(searchDirs);
82
+ // (nx-specific): we support loading the TailwindCSS config from the root of the workspace
83
+ searchDirs = generateSearchDirectories([
84
+ this.projectBasePath,
85
+ devkit_1.workspaceRoot,
86
+ ]);
87
+ tailwindConfigPath = findTailwindConfiguration(searchDirs);
88
+ }
89
+ else if ((0, semver_1.gt)(ngPackagrVersion, '17.2.0')) {
90
+ const { loadPostcssConfiguration, } = require('ng-packagr/lib/styles/postcss-configuration');
91
+ postcssConfiguration = loadPostcssConfiguration(this.projectBasePath);
92
+ tailwindConfigPath = (0, tailwindcss_1.getTailwindConfigPath)(this.projectBasePath, devkit_1.workspaceRoot);
93
+ }
94
+ this.renderWorker = new Piscina({
95
+ filename: require.resolve('ng-packagr/lib/styles/stylesheet-processor-worker'),
96
+ maxThreads,
97
+ recordTiming: false,
98
+ env: {
99
+ ...process.env,
100
+ FORCE_COLOR: '' + color_1.colors.enabled,
101
+ },
102
+ workerData: {
103
+ postcssConfiguration,
104
+ tailwindConfigPath,
105
+ projectBasePath: this.projectBasePath,
106
+ browserslistData,
107
+ targets: transformSupportedBrowsersToTargets(browserslistData),
108
+ cacheDirectory: this.cacheDirectory,
109
+ cssUrl: this.cssUrl,
110
+ styleIncludePaths,
111
+ },
112
+ });
113
+ }
114
+ }
115
+ exports.StylesheetProcessor = StylesheetProcessor;
116
+ /**
117
+ * This class is used when ng-packagr version is 17.2.0. The async `loadPostcssConfiguration` function
118
+ * introduced in ng-packagr 17.2.0 causes a memory leak due to multiple workers being created. We must
119
+ * keep this class to support any workspace that might be using ng-packagr 17.2.0 where that function
120
+ * need to be awaited.
121
+ */
122
+ class AsyncStylesheetProcessor {
123
+ constructor(projectBasePath, basePath, cssUrl, includePaths, cacheDirectory) {
124
+ this.projectBasePath = projectBasePath;
125
+ this.basePath = basePath;
126
+ this.cssUrl = cssUrl;
127
+ this.includePaths = includePaths;
128
+ this.cacheDirectory = cacheDirectory;
129
+ // By default, browserslist defaults are too inclusive
130
+ // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
131
+ // We change the default query to browsers that Angular support.
132
+ // https://angular.io/guide/browser-support
133
+ browserslist_1.default.defaults = [
42
134
  'last 2 Chrome versions',
43
135
  'last 1 Firefox version',
44
136
  'last 2 Edge major versions',
@@ -70,16 +162,17 @@ class StylesheetProcessor {
70
162
  prevDir = currentDir;
71
163
  currentDir = (0, path_1.dirname)(prevDir);
72
164
  }
73
- const browserslistData = browserslist(undefined, { path: this.basePath });
165
+ const browserslistData = (0, browserslist_1.default)(undefined, { path: this.basePath });
74
166
  const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
75
167
  let postcssConfiguration;
76
- if ((0, semver_1.gte)(ngPackagrVersion, '17.2.0')) {
77
- const { loadPostcssConfiguration } = await Promise.resolve().then(() => require('ng-packagr/lib/styles/postcss-configuration'));
168
+ if (ngPackagrVersion === '17.2.0') {
169
+ const { loadPostcssConfiguration, } = require('ng-packagr/lib/styles/postcss-configuration');
78
170
  postcssConfiguration = await loadPostcssConfiguration(this.projectBasePath);
79
171
  }
80
172
  this.renderWorker = new Piscina({
81
173
  filename: require.resolve('ng-packagr/lib/styles/stylesheet-processor-worker'),
82
174
  maxThreads,
175
+ recordTiming: false,
83
176
  env: {
84
177
  ...process.env,
85
178
  FORCE_COLOR: '' + color_1.colors.enabled,
@@ -97,7 +190,7 @@ class StylesheetProcessor {
97
190
  });
98
191
  }
99
192
  }
100
- exports.StylesheetProcessor = StylesheetProcessor;
193
+ exports.AsyncStylesheetProcessor = AsyncStylesheetProcessor;
101
194
  function transformSupportedBrowsersToTargets(supportedBrowsers) {
102
195
  const transformed = [];
103
196
  // https://esbuild.github.io/api/#target
@@ -6,8 +6,7 @@
6
6
  * - Added an extra function that updates the configFilePath in the returned parsed options
7
7
  * to be the original tsconfig file.
8
8
  */
9
- import type { ParsedConfiguration } from '@angular/compiler-cli';
10
9
  /**
11
10
  * Proxy function that ensures the configFilePath option points to the original file path.
12
11
  */
13
- export declare function parseRemappedTsConfigAndMergeDefaults(workspaceRoot: string, originalFilePath: string, remappedFilePath: string): Promise<ParsedConfiguration>;
12
+ export declare function parseRemappedTsConfigAndMergeDefaults(workspaceRoot: string, originalFilePath: string, remappedFilePath: string): Promise<any>;
@@ -9,9 +9,10 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.parseRemappedTsConfigAndMergeDefaults = void 0;
12
+ const tslib_1 = require("tslib");
12
13
  const path_1 = require("path");
13
- const ts = require("typescript");
14
- const ng_compiler_cli_1 = require("./ng-compiler-cli");
14
+ const ts = tslib_1.__importStar(require("typescript"));
15
+ const module_loader_1 = require("./module-loader");
15
16
  async function readDefaultTsConfig(fileName) {
16
17
  // these options are mandatory
17
18
  const extraOptions = {
@@ -29,7 +30,7 @@ async function readDefaultTsConfig(fileName) {
29
30
  flatModuleId: 'AUTOGENERATED',
30
31
  flatModuleOutFile: 'AUTOGENERATED',
31
32
  };
32
- const { readConfiguration } = await (0, ng_compiler_cli_1.ngCompilerCli)();
33
+ const { readConfiguration } = await (0, module_loader_1.loadEsmModule)('@angular/compiler-cli');
33
34
  return readConfiguration(fileName, extraOptions);
34
35
  }
35
36
  /**
@@ -1,4 +1,4 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
2
  import type { AddLintingGeneratorSchema } from './schema';
3
3
  export declare function addLintingGenerator(tree: Tree, options: AddLintingGeneratorSchema): Promise<GeneratorCallback>;
4
4
  export default addLintingGenerator;
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLintingGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const eslint_1 = require("@nx/eslint");
6
- const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
7
- const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
5
  const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
6
+ const eslint_1 = require("@nx/eslint");
9
7
  const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-eslint-config");
8
+ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
9
+ const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
10
+ const buildable_project_1 = require("./lib/buildable-project");
10
11
  async function addLintingGenerator(tree, options) {
11
12
  const tasks = [];
12
13
  const rootProject = options.projectRoot === '.' || options.projectRoot === '';
@@ -22,6 +23,7 @@ async function addLintingGenerator(tree, options) {
22
23
  rootProject: rootProject,
23
24
  addPlugin: false,
24
25
  addExplicitTargets: true,
26
+ skipPackageJson: options.skipPackageJson,
25
27
  });
26
28
  tasks.push(lintTask);
27
29
  if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
@@ -73,7 +75,7 @@ async function addLintingGenerator(tree, options) {
73
75
  */
74
76
  rules: {},
75
77
  },
76
- ...(isBuildableLibraryProject(tree, options.projectName)
78
+ ...((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)
77
79
  ? [
78
80
  {
79
81
  files: ['*.json'],
@@ -87,7 +89,7 @@ async function addLintingGenerator(tree, options) {
87
89
  ]);
88
90
  }
89
91
  if (!options.skipPackageJson) {
90
- const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree);
92
+ const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree, options.projectName);
91
93
  tasks.push(installTask);
92
94
  }
93
95
  if (!options.skipFormat) {
@@ -96,10 +98,4 @@ async function addLintingGenerator(tree, options) {
96
98
  return (0, devkit_1.runTasksInSerial)(...tasks);
97
99
  }
98
100
  exports.addLintingGenerator = addLintingGenerator;
99
- function isBuildableLibraryProject(tree, projectName) {
100
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
101
- return (projectConfig.projectType === 'library' &&
102
- projectConfig.targets?.build &&
103
- !!projectConfig.targets.build);
104
- }
105
101
  exports.default = addLintingGenerator;
@@ -1,2 +1,2 @@
1
- import type { GeneratorCallback, Tree } from '@nx/devkit';
2
- export declare function addAngularEsLintDependencies(tree: Tree): GeneratorCallback;
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ export declare function addAngularEsLintDependencies(tree: Tree, projectName: string): GeneratorCallback;
@@ -3,14 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addAngularEsLintDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const version_utils_1 = require("../../utils/version-utils");
6
- function addAngularEsLintDependencies(tree) {
7
- const angularEslintVersionToInstall = (0, version_utils_1.versions)(tree).angularEslintVersion;
8
- const jsoncEslintParserVersionToInstall = (0, version_utils_1.versions)(tree).jsoncEslintParserVersion;
9
- return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
6
+ const buildable_project_1 = require("./buildable-project");
7
+ function addAngularEsLintDependencies(tree, projectName) {
8
+ const compatVersions = (0, version_utils_1.versions)(tree);
9
+ const angularEslintVersionToInstall = compatVersions.angularEslintVersion;
10
+ const devDependencies = {
10
11
  '@angular-eslint/eslint-plugin': angularEslintVersionToInstall,
11
12
  '@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall,
12
13
  '@angular-eslint/template-parser': angularEslintVersionToInstall,
13
- 'jsonc-eslint-parser': jsoncEslintParserVersionToInstall,
14
- });
14
+ };
15
+ if ('typescriptEslintVersion' in compatVersions) {
16
+ devDependencies['@typescript-eslint/utils'] =
17
+ compatVersions.typescriptEslintVersion;
18
+ }
19
+ if ((0, buildable_project_1.isBuildableLibraryProject)(tree, projectName)) {
20
+ const jsoncEslintParserVersionToInstall = (0, version_utils_1.versions)(tree).jsoncEslintParserVersion;
21
+ devDependencies['jsonc-eslint-parser'] = jsoncEslintParserVersionToInstall;
22
+ }
23
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
15
24
  }
16
25
  exports.addAngularEsLintDependencies = addAngularEsLintDependencies;
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function isBuildableLibraryProject(tree: Tree, projectName: string): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBuildableLibraryProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function isBuildableLibraryProject(tree, projectName) {
6
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
7
+ return (projectConfig.projectType === 'library' && !!projectConfig.targets?.build);
8
+ }
9
+ exports.isBuildableLibraryProject = isBuildableLibraryProject;
@@ -29,7 +29,7 @@ export declare const extendAngularEslintJson: (json: Linter.Config, options: Esl
29
29
  [name: string]: boolean;
30
30
  };
31
31
  globals?: {
32
- [name: string]: boolean | "readable" | "off" | "readonly" | "writable" | "writeable";
32
+ [name: string]: boolean | "off" | "readonly" | "readable" | "writable" | "writeable";
33
33
  };
34
34
  noInlineConfig?: boolean;
35
35
  overrides?: Linter.ConfigOverride<Linter.RulesRecord>[];
@@ -61,7 +61,7 @@ export declare const extendAngularEslintJson: (json: Linter.Config, options: Esl
61
61
  };
62
62
  extends?: string | string[];
63
63
  globals?: {
64
- [name: string]: boolean | "readable" | "off" | "readonly" | "writable" | "writeable";
64
+ [name: string]: boolean | "off" | "readonly" | "readable" | "writable" | "writeable";
65
65
  };
66
66
  noInlineConfig?: boolean;
67
67
  parser?: string;
@@ -8,7 +8,7 @@
8
8
  "examples": [
9
9
  {
10
10
  "command": "nx g @nx/angular:add-linting --prefix=cool --projectName=cool-lib --projectRoot=libs/cool-lib",
11
- "description": "Adds ESLint with Angular-specific rules for an existing project named `cool-lib` with the [prefix](https://angular.io/guide/styleguide#style-02-07) `cool`"
11
+ "description": "Adds ESLint with Angular-specific rules for an existing project named `cool-lib` with the [prefix](https://angular.dev/style-guide#style-02-07) `cool`"
12
12
  }
13
13
  ],
14
14
  "properties": {
@@ -29,7 +29,9 @@ async function applicationGeneratorInternal(tree, schema) {
29
29
  ...options,
30
30
  skipFormat: true,
31
31
  });
32
- (0, ensure_angular_dependencies_1.ensureAngularDependencies)(tree);
32
+ if (!options.skipPackageJson) {
33
+ (0, ensure_angular_dependencies_1.ensureAngularDependencies)(tree);
34
+ }
33
35
  (0, lib_1.createProject)(tree, options);
34
36
  await (0, lib_1.createFiles)(tree, options, rootOffset);
35
37
  if (options.addTailwind) {
@@ -62,6 +64,7 @@ async function applicationGeneratorInternal(tree, schema) {
62
64
  await (0, setup_ssr_1.setupSsr)(tree, {
63
65
  project: options.name,
64
66
  standalone: options.standalone,
67
+ skipPackageJson: options.skipPackageJson,
65
68
  });
66
69
  }
67
70
  if (!options.skipFormat) {
@@ -2,5 +2,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2
2
  import { AppModule } from './app/app.module';
3
3
 
4
4
  platformBrowserDynamic()
5
- .bootstrapModule(AppModule)
5
+ .bootstrapModule(AppModule<% if (useEventCoalescing) { %>, {
6
+ ngZoneEventCoalescing: true
7
+ }<% } %>)
6
8
  .catch((err) => console.error(err));
@@ -1,7 +1,7 @@
1
- import { ApplicationConfig } from <% if (angularMajorVersion >= 16) { %>'@angular/core';<% } else { %>'@angular/platform-browser';<% } %><% if (routing) { %>
1
+ import { ApplicationConfig<% if (useEventCoalescing) { %>, provideZoneChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
2
2
  import { provideRouter } from '@angular/router';
3
3
  import { appRoutes } from './app.routes';<% } %>
4
4
 
5
5
  export const appConfig: ApplicationConfig = {
6
- providers: [<% if (routing) { %>provideRouter(appRoutes) <% } %>]
6
+ providers: [<% if (useEventCoalescing) { %>provideZoneChangeDetection({ eventCoalescing: true }), <% } %><% if (routing) { %>provideRouter(appRoutes) <% } %>]
7
7
  };
@@ -27,8 +27,8 @@ async function addE2e(tree, options) {
27
27
  linter: options.linter,
28
28
  skipPackageJson: options.skipPackageJson,
29
29
  skipFormat: true,
30
- devServerTarget: `${options.name}:serve:development`,
31
- baseUrl: 'http://localhost:4200',
30
+ devServerTarget: `${options.name}:${options.e2eWebServerTarget}:development`,
31
+ baseUrl: options.e2eWebServerAddress,
32
32
  rootProject: options.rootProject,
33
33
  addPlugin,
34
34
  });
@@ -50,8 +50,8 @@ async function addE2e(tree, options) {
50
50
  js: false,
51
51
  linter: options.linter,
52
52
  setParserOptionsProject: options.setParserOptionsProject,
53
- webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
54
- webServerAddress: `http://localhost:${options.port ?? 4200}`,
53
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.name}`,
54
+ webServerAddress: options.e2eWebServerAddress,
55
55
  rootProject: options.rootProject,
56
56
  addPlugin,
57
57
  });
@@ -59,7 +59,9 @@ async function addE2e(tree, options) {
59
59
  }
60
60
  exports.addE2e = addE2e;
61
61
  function addFileServerTarget(tree, options, targetName) {
62
- (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/web': versions_1.nxVersion });
62
+ if (!options.skipPackageJson) {
63
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/web': versions_1.nxVersion });
64
+ }
63
65
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
64
66
  const isUsingApplicationBuilder = angularMajorVersion >= 17 && options.bundler === 'esbuild';
65
67
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.name);
@@ -67,10 +69,11 @@ function addFileServerTarget(tree, options, targetName) {
67
69
  executor: '@nx/web:file-server',
68
70
  options: {
69
71
  buildTarget: `${options.name}:build`,
70
- port: options.port,
72
+ port: options.e2ePort,
71
73
  staticFilePath: isUsingApplicationBuilder
72
74
  ? (0, devkit_1.joinPathFragments)(options.outputPath, 'browser')
73
75
  : undefined,
76
+ spa: true,
74
77
  },
75
78
  };
76
79
  (0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfig);
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const eslint_1 = require("@nx/eslint");
5
- const add_linting_1 = require("../../add-linting/add-linting");
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 === eslint_1.Linter.None) {
8
9
  return;
@@ -29,9 +29,16 @@ async function createFiles(tree, options, rootOffset) {
29
29
  angularMajorVersion,
30
30
  rootOffset,
31
31
  isUsingApplicationBuilder,
32
+ useEventCoalescing: angularMajorVersion >= 18,
32
33
  tpl: '',
33
34
  };
34
35
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/base'), options.appProjectRoot, substitutions);
36
+ if (angularMajorVersion >= 18) {
37
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/base-18+'), options.appProjectRoot, substitutions);
38
+ }
39
+ else {
40
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/base-pre18'), options.appProjectRoot, substitutions);
41
+ }
35
42
  if (options.standalone) {
36
43
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/standalone-components'), options.appProjectRoot, substitutions);
37
44
  }
@@ -56,12 +56,19 @@ function createProject(tree, options) {
56
56
  index: `${options.appProjectSourceRoot}/index.html`,
57
57
  [buildMainOptionName]: `${options.appProjectSourceRoot}/main.ts`,
58
58
  polyfills: ['zone.js'],
59
- tsConfig: `${options.appProjectRoot}/tsconfig.app.json`,
59
+ tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
60
60
  inlineStyleLanguage,
61
- assets: [
62
- `${options.appProjectSourceRoot}/favicon.ico`,
63
- `${options.appProjectSourceRoot}/assets`,
64
- ],
61
+ assets: angularMajorVersion >= 18
62
+ ? [
63
+ {
64
+ glob: '**/*',
65
+ input: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'public'),
66
+ },
67
+ ]
68
+ : [
69
+ `${options.appProjectSourceRoot}/favicon.ico`,
70
+ `${options.appProjectSourceRoot}/assets`,
71
+ ],
65
72
  styles: [`${options.appProjectSourceRoot}/styles.${options.style}`],
66
73
  scripts: [],
67
74
  },
@@ -17,8 +17,19 @@ async function normalizeOptions(host, options) {
17
17
  });
18
18
  options.rootProject = appProjectRoot === '.';
19
19
  options.projectNameAndRootFormat = projectNameAndRootFormat;
20
+ const nxJson = (0, devkit_1.readNxJson)(host);
21
+ let e2eWebServerTarget = 'serve';
22
+ let e2ePort = options.port ?? 4200;
23
+ if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
24
+ (nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
25
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT)) {
26
+ e2ePort =
27
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
28
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT;
29
+ }
20
30
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
21
31
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
32
+ const e2eWebServerAddress = `http://localhost:${e2ePort}`;
22
33
  const parsedTags = options.tags
23
34
  ? options.tags.split(',').map((s) => s.trim())
24
35
  : [];
@@ -36,7 +47,7 @@ async function normalizeOptions(host, options) {
36
47
  skipTests: options.unitTestRunner === test_runners_1.UnitTestRunner.None,
37
48
  skipFormat: false,
38
49
  unitTestRunner: test_runners_1.UnitTestRunner.Jest,
39
- e2eTestRunner: test_runners_1.E2eTestRunner.Cypress,
50
+ e2eTestRunner: test_runners_1.E2eTestRunner.Playwright,
40
51
  linter: eslint_1.Linter.EsLint,
41
52
  strict: true,
42
53
  standalone: true,
@@ -47,6 +58,9 @@ async function normalizeOptions(host, options) {
47
58
  appProjectSourceRoot: `${appProjectRoot}/src`,
48
59
  e2eProjectRoot,
49
60
  e2eProjectName,
61
+ e2eWebServerAddress,
62
+ e2eWebServerTarget,
63
+ e2ePort,
50
64
  parsedTags,
51
65
  bundler,
52
66
  outputPath: (0, devkit_1.joinPathFragments)('dist', !options.rootProject ? appProjectRoot : appProjectName),
@@ -10,6 +10,9 @@ export interface NormalizedSchema extends Schema {
10
10
  appProjectSourceRoot: string;
11
11
  e2eProjectName: string;
12
12
  e2eProjectRoot: string;
13
+ e2eWebServerAddress: string;
14
+ e2eWebServerTarget: string;
15
+ e2ePort: number;
13
16
  parsedTags: string[];
14
17
  outputPath: string;
15
18
  }
@@ -110,10 +110,10 @@
110
110
  },
111
111
  "e2eTestRunner": {
112
112
  "type": "string",
113
- "enum": ["cypress", "playwright", "none"],
113
+ "enum": ["playwright", "cypress", "none"],
114
114
  "description": "Test runner to use for end to end (E2E) tests.",
115
115
  "x-prompt": "Which E2E test runner would you like to use?",
116
- "default": "cypress"
116
+ "default": "playwright"
117
117
  },
118
118
  "tags": {
119
119
  "type": "string",
@@ -22,15 +22,15 @@ export interface Schema {
22
22
  skipFormat?: boolean;
23
23
 
24
24
  /**
25
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
25
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.
26
26
  */
27
27
  flat?: boolean;
28
28
  /**
29
- * @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
29
+ * @deprecated Provide the `directory` option instead. It will be removed in Nx v20.
30
30
  */
31
31
  path?: string;
32
32
  /**
33
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
33
+ * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v20.
34
34
  */
35
35
  project?: string;
36
36
  }
@@ -34,7 +34,7 @@
34
34
  "$source": "projectName"
35
35
  },
36
36
  "x-dropdown": "projects",
37
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
37
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
38
38
  },
39
39
  "prefix": {
40
40
  "type": "string",
@@ -98,7 +98,7 @@
98
98
  "type": "boolean",
99
99
  "description": "Create the new files at the top level of the current project.",
100
100
  "default": false,
101
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
101
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
102
102
  },
103
103
  "skipImport": {
104
104
  "type": "boolean",
@@ -6,7 +6,7 @@ const versions_1 = require("../../utils/versions");
6
6
  const storybook_inputs_1 = require("../utils/storybook-ast/storybook-inputs");
7
7
  async function componentTestGenerator(tree, options) {
8
8
  (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
9
- const { assertMinimumCypressVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/cypress-version'));
9
+ const { assertMinimumCypressVersion } = require('@nx/cypress/src/utils/cypress-version');
10
10
  assertMinimumCypressVersion(10);
11
11
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
12
12
  const componentDirPath = (0, devkit_1.joinPathFragments)(root, options.componentDir);