@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
package/executors.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './src/executors/ng-packagr-lite/ng-packagr-lite.impl';
7
7
  export * from './src/executors/package/package.impl';
8
8
  export * from './src/executors/browser-esbuild/browser-esbuild.impl';
9
9
  export * from './src/executors/application/application.impl';
10
+ export * from './src/executors/extract-i18n/extract-i18n.impl';
10
11
  import { executeDevServerBuilder } from './src/builders/dev-server/dev-server.impl';
11
12
  export {
12
13
  /**
package/executors.js CHANGED
@@ -11,6 +11,7 @@ tslib_1.__exportStar(require("./src/executors/ng-packagr-lite/ng-packagr-lite.im
11
11
  tslib_1.__exportStar(require("./src/executors/package/package.impl"), exports);
12
12
  tslib_1.__exportStar(require("./src/executors/browser-esbuild/browser-esbuild.impl"), exports);
13
13
  tslib_1.__exportStar(require("./src/executors/application/application.impl"), exports);
14
+ tslib_1.__exportStar(require("./src/executors/extract-i18n/extract-i18n.impl"), exports);
14
15
  const dev_server_impl_1 = require("./src/builders/dev-server/dev-server.impl");
15
16
  Object.defineProperty(exports, "executeWebpackDevServerBuilder", { enumerable: true, get: function () { return dev_server_impl_1.executeDevServerBuilder; } });
16
17
  Object.defineProperty(exports, "executeDevServerBuilder", { enumerable: true, get: function () { return dev_server_impl_1.executeDevServerBuilder; } });
package/executors.json CHANGED
@@ -29,6 +29,11 @@
29
29
  "implementation": "./src/executors/application/application.impl",
30
30
  "schema": "./src/executors/application/schema.json",
31
31
  "description": "Builds an application with esbuild with support for incremental builds. _Note: this is only supported in Angular versions >= 17.0.0_."
32
+ },
33
+ "extract-i18n": {
34
+ "implementation": "./src/executors/extract-i18n/extract-i18n.impl",
35
+ "schema": "./src/executors/extract-i18n/schema.json",
36
+ "description": "Extracts i18n messages from source code."
32
37
  }
33
38
  },
34
39
  "builders": {
package/migrations.json CHANGED
@@ -362,6 +362,21 @@
362
362
  "version": "18.0.0-beta.0",
363
363
  "description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/angular:webpack-browser' is used for Module Federation.",
364
364
  "factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
365
+ },
366
+ "update-angular-cli-version-17-2-0": {
367
+ "cli": "nx",
368
+ "version": "18.1.0-beta.1",
369
+ "requires": {
370
+ "@angular/core": ">=17.2.0"
371
+ },
372
+ "description": "Update the @angular/cli package version to ~17.2.0.",
373
+ "factory": "./src/migrations/update-18-1-0/update-angular-cli"
374
+ },
375
+ "fix-target-defaults-for-webpack-browser": {
376
+ "cli": "nx",
377
+ "version": "18.1.1-beta.0",
378
+ "description": "Ensure targetDefaults inputs for task hashing when '@nx/angular:webpack-browser' is used are correct for Module Federation.",
379
+ "factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs"
365
380
  }
366
381
  },
367
382
  "packageJsonUpdates": {
@@ -1630,6 +1645,79 @@
1630
1645
  "alwaysAddToPackageJson": false
1631
1646
  }
1632
1647
  }
1648
+ },
1649
+ "18.1.0-jest": {
1650
+ "version": "18.1.0-beta.2",
1651
+ "requires": {
1652
+ "@angular-devkit/build-angular": ">=15.0.0 <18.0.0",
1653
+ "@angular/compiler-cli": ">=15.0.0 <18.0.0",
1654
+ "@angular/core": ">=15.0.0 <18.0.0",
1655
+ "@angular/platform-browser-dynamic": ">=15.0.0 <18.0.0",
1656
+ "jest": "^29.0.0"
1657
+ },
1658
+ "packages": {
1659
+ "jest-preset-angular": {
1660
+ "version": "~14.0.3",
1661
+ "alwaysAddToPackageJson": false
1662
+ }
1663
+ }
1664
+ },
1665
+ "18.1.0": {
1666
+ "version": "18.1.0-beta.1",
1667
+ "x-prompt": "Do you want to update the Angular version to v17.2?",
1668
+ "requires": {
1669
+ "@angular/core": ">=17.1.0 <17.2.0"
1670
+ },
1671
+ "packages": {
1672
+ "@angular-devkit/build-angular": {
1673
+ "version": "~17.2.0",
1674
+ "alwaysAddToPackageJson": false
1675
+ },
1676
+ "@angular-devkit/core": {
1677
+ "version": "~17.2.0",
1678
+ "alwaysAddToPackageJson": false
1679
+ },
1680
+ "@angular-devkit/schematics": {
1681
+ "version": "~17.2.0",
1682
+ "alwaysAddToPackageJson": false
1683
+ },
1684
+ "@angular/pwa": {
1685
+ "version": "~17.2.0",
1686
+ "alwaysAddToPackageJson": false
1687
+ },
1688
+ "@angular/ssr": {
1689
+ "version": "~17.2.0",
1690
+ "alwaysAddToPackageJson": false
1691
+ },
1692
+ "@schematics/angular": {
1693
+ "version": "~17.2.0",
1694
+ "alwaysAddToPackageJson": false
1695
+ },
1696
+ "@angular-devkit/architect": {
1697
+ "version": "~0.1702.0",
1698
+ "alwaysAddToPackageJson": false
1699
+ },
1700
+ "@angular-devkit/build-webpack": {
1701
+ "version": "~0.1702.0",
1702
+ "alwaysAddToPackageJson": false
1703
+ },
1704
+ "@angular/core": {
1705
+ "version": "~17.2.0",
1706
+ "alwaysAddToPackageJson": true
1707
+ },
1708
+ "@angular/material": {
1709
+ "version": "~17.2.0",
1710
+ "alwaysAddToPackageJson": false
1711
+ },
1712
+ "@angular/cdk": {
1713
+ "version": "~17.2.0",
1714
+ "alwaysAddToPackageJson": false
1715
+ },
1716
+ "ng-packagr": {
1717
+ "version": "~17.2.0",
1718
+ "alwaysAddToPackageJson": false
1719
+ }
1720
+ }
1633
1721
  }
1634
1722
  }
1635
1723
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "18.1.0-beta.0",
3
+ "version": "18.1.0-beta.10",
4
4
  "private": false,
5
- "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
5
+ "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/nrwl/nx.git",
@@ -78,24 +78,22 @@
78
78
  "tslib": "^2.3.0",
79
79
  "webpack": "^5.80.0",
80
80
  "webpack-merge": "^5.8.0",
81
- "@nx/devkit": "18.1.0-beta.0",
82
- "@nx/cypress": "18.1.0-beta.0",
83
- "@nx/jest": "18.1.0-beta.0",
84
- "@nx/js": "18.1.0-beta.0",
85
- "@nx/eslint": "18.1.0-beta.0",
86
- "@nx/webpack": "18.1.0-beta.0",
87
- "@nx/web": "18.1.0-beta.0",
88
- "@nx/workspace": "18.1.0-beta.0",
81
+ "@nx/devkit": "18.1.0-beta.10",
82
+ "@nx/js": "18.1.0-beta.10",
83
+ "@nx/eslint": "18.1.0-beta.10",
84
+ "@nx/webpack": "18.1.0-beta.10",
85
+ "@nx/web": "18.1.0-beta.10",
86
+ "@nx/workspace": "18.1.0-beta.10",
89
87
  "piscina": "^4.2.1",
90
- "@nrwl/angular": "18.1.0-beta.0"
88
+ "@nrwl/angular": "18.1.0-beta.10"
91
89
  },
92
90
  "peerDependencies": {
93
91
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
92
+ "@angular-devkit/core": ">= 15.0.0 < 18.0.0",
94
93
  "@angular-devkit/schematics": ">= 15.0.0 < 18.0.0",
95
94
  "@schematics/angular": ">= 15.0.0 < 18.0.0",
96
- "@angular-devkit/core": ">= 15.0.0 < 18.0.0",
97
- "rxjs": "^6.5.3 || ^7.5.0",
98
- "esbuild": "^0.19.2"
95
+ "esbuild": "^0.19.2",
96
+ "rxjs": "^6.5.3 || ^7.5.0"
99
97
  },
100
98
  "peerDependenciesMeta": {
101
99
  "esbuild": {
@@ -12,6 +12,7 @@ const rxjs_1 = require("rxjs");
12
12
  const operators_2 = require("rxjs/operators");
13
13
  const angular_version_utils_1 = require("../../executors/utilities/angular-version-utils");
14
14
  const esbuild_extensions_1 = require("../../executors/utilities/esbuild-extensions");
15
+ const patch_builder_context_1 = require("../../executors/utilities/patch-builder-context");
15
16
  const buildable_libs_1 = require("../utilities/buildable-libs");
16
17
  const webpack_1 = require("../utilities/webpack");
17
18
  const lib_1 = require("./lib");
@@ -95,7 +96,7 @@ function executeDevServerBuilder(rawOptions, context) {
95
96
  * builders. Since we are using a custom builder, we patch the context to
96
97
  * handle `@nx/angular:*` executors.
97
98
  */
98
- patchBuilderContext(context, !isUsingWebpackBuilder, parsedBuildTarget);
99
+ (0, patch_builder_context_1.patchBuilderContext)(context, !isUsingWebpackBuilder, parsedBuildTarget);
99
100
  return (0, rxjs_1.combineLatest)([
100
101
  (0, rxjs_1.from)(Promise.resolve().then(() => require('@angular-devkit/build-angular'))),
101
102
  (0, rxjs_1.from)((0, esbuild_extensions_1.loadPlugins)(buildTargetOptions.plugins, buildTargetOptions.tsConfig)),
@@ -157,40 +158,3 @@ async function loadIndexHtmlFileTransformer(pathToIndexFileTransformer, tsConfig
157
158
  ? (0, webpack_1.resolveIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig, context.target)
158
159
  : await (0, esbuild_extensions_1.loadIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig);
159
160
  }
160
- const executorToBuilderMap = new Map([
161
- [
162
- '@nx/angular:browser-esbuild',
163
- '@angular-devkit/build-angular:browser-esbuild',
164
- ],
165
- ['@nx/angular:application', '@angular-devkit/build-angular:application'],
166
- ]);
167
- function patchBuilderContext(context, isUsingEsbuildBuilder, buildTarget) {
168
- const originalGetBuilderNameForTarget = context.getBuilderNameForTarget;
169
- context.getBuilderNameForTarget = async (target) => {
170
- const builderName = await originalGetBuilderNameForTarget(target);
171
- if (executorToBuilderMap.has(builderName)) {
172
- return executorToBuilderMap.get(builderName);
173
- }
174
- return builderName;
175
- };
176
- if (isUsingEsbuildBuilder) {
177
- const originalGetTargetOptions = context.getTargetOptions;
178
- context.getTargetOptions = async (target) => {
179
- const options = await originalGetTargetOptions(target);
180
- if (target.project === buildTarget.project &&
181
- target.target === buildTarget.target &&
182
- target.configuration === buildTarget.configuration) {
183
- cleanBuildTargetOptions(options);
184
- }
185
- return options;
186
- };
187
- }
188
- }
189
- function cleanBuildTargetOptions(options) {
190
- delete options.buildLibsFromSource;
191
- delete options.customWebpackConfig;
192
- delete options.indexHtmlTransformer;
193
- delete options.indexFileTransformer;
194
- delete options.plugins;
195
- return options;
196
- }
@@ -14,5 +14,9 @@ function validateOptions(options) {
14
14
  throw new Error((0, devkit_1.stripIndents) `The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
15
15
  You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
16
16
  }
17
+ if ((0, semver_1.lt)(angularVersion, '17.2.0') && options.prebundle) {
18
+ throw new Error((0, devkit_1.stripIndents) `The "prebundle" option is only supported in Angular >= 17.2.0. You are currently using "${angularVersion}".
19
+ You can resolve this error by removing the "prebundle" option or by migrating to Angular 17.2.0.`);
20
+ }
17
21
  }
18
22
  exports.validateOptions = validateOptions;
@@ -17,6 +17,7 @@ interface BaseSchema {
17
17
  watch?: boolean;
18
18
  poll?: number;
19
19
  forceEsbuild?: boolean;
20
+ prebundle?: boolean | { exclude: string[] };
20
21
  buildLibsFromSource?: boolean;
21
22
  esbuildMiddleware?: string[];
22
23
  }
@@ -116,6 +116,24 @@
116
116
  "description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system. _Note: this is only supported in Angular versions >= 16.1.0_.",
117
117
  "default": false
118
118
  },
119
+ "prebundle": {
120
+ "description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders. _Note: this is only supported in Angular versions >= 17.2.0_.",
121
+ "oneOf": [
122
+ { "type": "boolean" },
123
+ {
124
+ "type": "object",
125
+ "properties": {
126
+ "exclude": {
127
+ "description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself.",
128
+ "type": "array",
129
+ "items": { "type": "string" }
130
+ }
131
+ },
132
+ "additionalProperties": false,
133
+ "required": ["exclude"]
134
+ }
135
+ ]
136
+ },
119
137
  "buildLibsFromSource": {
120
138
  "type": "boolean",
121
139
  "description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
@@ -8,7 +8,7 @@ const esbuild_extensions_1 = require("../utilities/esbuild-extensions");
8
8
  const validate_options_1 = require("./utils/validate-options");
9
9
  async function* applicationExecutor(options, context) {
10
10
  (0, validate_options_1.validateOptions)(options);
11
- const { buildLibsFromSource = true, plugins: pluginPaths, ...delegateExecutorOptions } = options;
11
+ const { buildLibsFromSource = true, plugins: pluginPaths, indexHtmlTransformer: indexHtmlTransformerPath, ...delegateExecutorOptions } = options;
12
12
  let dependencies;
13
13
  if (!buildLibsFromSource) {
14
14
  const { tsConfigPath, dependencies: foundDependencies } = (0, buildable_libs_1.createTmpTsConfigForBuildableLibs)(delegateExecutorOptions.tsConfig, context);
@@ -16,8 +16,8 @@ async function* applicationExecutor(options, context) {
16
16
  delegateExecutorOptions.tsConfig = tsConfigPath;
17
17
  }
18
18
  const plugins = await (0, esbuild_extensions_1.loadPlugins)(pluginPaths, options.tsConfig);
19
- const indexHtmlTransformer = options.indexHtmlTransformer
20
- ? await (0, esbuild_extensions_1.loadIndexHtmlTransformer)(options.indexHtmlTransformer, options.tsConfig)
19
+ const indexHtmlTransformer = indexHtmlTransformerPath
20
+ ? await (0, esbuild_extensions_1.loadIndexHtmlTransformer)(indexHtmlTransformerPath, options.tsConfig)
21
21
  : undefined;
22
22
  const { buildApplication } = await Promise.resolve().then(() => require('@angular-devkit/build-angular'));
23
23
  const builderContext = await (0, ngcli_adapter_1.createBuilderContext)({
@@ -135,6 +135,11 @@
135
135
  },
136
136
  "default": []
137
137
  },
138
+ "clearScreen": {
139
+ "type": "boolean",
140
+ "default": false,
141
+ "description": "Automatically clear the terminal screen during rebuilds. _Note: this is only supported in Angular versions >= 17.2.0_."
142
+ },
138
143
  "optimization": {
139
144
  "description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
140
145
  "default": true,
@@ -213,6 +218,13 @@
213
218
  "^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
214
219
  }
215
220
  },
221
+ "define": {
222
+ "description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced. _Note: this is only supported in Angular versions >= 17.2.0_.",
223
+ "type": "object",
224
+ "additionalProperties": {
225
+ "type": "string"
226
+ }
227
+ },
216
228
  "fileReplacements": {
217
229
  "description": "Replace compilation source files with other compilation source files in the build.",
218
230
  "type": "array",
@@ -8,32 +8,40 @@ function validateOptions(options) {
8
8
  if (angularMajorVersion < 17) {
9
9
  throw new Error(`The "application" executor requires Angular version 17 or greater. You are currently using version ${angularVersion}.`);
10
10
  }
11
- if (options.loader && (0, semver_1.lt)(angularVersion, '17.1.0')) {
12
- throw new Error(`The "loader" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
13
- }
14
- if (options.indexHtmlTransformer && (0, semver_1.lt)(angularVersion, '17.1.0')) {
15
- throw new Error(`The "indexHtmlTransformer" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
16
- }
17
- if (typeof options.index === 'object' &&
18
- options.index.preloadInitial !== undefined &&
19
- (0, semver_1.lt)(angularVersion, '17.1.0')) {
20
- throw new Error(`The "index.preloadInitial" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
21
- }
22
- if (options.optimization &&
23
- typeof options.optimization !== 'boolean' &&
24
- options.optimization.styles &&
25
- typeof options.optimization.styles !== 'boolean' &&
26
- (0, semver_1.lt)(angularVersion, '17.1.0')) {
27
- if (options.optimization.styles.removeSpecialComments === false) {
28
- throw new Error(`The "optimization.styles.removeSpecialComments" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
11
+ if ((0, semver_1.lt)(angularVersion, '17.1.0')) {
12
+ if (options.loader) {
13
+ throw new Error(`The "loader" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
14
+ }
15
+ if (options.indexHtmlTransformer) {
16
+ throw new Error(`The "indexHtmlTransformer" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
29
17
  }
30
- else if (options.optimization.styles.removeSpecialComments === true) {
31
- // silently remove the option, as it was the default before 17.1.0
32
- delete options.optimization.styles.removeSpecialComments;
18
+ if (typeof options.index === 'object' &&
19
+ options.index.preloadInitial !== undefined) {
20
+ throw new Error(`The "index.preloadInitial" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
21
+ }
22
+ if (options.optimization &&
23
+ typeof options.optimization !== 'boolean' &&
24
+ options.optimization.styles &&
25
+ typeof options.optimization.styles !== 'boolean') {
26
+ if (options.optimization.styles.removeSpecialComments === false) {
27
+ throw new Error(`The "optimization.styles.removeSpecialComments" option requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
28
+ }
29
+ else if (options.optimization.styles.removeSpecialComments === true) {
30
+ // silently remove the option, as it was the default before 17.1.0
31
+ delete options.optimization.styles.removeSpecialComments;
32
+ }
33
+ }
34
+ if (typeof options.outputPath === 'object') {
35
+ throw new Error(`The "outputPath" option as an object requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
33
36
  }
34
37
  }
35
- if (typeof options.outputPath === 'object' && (0, semver_1.lt)(angularVersion, '17.1.0')) {
36
- throw new Error(`The "outputPath" option as an object requires Angular version 17.1.0 or greater. You are currently using version ${angularVersion}.`);
38
+ if ((0, semver_1.lt)(angularVersion, '17.2.0')) {
39
+ if (options.define) {
40
+ throw new Error(`The "define" option requires Angular version 17.2.0 or greater. You are currently using version ${angularVersion}.`);
41
+ }
42
+ if (options.clearScreen !== undefined) {
43
+ throw new Error(`The "clearScreen" option requires Angular version 17.2.0 or greater. You are currently using version ${angularVersion}.`);
44
+ }
37
45
  }
38
46
  }
39
47
  exports.validateOptions = validateOptions;
@@ -0,0 +1,3 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import type { ExtractI18nExecutorOptions } from './schema';
3
+ export default function extractI18nExecutor(options: ExtractI18nExecutorOptions, context: ExecutorContext): AsyncGenerator<never, import("@angular-devkit/architect").BuilderOutput, unknown>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
5
+ const project_graph_1 = require("nx/src/project-graph/project-graph");
6
+ const angular_version_utils_1 = require("../utilities/angular-version-utils");
7
+ const patch_builder_context_1 = require("../utilities/patch-builder-context");
8
+ async function* extractI18nExecutor(options, context) {
9
+ const parsedBuildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context);
10
+ const browserTargetProjectConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(parsedBuildTarget.project);
11
+ const buildTarget = browserTargetProjectConfiguration.targets[parsedBuildTarget.target];
12
+ const isUsingEsbuildBuilder = [
13
+ '@angular-devkit/build-angular:application',
14
+ '@angular-devkit/build-angular:browser-esbuild',
15
+ '@nx/angular:application',
16
+ '@nx/angular:browser-esbuild',
17
+ ].includes(buildTarget.executor);
18
+ const builderContext = await (0, ngcli_adapter_1.createBuilderContext)({
19
+ builderName: 'extrct-i18n',
20
+ description: 'Extracts i18n messages from source code.',
21
+ optionSchema: await Promise.resolve().then(() => require('./schema.json')),
22
+ }, context);
23
+ /**
24
+ * The Angular CLI extract-i18n builder make some decisions based on the build
25
+ * target builder but it only considers `@angular-devkit/build-angular:*`
26
+ * builders. Since we are using a custom builder, we patch the context to
27
+ * handle `@nx/angular:*` executors.
28
+ */
29
+ (0, patch_builder_context_1.patchBuilderContext)(builderContext, isUsingEsbuildBuilder, parsedBuildTarget);
30
+ const { executeExtractI18nBuilder } = await Promise.resolve().then(() => require('@angular-devkit/build-angular'));
31
+ const delegateBuilderOptions = getDelegateBuilderOptions(options);
32
+ return await executeExtractI18nBuilder(delegateBuilderOptions, builderContext);
33
+ }
34
+ exports.default = extractI18nExecutor;
35
+ function getDelegateBuilderOptions(options) {
36
+ const delegateBuilderOptions = { ...options };
37
+ const { major: angularMajorVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
38
+ if (angularMajorVersion <= 17) {
39
+ delegateBuilderOptions.browserTarget = delegateBuilderOptions.buildTarget;
40
+ delete delegateBuilderOptions.buildTarget;
41
+ }
42
+ return delegateBuilderOptions;
43
+ }
@@ -0,0 +1,8 @@
1
+ import type { ExtractI18nBuilderOptions } from '@angular-devkit/build-angular';
2
+
3
+ export type ExtractI18nExecutorOptions = Omit<
4
+ ExtractI18nBuilderOptions,
5
+ 'browserTarget'
6
+ > & {
7
+ buildTarget: string;
8
+ };
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "title": "Schema for Nx extract-i18n Executor",
4
+ "description": "Extracts i18n messages from source code.",
5
+ "outputCapture": "direct-nodejs",
6
+ "type": "object",
7
+ "properties": {
8
+ "buildTarget": {
9
+ "type": "string",
10
+ "description": "A builder target to extract i18n messages in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
11
+ "pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
12
+ },
13
+ "format": {
14
+ "type": "string",
15
+ "description": "Output format for the generated file.",
16
+ "default": "xlf",
17
+ "enum": [
18
+ "xmb",
19
+ "xlf",
20
+ "xlif",
21
+ "xliff",
22
+ "xlf2",
23
+ "xliff2",
24
+ "json",
25
+ "arb",
26
+ "legacy-migrate"
27
+ ]
28
+ },
29
+ "progress": {
30
+ "type": "boolean",
31
+ "description": "Log progress to the console.",
32
+ "default": true
33
+ },
34
+ "outputPath": {
35
+ "type": "string",
36
+ "description": "Path where output will be placed."
37
+ },
38
+ "outFile": {
39
+ "type": "string",
40
+ "description": "Name of the file to output."
41
+ }
42
+ },
43
+ "additionalProperties": false,
44
+ "required": ["buildTarget"]
45
+ }
@@ -101,8 +101,10 @@ async function* moduleFederationDevServerExecutor(schema, context) {
101
101
  devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
102
102
  next({ success: true, baseUrl: `http://localhost:${options.port}` });
103
103
  }
104
- catch {
105
- throw new Error(`Timed out waiting for remote to start. Check above for any errors.`);
104
+ catch (err) {
105
+ throw new Error(`Failed to start remotes. Check above for any errors.`, {
106
+ cause: err,
107
+ });
106
108
  }
107
109
  finally {
108
110
  done();
@@ -122,7 +122,7 @@
122
122
  "items": {
123
123
  "type": "string"
124
124
  },
125
- "description": "List of remote applications to not automatically serve, either statically or in development mode."
125
+ "description": "List of remote applications to not automatically serve, either statically or in development mode. This will not remove the remotes from the `module-federation.config` file, and therefore the application may still try to fetch these remotes.\nThis option is useful for when the `host` application is using a `remote` that does not live in the same workspace as the `host`."
126
126
  },
127
127
  "pathToManifestFile": {
128
128
  "type": "string",
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNgPackagrInstance = void 0;
4
4
  const ng_packagr_1 = require("ng-packagr");
5
5
  const angular_version_utils_1 = require("../../utilities/angular-version-utils");
6
- const stylesheet_processor_di_1 = require("../../utilities/ng-packagr/stylesheet-processor.di");
7
6
  async function getNgPackagrInstance(options) {
8
7
  const { major: angularMajorVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
9
8
  if (angularMajorVersion >= 17) {
9
+ const { STYLESHEET_PROCESSOR } = await Promise.resolve().then(() => require('../../utilities/ng-packagr/stylesheet-processor.di'));
10
10
  const packagr = (0, ng_packagr_1.ngPackagr)();
11
- packagr.withProviders([stylesheet_processor_di_1.STYLESHEET_PROCESSOR]);
11
+ packagr.withProviders([STYLESHEET_PROCESSOR]);
12
12
  return packagr;
13
13
  }
14
14
  const { NX_ENTRY_POINT_PROVIDERS } = await Promise.resolve().then(() => require('./ng-package/entry-point/entry-point.di'));
@@ -16,6 +16,8 @@ const color_1 = require("ng-packagr/lib/utils/color");
16
16
  // using this instead of the one from ng-packagr
17
17
  const tailwindcss_1 = require("./tailwindcss");
18
18
  const devkit_1 = require("@nx/devkit");
19
+ const semver_1 = require("semver");
20
+ const angular_version_utils_1 = require("../angular-version-utils");
19
21
  const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
20
22
  const maxThreads = typeof maxWorkersVariable === 'string' && maxWorkersVariable !== ''
21
23
  ? +maxWorkersVariable
@@ -46,14 +48,14 @@ class StylesheetProcessor {
46
48
  ];
47
49
  }
48
50
  async process({ filePath, content, }) {
49
- this.createRenderWorker();
51
+ await this.createRenderWorker();
50
52
  return this.renderWorker.run({ content, filePath });
51
53
  }
52
54
  /** Destory workers in pool. */
53
55
  destroy() {
54
56
  void this.renderWorker?.destroy();
55
57
  }
56
- createRenderWorker() {
58
+ async createRenderWorker() {
57
59
  if (this.renderWorker) {
58
60
  return;
59
61
  }
@@ -69,6 +71,12 @@ class StylesheetProcessor {
69
71
  currentDir = (0, path_1.dirname)(prevDir);
70
72
  }
71
73
  const browserslistData = browserslist(undefined, { path: this.basePath });
74
+ const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
75
+ 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'));
78
+ postcssConfiguration = await loadPostcssConfiguration(this.projectBasePath);
79
+ }
72
80
  this.renderWorker = new Piscina({
73
81
  filename: require.resolve('ng-packagr/lib/styles/stylesheet-processor-worker'),
74
82
  maxThreads,
@@ -77,6 +85,7 @@ class StylesheetProcessor {
77
85
  FORCE_COLOR: '' + color_1.colors.enabled,
78
86
  },
79
87
  workerData: {
88
+ postcssConfiguration,
80
89
  tailwindConfigPath: (0, tailwindcss_1.getTailwindConfigPath)(this.projectBasePath, devkit_1.workspaceRoot),
81
90
  projectBasePath: this.projectBasePath,
82
91
  browserslistData,
@@ -0,0 +1,3 @@
1
+ import type { BuilderContext } from '@angular-devkit/architect';
2
+ import type { Target } from '@nx/devkit';
3
+ export declare function patchBuilderContext(context: BuilderContext, isUsingEsbuildBuilder: boolean, buildTarget: Target): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchBuilderContext = void 0;
4
+ const executorToBuilderMap = new Map([
5
+ [
6
+ '@nx/angular:browser-esbuild',
7
+ '@angular-devkit/build-angular:browser-esbuild',
8
+ ],
9
+ ['@nx/angular:application', '@angular-devkit/build-angular:application'],
10
+ ]);
11
+ function patchBuilderContext(context, isUsingEsbuildBuilder, buildTarget) {
12
+ const originalGetBuilderNameForTarget = context.getBuilderNameForTarget;
13
+ context.getBuilderNameForTarget = async (target) => {
14
+ const builderName = await originalGetBuilderNameForTarget(target);
15
+ if (executorToBuilderMap.has(builderName)) {
16
+ return executorToBuilderMap.get(builderName);
17
+ }
18
+ return builderName;
19
+ };
20
+ if (isUsingEsbuildBuilder) {
21
+ const originalGetTargetOptions = context.getTargetOptions;
22
+ context.getTargetOptions = async (target) => {
23
+ const options = await originalGetTargetOptions(target);
24
+ if (target.project === buildTarget.project &&
25
+ target.target === buildTarget.target &&
26
+ target.configuration === buildTarget.configuration) {
27
+ cleanBuildTargetOptions(options);
28
+ }
29
+ return options;
30
+ };
31
+ }
32
+ }
33
+ exports.patchBuilderContext = patchBuilderContext;
34
+ function cleanBuildTargetOptions(options) {
35
+ delete options.buildLibsFromSource;
36
+ delete options.customWebpackConfig;
37
+ delete options.indexHtmlTransformer;
38
+ delete options.indexFileTransformer;
39
+ delete options.plugins;
40
+ return options;
41
+ }