@nx/angular 18.0.3 → 18.0.5

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 (37) hide show
  1. package/package.json +10 -10
  2. package/src/builders/dev-server/dev-server.impl.js +13 -10
  3. package/src/builders/dev-server/lib/index.d.ts +1 -0
  4. package/src/builders/dev-server/lib/index.js +1 -0
  5. package/src/builders/dev-server/lib/validate-options.d.ts +2 -0
  6. package/src/builders/dev-server/lib/validate-options.js +18 -0
  7. package/src/builders/dev-server/schema.d.ts +1 -0
  8. package/src/builders/dev-server/schema.json +5 -0
  9. package/src/executors/module-federation-dev-server/lib/build-static-remotes.d.ts +2 -5
  10. package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +7 -8
  11. package/src/executors/module-federation-dev-server/lib/index.d.ts +1 -0
  12. package/src/executors/module-federation-dev-server/lib/index.js +1 -0
  13. package/src/executors/module-federation-dev-server/lib/parse-static-remotes-config.d.ts +11 -0
  14. package/src/executors/module-federation-dev-server/lib/parse-static-remotes-config.js +18 -0
  15. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts +2 -5
  16. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +9 -11
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +7 -4
  18. package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -0
  19. package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +1 -1
  20. package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +1 -1
  21. package/src/generators/application/lib/create-files.js +2 -8
  22. package/src/generators/application/lib/update-editor-tsconfig.d.ts +1 -1
  23. package/src/generators/application/lib/update-editor-tsconfig.js +11 -14
  24. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -0
  25. package/src/generators/library/lib/add-project.js +23 -24
  26. package/src/generators/library/lib/update-tsconfig.js +3 -3
  27. package/src/generators/setup-ssr/files/ngmodule/base/src/__main__ +1 -1
  28. package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +1 -1
  29. package/src/generators/setup-ssr/files/server/server-builder/pre-v17/__serverFileName__ +1 -1
  30. package/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ +1 -1
  31. package/src/generators/storybook-configuration/storybook-configuration.js +5 -0
  32. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.d.ts +2 -0
  33. package/src/generators/utils/update-app-editor-tsconfig-excluded-files.js +23 -0
  34. package/src/generators/utils/update-project-root-tsconfig.d.ts +3 -0
  35. package/src/generators/utils/update-project-root-tsconfig.js +26 -0
  36. package/src/generators/utils/create-ts-config.d.ts +0 -9
  37. package/src/generators/utils/create-ts-config.js +0 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "18.0.3",
3
+ "version": "18.0.5",
4
4
  "private": false,
5
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.",
6
6
  "repository": {
@@ -78,16 +78,16 @@
78
78
  "tslib": "^2.3.0",
79
79
  "webpack": "^5.80.0",
80
80
  "webpack-merge": "^5.8.0",
81
- "@nx/devkit": "18.0.3",
82
- "@nx/cypress": "18.0.3",
83
- "@nx/jest": "18.0.3",
84
- "@nx/js": "18.0.3",
85
- "@nx/eslint": "18.0.3",
86
- "@nx/webpack": "18.0.3",
87
- "@nx/web": "18.0.3",
88
- "@nx/workspace": "18.0.3",
81
+ "@nx/devkit": "18.0.5",
82
+ "@nx/cypress": "18.0.5",
83
+ "@nx/jest": "18.0.5",
84
+ "@nx/js": "18.0.5",
85
+ "@nx/eslint": "18.0.5",
86
+ "@nx/webpack": "18.0.5",
87
+ "@nx/web": "18.0.5",
88
+ "@nx/workspace": "18.0.5",
89
89
  "piscina": "^4.2.1",
90
- "@nrwl/angular": "18.0.3"
90
+ "@nrwl/angular": "18.0.5"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
@@ -16,13 +16,7 @@ const buildable_libs_1 = require("../utilities/buildable-libs");
16
16
  const webpack_1 = require("../utilities/webpack");
17
17
  const lib_1 = require("./lib");
18
18
  function executeDevServerBuilder(rawOptions, context) {
19
- if (rawOptions.esbuildMiddleware?.length > 0) {
20
- const { major: angularMajorVersion, version: angularVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
21
- if (angularMajorVersion < 17) {
22
- throw new Error((0, devkit_1.stripIndents) `The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
23
- You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
24
- }
25
- }
19
+ (0, lib_1.validateOptions)(rawOptions);
26
20
  process.env.NX_TSCONFIG_PATH = (0, js_1.getRootTsConfigPath)();
27
21
  const options = (0, lib_1.normalizeOptions)(rawOptions);
28
22
  const parsedBuildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, {
@@ -106,7 +100,8 @@ function executeDevServerBuilder(rawOptions, context) {
106
100
  (0, rxjs_1.from)(Promise.resolve().then(() => require('@angular-devkit/build-angular'))),
107
101
  (0, rxjs_1.from)((0, esbuild_extensions_1.loadPlugins)(buildTargetOptions.plugins, buildTargetOptions.tsConfig)),
108
102
  (0, rxjs_1.from)((0, esbuild_extensions_1.loadMiddleware)(options.esbuildMiddleware, buildTargetOptions.tsConfig)),
109
- ]).pipe((0, operators_2.switchMap)(([{ executeDevServerBuilder }, plugins, middleware]) => executeDevServerBuilder(delegateBuilderOptions, context, {
103
+ (0, rxjs_1.from)(loadIndexHtmlFileTransformer(pathToIndexFileTransformer, buildTargetOptions.tsConfig, context, isUsingWebpackBuilder)),
104
+ ]).pipe((0, operators_2.switchMap)(([{ executeDevServerBuilder }, plugins, middleware, indexHtmlTransformer,]) => executeDevServerBuilder(delegateBuilderOptions, context, {
110
105
  webpackConfiguration: isUsingWebpackBuilder
111
106
  ? async (baseWebpackConfig) => {
112
107
  if (!buildLibsFromSource) {
@@ -129,9 +124,9 @@ function executeDevServerBuilder(rawOptions, context) {
129
124
  return (0, webpack_1.mergeCustomWebpackConfig)(baseWebpackConfig, pathToWebpackConfig, buildTargetOptions, context.target);
130
125
  }
131
126
  : undefined,
132
- ...(pathToIndexFileTransformer
127
+ ...(indexHtmlTransformer
133
128
  ? {
134
- indexHtml: (0, webpack_1.resolveIndexHtmlTransformer)(pathToIndexFileTransformer, buildTargetOptions.tsConfig, context.target),
129
+ indexHtml: indexHtmlTransformer,
135
130
  }
136
131
  : {}),
137
132
  }, {
@@ -154,6 +149,14 @@ function getDelegateBuilderOptions(options) {
154
149
  delete delegateBuilderOptions.buildLibsFromSource;
155
150
  return delegateBuilderOptions;
156
151
  }
152
+ async function loadIndexHtmlFileTransformer(pathToIndexFileTransformer, tsConfig, context, isUsingWebpackBuilder) {
153
+ if (!pathToIndexFileTransformer) {
154
+ return undefined;
155
+ }
156
+ return isUsingWebpackBuilder
157
+ ? (0, webpack_1.resolveIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig, context.target)
158
+ : await (0, esbuild_extensions_1.loadIndexHtmlTransformer)(pathToIndexFileTransformer, tsConfig);
159
+ }
157
160
  const executorToBuilderMap = new Map([
158
161
  [
159
162
  '@nx/angular:browser-esbuild',
@@ -1 +1,2 @@
1
1
  export * from './normalize-options';
2
+ export * from './validate-options';
@@ -2,3 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
5
+ tslib_1.__exportStar(require("./validate-options"), exports);
@@ -0,0 +1,2 @@
1
+ import type { Schema } from '../schema';
2
+ export declare function validateOptions(options: Schema): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const semver_1 = require("semver");
6
+ const angular_version_utils_1 = require("../../../executors/utilities/angular-version-utils");
7
+ function validateOptions(options) {
8
+ const { major: angularMajorVersion, version: angularVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
9
+ if ((0, semver_1.lt)(angularVersion, '16.1.0') && options.forceEsbuild !== undefined) {
10
+ throw new Error((0, devkit_1.stripIndents) `The "forceEsbuild" option is only supported in Angular >= 16.1.0. You are currently using "${angularVersion}".
11
+ You can resolve this error by removing the "forceEsbuild" option or by migrating to Angular 16.1.0.`);
12
+ }
13
+ if (angularMajorVersion < 17 && options.esbuildMiddleware?.length > 0) {
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
+ You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
16
+ }
17
+ }
18
+ exports.validateOptions = validateOptions;
@@ -16,6 +16,7 @@ interface BaseSchema {
16
16
  hmr?: boolean;
17
17
  watch?: boolean;
18
18
  poll?: number;
19
+ forceEsbuild?: boolean;
19
20
  buildLibsFromSource?: boolean;
20
21
  esbuildMiddleware?: string[];
21
22
  }
@@ -111,6 +111,11 @@
111
111
  "type": "number",
112
112
  "description": "Enable and define the file watching poll time period in milliseconds."
113
113
  },
114
+ "forceEsbuild": {
115
+ "type": "boolean",
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
+ "default": false
118
+ },
114
119
  "buildLibsFromSource": {
115
120
  "type": "boolean",
116
121
  "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.",
@@ -1,7 +1,4 @@
1
1
  import { type Schema } from '../schema';
2
2
  import { type ExecutorContext } from '@nx/devkit';
3
- export declare function buildStaticRemotes(remotes: {
4
- remotePorts: any[];
5
- staticRemotes: string[];
6
- devRemotes: string[];
7
- }, nxBin: any, context: ExecutorContext, options: Schema): Promise<void>;
3
+ import type { StaticRemotesConfig } from './parse-static-remotes-config';
4
+ export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<void>;
@@ -3,22 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildStaticRemotes = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const child_process_1 = require("child_process");
6
- async function buildStaticRemotes(remotes, nxBin, context, options) {
7
- if (!remotes.staticRemotes ||
8
- (Array.isArray(remotes.staticRemotes) && !remotes.staticRemotes.length)) {
6
+ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
7
+ if (!staticRemotesConfig.remotes.length) {
9
8
  return;
10
9
  }
11
10
  const mappedLocationOfRemotes = {};
12
- for (const app of remotes.staticRemotes) {
13
- mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${app}`;
11
+ for (const app of staticRemotesConfig.remotes) {
12
+ mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
14
13
  }
15
14
  process.env.NX_MF_DEV_SERVER_STATIC_REMOTES = JSON.stringify(mappedLocationOfRemotes);
16
15
  await new Promise((res) => {
17
- devkit_1.logger.info(`NX Building ${remotes.staticRemotes.length} static remotes...`);
16
+ devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
18
17
  const staticProcess = (0, child_process_1.fork)(nxBin, [
19
18
  'run-many',
20
19
  `--target=build`,
21
- `--projects=${remotes.staticRemotes.join(',')}`,
20
+ `--projects=${staticRemotesConfig.remotes.join(',')}`,
22
21
  ...(context.configurationName
23
22
  ? [`--configuration=${context.configurationName}`]
24
23
  : []),
@@ -32,7 +31,7 @@ async function buildStaticRemotes(remotes, nxBin, context, options) {
32
31
  const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
33
32
  if (stdoutString.includes('Successfully ran target build')) {
34
33
  staticProcess.stdout.removeAllListeners('data');
35
- devkit_1.logger.info(`NX Built ${remotes.staticRemotes.length} static remotes`);
34
+ devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
36
35
  res();
37
36
  }
38
37
  });
@@ -1,4 +1,5 @@
1
1
  export * from './build-static-remotes';
2
2
  export * from './normalize-options';
3
+ export * from './parse-static-remotes-config';
3
4
  export * from './start-dev-remotes';
4
5
  export * from './start-static-remotes-file-server';
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./build-static-remotes"), exports);
5
5
  tslib_1.__exportStar(require("./normalize-options"), exports);
6
+ tslib_1.__exportStar(require("./parse-static-remotes-config"), exports);
6
7
  tslib_1.__exportStar(require("./start-dev-remotes"), exports);
7
8
  tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
@@ -0,0 +1,11 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ export type StaticRemoteConfig = {
3
+ basePath: string;
4
+ outputPath: string;
5
+ urlSegment: string;
6
+ };
7
+ export type StaticRemotesConfig = {
8
+ remotes: string[];
9
+ config: Record<string, StaticRemoteConfig> | undefined;
10
+ };
11
+ export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStaticRemotesConfig = void 0;
4
+ const path_1 = require("path");
5
+ function parseStaticRemotesConfig(staticRemotes, context) {
6
+ if (!staticRemotes?.length) {
7
+ return { remotes: [], config: undefined };
8
+ }
9
+ const config = {};
10
+ for (const app of staticRemotes) {
11
+ const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
12
+ const basePath = (0, path_1.dirname)(outputPath);
13
+ const urlSegment = (0, path_1.basename)(outputPath);
14
+ config[app] = { basePath, outputPath, urlSegment };
15
+ }
16
+ return { remotes: staticRemotes, config };
17
+ }
18
+ exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
@@ -1,10 +1,7 @@
1
1
  import { type ExecutorContext } from '@nx/devkit';
2
2
  import { type Schema } from '../schema';
3
- export declare function startStaticRemotesFileServer(remotes: {
4
- remotePorts: any[];
5
- staticRemotes: string[];
6
- devRemotes: string[];
7
- }, context: ExecutorContext, options: Schema): AsyncGenerator<{
3
+ import type { StaticRemotesConfig } from './parse-static-remotes-config';
4
+ export declare function startStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
8
5
  success: boolean;
9
6
  baseUrl: string;
10
7
  }, {
@@ -5,26 +5,24 @@ const devkit_1 = require("@nx/devkit");
5
5
  const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
6
6
  const path_1 = require("path");
7
7
  const fs_1 = require("fs");
8
- function startStaticRemotesFileServer(remotes, context, options) {
8
+ function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
9
9
  let shouldMoveToCommonLocation = false;
10
10
  let commonOutputDirectory;
11
- for (const app of remotes.staticRemotes) {
12
- const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
13
- const directoryOfOutputPath = (0, path_1.dirname)(outputPath);
11
+ for (const app of staticRemotesConfig.remotes) {
12
+ const remoteBasePath = staticRemotesConfig.config[app].basePath;
14
13
  if (!commonOutputDirectory) {
15
- commonOutputDirectory = directoryOfOutputPath;
14
+ commonOutputDirectory = remoteBasePath;
16
15
  }
17
- else if (commonOutputDirectory !== directoryOfOutputPath ||
18
- !outputPath.endsWith(app)) {
16
+ else if (commonOutputDirectory !== remoteBasePath) {
19
17
  shouldMoveToCommonLocation = true;
18
+ break;
20
19
  }
21
20
  }
22
21
  if (shouldMoveToCommonLocation) {
23
22
  commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
24
- for (const app of remotes.staticRemotes) {
25
- const outputPath = context.projectGraph.nodes[app].data.targets['build'].options
26
- .outputPath;
27
- (0, fs_1.cpSync)(outputPath, (0, path_1.join)(commonOutputDirectory, app), {
23
+ for (const app of staticRemotesConfig.remotes) {
24
+ const remoteConfig = staticRemotesConfig.config[app];
25
+ (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
28
26
  force: true,
29
27
  recursive: true,
30
28
  });
@@ -68,10 +68,11 @@ async function* moduleFederationDevServerExecutor(schema, context) {
68
68
  }
69
69
  }, options.staticRemotesPort);
70
70
  }
71
- await (0, lib_1.buildStaticRemotes)(remotes, nxBin, context, options);
71
+ const staticRemotesConfig = (0, lib_1.parseStaticRemotesConfig)(remotes.staticRemotes, context);
72
+ await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
72
73
  const devRemoteIters = await (0, lib_1.startDevRemotes)(remotes, workspaceProjects, options, context);
73
74
  const staticRemotesIter = remotes.staticRemotes.length > 0
74
- ? (0, lib_1.startStaticRemotesFileServer)(remotes, context, options)
75
+ ? (0, lib_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options)
75
76
  : undefined;
76
77
  const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
77
78
  ...v,
@@ -100,8 +101,10 @@ async function* moduleFederationDevServerExecutor(schema, context) {
100
101
  devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
101
102
  next({ success: true, baseUrl: `http://localhost:${options.port}` });
102
103
  }
103
- catch {
104
- 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
+ });
105
108
  }
106
109
  finally {
107
110
  done();
@@ -7,6 +7,9 @@
7
7
  "files": [],
8
8
  "include": [],
9
9
  "references": [
10
+ {
11
+ "path": "./tsconfig.editor.json"
12
+ },
10
13
  {
11
14
  "path": "./tsconfig.app.json"
12
15
  }
@@ -699,7 +699,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
699
699
  You can activate distributed tasks executions and caching by
700
700
  running:
701
701
  </p>
702
- <pre>nx connect-to-nx-cloud</pre>
702
+ <pre>nx connect</pre>
703
703
  <a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
704
704
  </div>
705
705
  <a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
@@ -702,7 +702,7 @@ import { CommonModule } from '@angular/common';
702
702
  You can activate distributed tasks executions and caching by
703
703
  running:
704
704
  </p>
705
- <pre>nx connect-to-nx-cloud</pre>
705
+ <pre>nx connect</pre>
706
706
  <a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
707
707
  </div>
708
708
  <a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const create_ts_config_1 = require("../../utils/create-ts-config");
6
+ const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
7
7
  const test_runners_1 = require("../../../utils/test-runners");
8
8
  const version_utils_1 = require("../../utils/version-utils");
9
9
  async function createFiles(tree, options, rootOffset) {
@@ -33,13 +33,7 @@ async function createFiles(tree, options, rootOffset) {
33
33
  else {
34
34
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/ng-module'), options.appProjectRoot, substitutions);
35
35
  }
36
- (0, create_ts_config_1.createTsConfig)(tree, options.appProjectRoot, 'app', {
37
- bundler: options.bundler,
38
- rootProject: options.rootProject,
39
- strict: options.strict,
40
- style: options.style,
41
- esModuleInterop: isUsingApplicationBuilder,
42
- }, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot));
36
+ (0, update_project_root_tsconfig_1.updateProjectRootTsConfig)(tree, options.appProjectRoot, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot), options.rootProject);
43
37
  if (!options.routing) {
44
38
  tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, '/src/app/app.routes.ts'));
45
39
  }
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import { type Tree } from '@nx/devkit';
2
2
  import type { NormalizedSchema } from './normalized-schema';
3
3
  export declare function updateEditorTsConfig(tree: Tree, options: NormalizedSchema): void;
@@ -2,24 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateEditorTsConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const update_app_editor_tsconfig_excluded_files_1 = require("../../utils/update-app-editor-tsconfig-excluded-files");
5
6
  function getCompilerOptionsTypes(tsConfig) {
6
7
  return tsConfig?.compilerOptions?.types ?? [];
7
8
  }
8
9
  function updateEditorTsConfig(tree, options) {
9
- const types = getCompilerOptionsTypes((0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json')));
10
- if (options.unitTestRunner !== 'none') {
11
- types.push(...getCompilerOptionsTypes((0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'))));
12
- }
13
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.editor.json'), (json) => {
14
- json.compilerOptions.types = types;
15
- return json;
16
- });
17
- // This should be the last tsconfig references so it's not in the template
18
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
19
- json.references.push({
20
- path: './tsconfig.editor.json',
10
+ const appTsConfig = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'));
11
+ const types = getCompilerOptionsTypes(appTsConfig);
12
+ if (types?.length) {
13
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.editor.json'), (json) => {
14
+ json.compilerOptions ??= {};
15
+ json.compilerOptions.types = Array.from(new Set(types));
16
+ return json;
21
17
  });
22
- return json;
23
- });
18
+ }
19
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
20
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, project);
24
21
  }
25
22
  exports.updateEditorTsConfig = updateEditorTsConfig;
@@ -10,6 +10,7 @@ const component_test_1 = require("../component-test/component-test");
10
10
  const component_info_1 = require("../utils/storybook-ast/component-info");
11
11
  const entry_point_1 = require("../utils/storybook-ast/entry-point");
12
12
  const module_info_1 = require("../utils/storybook-ast/module-info");
13
+ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app-editor-tsconfig-excluded-files");
13
14
  function cypressComponentConfiguration(tree, options) {
14
15
  return cypressComponentConfigurationInternal(tree, {
15
16
  addPlugin: false,
@@ -31,6 +32,9 @@ async function cypressComponentConfigurationInternal(tree, options) {
31
32
  });
32
33
  await configureCypressCT(tree, options);
33
34
  await addFiles(tree, projectConfig, options);
35
+ if (projectConfig.projectType === 'application') {
36
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, projectConfig);
37
+ }
34
38
  if (!options.skipFormat) {
35
39
  await (0, devkit_1.formatFiles)(tree);
36
40
  }
@@ -4,10 +4,6 @@ exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
6
6
  function addProject(tree, libraryOptions) {
7
- const executor = libraryOptions.publishable
8
- ? '@nx/angular:package'
9
- : '@nx/angular:ng-packagr-lite';
10
- (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
11
7
  const project = {
12
8
  name: libraryOptions.name,
13
9
  root: libraryOptions.projectRoot,
@@ -15,27 +11,30 @@ function addProject(tree, libraryOptions) {
15
11
  prefix: libraryOptions.prefix,
16
12
  tags: libraryOptions.parsedTags,
17
13
  projectType: 'library',
18
- targets: {
19
- build: libraryOptions.buildable || libraryOptions.publishable
20
- ? {
21
- executor,
22
- outputs: ['{workspaceRoot}/dist/{projectRoot}'],
23
- options: {
24
- project: `${libraryOptions.projectRoot}/ng-package.json`,
25
- },
26
- configurations: {
27
- production: {
28
- tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.prod.json`,
29
- },
30
- development: {
31
- tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
32
- },
33
- },
34
- defaultConfiguration: 'production',
35
- }
36
- : undefined,
37
- },
14
+ targets: {},
38
15
  };
16
+ if (libraryOptions.buildable || libraryOptions.publishable) {
17
+ const executor = libraryOptions.publishable
18
+ ? '@nx/angular:package'
19
+ : '@nx/angular:ng-packagr-lite';
20
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
21
+ project.targets.build = {
22
+ executor,
23
+ outputs: ['{workspaceRoot}/dist/{projectRoot}'],
24
+ options: {
25
+ project: `${libraryOptions.projectRoot}/ng-package.json`,
26
+ },
27
+ configurations: {
28
+ production: {
29
+ tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.prod.json`,
30
+ },
31
+ development: {
32
+ tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
33
+ },
34
+ },
35
+ defaultConfiguration: 'production',
36
+ };
37
+ }
39
38
  (0, devkit_1.addProjectConfiguration)(tree, libraryOptions.name, project);
40
39
  return project;
41
40
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTsConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const create_ts_config_1 = require("../../utils/create-ts-config");
6
+ const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
7
7
  function updateProjectConfig(host, options) {
8
8
  (0, devkit_1.updateJson)(host, `${options.projectRoot}/tsconfig.lib.json`, (json) => {
9
9
  json.include = ['src/**/*.ts'];
@@ -18,7 +18,7 @@ function updateProjectConfig(host, options) {
18
18
  return json;
19
19
  });
20
20
  // tsconfig.json
21
- (0, create_ts_config_1.createTsConfig)(host, options.projectRoot, 'lib', options, (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot));
21
+ (0, update_project_root_tsconfig_1.updateProjectRootTsConfig)(host, options.projectRoot, (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot));
22
22
  }
23
23
  function updateProjectIvyConfig(host, options) {
24
24
  if (options.buildable || options.publishable) {
@@ -30,7 +30,7 @@ function updateProjectIvyConfig(host, options) {
30
30
  }
31
31
  }
32
32
  function updateTsConfig(host, options) {
33
- (0, create_ts_config_1.extractTsConfigBase)(host);
33
+ (0, update_project_root_tsconfig_1.extractTsConfigBase)(host);
34
34
  updateProjectConfig(host, options);
35
35
  updateProjectIvyConfig(host, options);
36
36
  }
@@ -1 +1 @@
1
- export { <%= rootModuleClassName %> } from './app/<%= rootModuleFileName.slice(0, -3) %>';
1
+ export { <%= rootModuleClassName %> as default } from './app/<%= rootModuleFileName.slice(0, -3) %>';
@@ -3,7 +3,7 @@ import { CommonEngine } from '@angular/ssr';
3
3
  import express from 'express';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { dirname, join, resolve } from 'node:path';
6
- import <% if (standalone) { %>bootstrap<% } else { %>{ <%= rootModuleClassName %> }<% } %> from './src/<%= main.slice(0, -3) %>';
6
+ import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><% } %> from './src/<%= main.slice(0, -3) %>';
7
7
 
8
8
  // The Express app is exported so that it can be used by serverless Functions.
9
9
  export function app(): express.Express {
@@ -5,7 +5,7 @@ import { ngExpressEngine } from '@nguniversal/express-engine';
5
5
  import * as express from 'express';
6
6
  import { existsSync } from 'fs';
7
7
  import { join } from 'path';
8
- import <% if (standalone) { %>bootstrap<% } else { %>{ <%= rootModuleClassName %> }<% } %> from './src/<%= main.slice(0, -3) %>';
8
+ import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><% } %> from './src/<%= main.slice(0, -3) %>';
9
9
 
10
10
  // The Express app is exported so that it can be used by serverless Functions.
11
11
  export function app(): express.Express {
@@ -5,7 +5,7 @@ import { CommonEngine } from '@angular/ssr';
5
5
  import * as express from 'express';
6
6
  import { existsSync } from 'node:fs';
7
7
  import { join } from 'node:path';
8
- import <% if (standalone) { %>bootstrap<% } else { %>{ <%= rootModuleClassName %> }<% } %> from './src/<%= main.slice(0, -3) %>';
8
+ import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><% } %> from './src/<%= main.slice(0, -3) %>';
9
9
 
10
10
  // The Express app is exported so that it can be used by serverless Functions.
11
11
  export function app(): express.Express {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storybookConfigurationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const update_app_editor_tsconfig_excluded_files_1 = require("../utils/update-app-editor-tsconfig-excluded-files");
5
6
  const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-storybook-version");
6
7
  const generate_stories_1 = require("./lib/generate-stories");
7
8
  const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
@@ -22,6 +23,10 @@ async function storybookConfigurationGenerator(tree, options) {
22
23
  skipFormat: true,
23
24
  });
24
25
  }
26
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
27
+ if (project.projectType === 'application') {
28
+ (0, update_app_editor_tsconfig_excluded_files_1.updateAppEditorTsConfigExcludedFiles)(tree, project);
29
+ }
25
30
  if (!options.skipFormat) {
26
31
  await (0, devkit_1.formatFiles)(tree);
27
32
  }
@@ -0,0 +1,2 @@
1
+ import { type ProjectConfiguration, type Tree } from '@nx/devkit';
2
+ export declare function updateAppEditorTsConfigExcludedFiles(tree: Tree, projectConfig: ProjectConfiguration): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAppEditorTsConfigExcludedFiles = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function updateAppEditorTsConfigExcludedFiles(tree, projectConfig) {
6
+ if (projectConfig.projectType !== 'application') {
7
+ return;
8
+ }
9
+ const editorTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.editor.json');
10
+ const appTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.app.json');
11
+ if (!tree.exists(editorTsConfigPath) || !tree.exists(appTsConfigPath)) {
12
+ return;
13
+ }
14
+ const appTsConfig = (0, devkit_1.readJson)(tree, appTsConfigPath);
15
+ (0, devkit_1.updateJson)(tree, editorTsConfigPath, (json) => {
16
+ const exclude = [...(json.exclude ?? []), ...(appTsConfig.exclude ?? [])];
17
+ if (exclude.length) {
18
+ json.exclude = Array.from(new Set(exclude));
19
+ }
20
+ return json;
21
+ });
22
+ }
23
+ exports.updateAppEditorTsConfigExcludedFiles = updateAppEditorTsConfigExcludedFiles;
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export { extractTsConfigBase } from '@nx/js';
3
+ export declare function updateProjectRootTsConfig(host: Tree, projectRoot: string, relativePathToRootTsConfig: string, isRootProject?: boolean): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProjectRootTsConfig = exports.extractTsConfigBase = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ var js_2 = require("@nx/js");
7
+ Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
8
+ function updateProjectRootTsConfig(host, projectRoot, relativePathToRootTsConfig, isRootProject) {
9
+ (0, devkit_1.updateJson)(host, `${projectRoot}/tsconfig.json`, (json) => {
10
+ if (isRootProject) {
11
+ // inline tsconfig.base.json into the project
12
+ json.compileOnSave = false;
13
+ json.compilerOptions = {
14
+ ...js_1.tsConfigBaseOptions,
15
+ ...json.compilerOptions,
16
+ };
17
+ json.exclude = ['node_modules', 'tmp'];
18
+ delete json.extends;
19
+ }
20
+ else {
21
+ json.extends = relativePathToRootTsConfig;
22
+ }
23
+ return json;
24
+ });
25
+ }
26
+ exports.updateProjectRootTsConfig = updateProjectRootTsConfig;
@@ -1,9 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export { extractTsConfigBase } from '@nx/js';
3
- export declare function createTsConfig(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
4
- strict?: boolean;
5
- style?: string;
6
- bundler?: string;
7
- rootProject?: boolean;
8
- esModuleInterop?: boolean;
9
- }, relativePathToRootTsConfig: string): void;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTsConfig = exports.extractTsConfigBase = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const js_1 = require("@nx/js");
6
- var js_2 = require("@nx/js");
7
- Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
8
- function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
9
- const json = {
10
- compilerOptions: {
11
- target: 'es2022',
12
- useDefineForClassFields: false,
13
- esModuleInterop: options.esModuleInterop ? true : undefined,
14
- },
15
- files: [],
16
- include: [],
17
- references: [
18
- {
19
- path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
20
- },
21
- ],
22
- };
23
- // inline tsconfig.base.json into the project
24
- if (options.rootProject) {
25
- json.compileOnSave = false;
26
- json.compilerOptions = { ...js_1.tsConfigBaseOptions, ...json.compilerOptions };
27
- json.exclude = ['node_modules', 'tmp'];
28
- }
29
- else {
30
- json.extends = relativePathToRootTsConfig;
31
- }
32
- (0, devkit_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
33
- }
34
- exports.createTsConfig = createTsConfig;