@nx/angular 19.6.0-canary.20240813-c72ba9b → 19.6.0-rc.0

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 (47) hide show
  1. package/esm2022/src/runtime/nx/data-persistence.mjs +9 -4
  2. package/esm2022/testing/src/testing-utils.mjs +5 -3
  3. package/executors.d.ts +1 -1
  4. package/executors.js +1 -1
  5. package/executors.json +5 -5
  6. package/fesm2022/nx-angular-testing.mjs +4 -2
  7. package/fesm2022/nx-angular-testing.mjs.map +1 -1
  8. package/fesm2022/nx-angular.mjs +8 -3
  9. package/fesm2022/nx-angular.mjs.map +1 -1
  10. package/migrations.json +76 -0
  11. package/package.json +8 -8
  12. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.d.ts +4 -0
  13. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.js +65 -0
  14. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +2 -0
  15. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +19 -0
  16. package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +5 -0
  17. package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.js +30 -0
  18. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.d.ts +9 -0
  19. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.js +37 -0
  20. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +4 -0
  21. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +101 -0
  22. package/src/{builders/module-federation-dev-ssr → executors/module-federation-ssr-dev-server}/schema.d.ts +7 -1
  23. package/src/{builders/module-federation-dev-ssr → executors/module-federation-ssr-dev-server}/schema.json +34 -2
  24. package/src/executors/utilities/esbuild-extensions.d.ts +2 -1
  25. package/src/generators/component-cypress-spec/schema.json +2 -1
  26. package/src/generators/host/files/js/webpack.server.config.js__tmpl__ +6 -1
  27. package/src/generators/host/files/ts/webpack.server.config.ts__tmpl__ +6 -1
  28. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -1
  29. package/src/generators/ng-add/migrators/projects/project.migrator.d.ts +2 -0
  30. package/src/generators/ng-add/migrators/projects/project.migrator.js +38 -1
  31. package/src/generators/remote/files/base/webpack.server.config.js__tmpl__ +7 -1
  32. package/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +6 -1
  33. package/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +6 -1
  34. package/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +6 -1
  35. package/src/generators/setup-mf/files/webpack/webpack.config.js__tmpl__ +7 -1
  36. package/src/generators/setup-mf/files/webpack/webpack.prod.config.js__tmpl__ +7 -1
  37. package/src/generators/stories/schema.json +4 -2
  38. package/src/migrations/update-19-6-0/turn-off-dts-by-default.d.ts +2 -0
  39. package/src/migrations/update-19-6-0/turn-off-dts-by-default.js +56 -0
  40. package/src/migrations/update-19-6-0/update-angular-cli.d.ts +3 -0
  41. package/src/migrations/update-19-6-0/update-angular-cli.js +23 -0
  42. package/src/runtime/nx/data-persistence.d.ts +8 -3
  43. package/src/utils/versions.d.ts +3 -3
  44. package/src/utils/versions.js +3 -3
  45. package/testing/src/testing-utils.d.ts +4 -2
  46. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.d.ts +0 -4
  47. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +0 -103
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildStaticRemotes = buildStaticRemotes;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_path_1 = require("node:path");
8
+ const node_fs_1 = require("node:fs");
9
+ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
10
+ if (!staticRemotesConfig.remotes.length) {
11
+ return;
12
+ }
13
+ const mappedLocationOfRemotes = {};
14
+ for (const app of staticRemotesConfig.remotes) {
15
+ mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
16
+ }
17
+ await new Promise((resolve, reject) => {
18
+ devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
19
+ const staticProcess = (0, node_child_process_1.fork)(nxBin, [
20
+ 'run-many',
21
+ `--target=server`,
22
+ `--projects=${staticRemotesConfig.remotes.join(',')}`,
23
+ ...(context.configurationName
24
+ ? [`--configuration=${context.configurationName}`]
25
+ : []),
26
+ ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
27
+ ], {
28
+ cwd: context.root,
29
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
30
+ });
31
+ // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
32
+ const remoteBuildLogFile = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
33
+ const stdoutStream = (0, node_fs_1.createWriteStream)(remoteBuildLogFile);
34
+ staticProcess.stdout.on('data', (data) => {
35
+ const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
36
+ const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
37
+ stdoutStream.write(stdoutString);
38
+ // in addition to writing into the stdout stream, also show error directly in console
39
+ // so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
40
+ if (stdoutString.includes('ERROR in')) {
41
+ devkit_1.logger.log(stdoutString);
42
+ }
43
+ if (stdoutString.includes('Successfully ran target server')) {
44
+ staticProcess.stdout.removeAllListeners('data');
45
+ devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
46
+ resolve();
47
+ }
48
+ });
49
+ staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
50
+ staticProcess.once('exit', (code) => {
51
+ stdoutStream.end();
52
+ staticProcess.stdout.removeAllListeners('data');
53
+ staticProcess.stderr.removeAllListeners('data');
54
+ if (code !== 0) {
55
+ reject(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
56
+ }
57
+ else {
58
+ resolve();
59
+ }
60
+ });
61
+ process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
62
+ process.on('exit', () => staticProcess.kill('SIGTERM'));
63
+ });
64
+ return mappedLocationOfRemotes;
65
+ }
@@ -0,0 +1,2 @@
1
+ import type { Schema } from '../schema';
2
+ export declare function normalizeOptions(options: Schema): Schema;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = normalizeOptions;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ function normalizeOptions(options) {
7
+ const devServeRemotes = !options.devRemotes
8
+ ? []
9
+ : Array.isArray(options.devRemotes)
10
+ ? options.devRemotes
11
+ : [options.devRemotes];
12
+ return {
13
+ ...options,
14
+ devRemotes: devServeRemotes,
15
+ ssl: options.ssl ?? false,
16
+ sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
17
+ sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
18
+ };
19
+ }
@@ -0,0 +1,5 @@
1
+ import { type Schema } from '../schema';
2
+ import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
3
+ export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Schema, context: ExecutorContext): Promise<AsyncIterable<{
4
+ success: boolean;
5
+ }>[]>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startRemotes = startRemotes;
4
+ const devkit_1 = require("@nx/devkit");
5
+ async function startRemotes(remotes, workspaceProjects, options, context) {
6
+ const target = 'serve-ssr';
7
+ const remoteIters = [];
8
+ for (const app of remotes) {
9
+ if (!workspaceProjects[app].targets?.[target]) {
10
+ throw new Error(`Could not find "${target}" target in "${app}" project.`);
11
+ }
12
+ else if (!workspaceProjects[app].targets?.[target].executor) {
13
+ throw new Error(`Could not find executor for "${target}" target in "${app}" project.`);
14
+ }
15
+ const [_, executor] = workspaceProjects[app].targets[target].executor.split(':');
16
+ const isUsingModuleFederationSsrDevServerExecutor = executor.includes('module-federation-dev-ssr');
17
+ const configurationOverride = options.devRemotes.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
18
+ remoteIters.push(await (0, devkit_1.runExecutor)({
19
+ project: app,
20
+ target,
21
+ configuration: configurationOverride ?? context.configurationName,
22
+ }, {
23
+ ...{ verbose: options.verbose ?? false },
24
+ ...(isUsingModuleFederationSsrDevServerExecutor
25
+ ? { isInitialHost: false }
26
+ : {}),
27
+ }, context));
28
+ }
29
+ return remoteIters;
30
+ }
@@ -0,0 +1,9 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import { type Schema } from '../schema';
3
+ import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
4
+ export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
5
+ success: boolean;
6
+ baseUrl: string;
7
+ }, {
8
+ success: boolean;
9
+ }, unknown>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startStaticRemotes = startStaticRemotes;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
7
+ const path_1 = require("path");
8
+ const fs_1 = require("fs");
9
+ function startStaticRemotes(ssrStaticRemotesConfig, context, options) {
10
+ if (ssrStaticRemotesConfig.remotes.length === 0) {
11
+ return;
12
+ }
13
+ // The directories are usually generated with /browser and /server suffixes so we need to copy them to a common directory
14
+ const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
15
+ for (const app of ssrStaticRemotesConfig.remotes) {
16
+ const remoteConfig = ssrStaticRemotesConfig.config[app];
17
+ (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
18
+ force: true,
19
+ recursive: true,
20
+ });
21
+ }
22
+ const staticRemotesIter = (0, file_server_impl_1.default)({
23
+ cors: true,
24
+ watch: false,
25
+ staticFilePath: commonOutputDirectory,
26
+ parallel: false,
27
+ spa: false,
28
+ withDeps: false,
29
+ host: options.host,
30
+ port: options.staticRemotesPort,
31
+ ssl: options.ssl,
32
+ sslCert: options.sslCert,
33
+ sslKey: options.sslKey,
34
+ cacheSeconds: -1,
35
+ }, context);
36
+ return staticRemotesIter;
37
+ }
@@ -0,0 +1,4 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import type { Schema } from './schema';
3
+ export declare function moduleFederationSsrDevServerExecutor(schema: Schema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
4
+ export default moduleFederationSsrDevServerExecutor;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moduleFederationSsrDevServerExecutor = moduleFederationSsrDevServerExecutor;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const fs_1 = require("fs");
6
+ const project_graph_1 = require("nx/src/project-graph/project-graph");
7
+ const path_1 = require("path");
8
+ const module_federation_1 = require("../../builders/utilities/module-federation");
9
+ const module_federation_2 = require("@nx/webpack/src/utils/module-federation");
10
+ const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
11
+ const build_static_remotes_1 = require("./lib/build-static-remotes");
12
+ const start_dev_remotes_1 = require("./lib/start-dev-remotes");
13
+ const start_static_remotes_1 = require("./lib/start-static-remotes");
14
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
15
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
16
+ const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
17
+ const normalize_options_1 = require("./lib/normalize-options");
18
+ const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
19
+ const start_ssr_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-ssr-remote-proxies");
20
+ const dev_server_impl_1 = require("../../builders/dev-server/dev-server.impl");
21
+ async function* moduleFederationSsrDevServerExecutor(schema, context) {
22
+ const nxBin = require.resolve('nx/bin/nx');
23
+ const options = (0, normalize_options_1.normalizeOptions)(schema);
24
+ const currIter = (0, rxjs_for_await_1.eachValueFrom)((0, dev_server_impl_1.executeDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
25
+ builderName: '@nx/angular:webpack-server',
26
+ description: 'Build a ssr application',
27
+ optionSchema: require('../../builders/webpack-server/schema.json'),
28
+ }, context)));
29
+ if (options.isInitialHost === false) {
30
+ return yield* currIter;
31
+ }
32
+ const { projects: workspaceProjects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
33
+ const project = workspaceProjects[context.projectName];
34
+ let pathToManifestFile;
35
+ if (options.pathToManifestFile) {
36
+ const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
37
+ if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
38
+ throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
39
+ }
40
+ else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
41
+ throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
42
+ }
43
+ pathToManifestFile = userPathToManifestFile;
44
+ }
45
+ else {
46
+ pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
47
+ }
48
+ (0, module_federation_1.validateDevRemotes)({ devRemotes: options.devRemotes }, workspaceProjects);
49
+ const moduleFederationConfig = (0, module_federation_2.getModuleFederationConfig)(project.targets.build.options.tsConfig, context.root, project.root, 'angular');
50
+ const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
51
+ const remotes = (0, module_federation_2.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
52
+ projectName: project.name,
53
+ projectGraph: context.projectGraph,
54
+ root: context.root,
55
+ }, pathToManifestFile);
56
+ options.staticRemotesPort ??= remotes.staticRemotePort;
57
+ const staticRemotesConfig = (0, parse_static_remotes_config_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
58
+ const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
59
+ // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
60
+ process.env.NX_MF_DEV_REMOTES = JSON.stringify(options.devRemotes);
61
+ const devRemotes = await (0, start_dev_remotes_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context);
62
+ const staticRemotes = (0, start_static_remotes_1.startStaticRemotes)(staticRemotesConfig, context, options);
63
+ (0, start_ssr_remote_proxies_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
64
+ ? { pathToCert: options.sslCert, pathToKey: options.sslKey }
65
+ : undefined);
66
+ const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
67
+ ...v,
68
+ baseUrl: undefined,
69
+ }));
70
+ return yield* (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemotes.map(removeBaseUrlEmission), ...(staticRemotes ? [removeBaseUrlEmission(staticRemotes)] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
71
+ if (!options.isInitialHost) {
72
+ done();
73
+ return;
74
+ }
75
+ if (remotes.remotePorts.length) {
76
+ devkit_1.logger.info(`Nx All remotes started, server ready at http://localhost:${options.port}`);
77
+ next({ success: true, baseUrl: `http://localhost:${options.port}` });
78
+ done();
79
+ return;
80
+ }
81
+ try {
82
+ const portsToWaitFor = staticRemotes
83
+ ? [options.staticRemotesPort, ...remotes.remotePorts]
84
+ : [...remotes.remotePorts];
85
+ await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
86
+ retries: 480,
87
+ retryDelay: 2500,
88
+ host: 'localhost',
89
+ })));
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Failed to start remotes. Check above for any errors.`, {
93
+ cause: error,
94
+ });
95
+ }
96
+ finally {
97
+ done();
98
+ }
99
+ }));
100
+ }
101
+ exports.default = moduleFederationSsrDevServerExecutor;
@@ -1,3 +1,5 @@
1
+ import { type DevRemoteDefinition } from '../../builders/utilities/module-federation';
2
+
1
3
  export interface Schema {
2
4
  browserTarget: string;
3
5
  serverTarget: string;
@@ -10,8 +12,12 @@ export interface Schema {
10
12
  sslKey?: string;
11
13
  sslCert?: string;
12
14
  proxyConfig?: string;
13
- devRemotes?: string[];
15
+ devRemotes?: DevRemoteDefinition[];
14
16
  skipRemotes?: string[];
15
17
  verbose: boolean;
16
18
  pathToManifestFile?: string;
19
+ parallel?: number;
20
+ staticRemotesPort?: number;
21
+ parallel?: number;
22
+ isInitialHost?: boolean;
17
23
  }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "title": "Module Federation SSR Dev Server Target",
4
- "description": "Serves host [Module Federation](https://module-federation.io/) applications ([webpack](https://webpack.js.org/)-based) that use SSR allowing to specify which remote applications should be served with the host.",
4
+ "outputCapture": "direct-nodejs",
5
+ "description": "The module-federation-ssr-dev-server executor is reserved exclusively for use with host SSR Module Federation applications. It allows the user to specify which remote applications should be served with the host.",
5
6
  "type": "object",
6
7
  "properties": {
7
8
  "browserTarget": {
@@ -63,7 +64,24 @@
63
64
  "devRemotes": {
64
65
  "type": "array",
65
66
  "items": {
66
- "type": "string"
67
+ "oneOf": [
68
+ {
69
+ "type": "string"
70
+ },
71
+ {
72
+ "type": "object",
73
+ "properties": {
74
+ "remoteName": {
75
+ "type": "string"
76
+ },
77
+ "configuration": {
78
+ "type": "string"
79
+ }
80
+ },
81
+ "required": ["remoteName"],
82
+ "additionalProperties": false
83
+ }
84
+ ]
67
85
  },
68
86
  "description": "List of remote applications to run in development mode (i.e. using serve target).",
69
87
  "x-priority": "important"
@@ -83,6 +101,20 @@
83
101
  "pathToManifestFile": {
84
102
  "type": "string",
85
103
  "description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic remote applications relative to the workspace root."
104
+ },
105
+ "isInitialHost": {
106
+ "type": "boolean",
107
+ "description": "Whether the host that is running this executor is the first in the project tree to do so.",
108
+ "default": true,
109
+ "x-priority": "internal"
110
+ },
111
+ "parallel": {
112
+ "type": "number",
113
+ "description": "Max number of parallel processes for building static remotes"
114
+ },
115
+ "staticRemotesPort": {
116
+ "type": "number",
117
+ "description": "The port at which to serve the file-server for the static remotes."
86
118
  }
87
119
  },
88
120
  "additionalProperties": false,
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'esbuild';
1
+ type Plugin = Parameters<typeof import('@angular-devkit/build-angular').buildApplication>[2]['codePlugins'][number];
2
2
  export type PluginSpec = {
3
3
  path: string;
4
4
  options: any;
@@ -6,3 +6,4 @@ export type PluginSpec = {
6
6
  export declare function loadPlugins(plugins: string[] | PluginSpec[] | undefined, tsConfig: string): Promise<Plugin[]>;
7
7
  export declare function loadMiddleware(middlewareFns: string[] | undefined, tsConfig: string): Promise<any[]>;
8
8
  export declare function loadIndexHtmlTransformer(indexHtmlTransformerPath: string, tsConfig: string): Promise<any>;
9
+ export {};
@@ -3,7 +3,8 @@
3
3
  "$id": "NxAngularComponentCypressSpecGenerator",
4
4
  "type": "object",
5
5
  "cli": "nx",
6
- "description": "Creates a Cypress spec for a UI component that has a story.",
6
+ "description": "Creates a Storybook Cypress spec for a UI component that has a story.",
7
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20.",
7
8
  "properties": {
8
9
  "projectName": {
9
10
  "type": "string",
@@ -1,3 +1,8 @@
1
1
  const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederationForSSR(config)
3
+ /**
4
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
5
+ * The DTS Plugin can be enabled by setting dts: true
6
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
7
+ */
8
+ module.exports = withModuleFederationForSSR(config, { dts: false });
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederationForSSR } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederationForSSR(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederationForSSR(config, { dts: false });
@@ -254,7 +254,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
254
254
  this.tree.delete(newTsConfigPath);
255
255
  this.moveFile((0, devkit_1.joinPathFragments)(this.project.oldSourceRoot, 'tsconfig.json'), newTsConfigPath);
256
256
  // replace the generated source with the project source
257
- (0, devkit_1.visitNotIgnoredFiles)(this.tree, this.project.newSourceRoot, (filePath) => {
257
+ this.visitFiles(this.project.newSourceRoot, (filePath) => {
258
258
  this.tree.delete(filePath);
259
259
  });
260
260
  this.moveDir(this.project.oldSourceRoot, (0, devkit_1.joinPathFragments)(this.project.newSourceRoot));
@@ -18,6 +18,8 @@ export declare class ProjectMigrator<TargetType extends string = string> extends
18
18
  protected convertPath(originalPath: string): string;
19
19
  protected moveDir(from: string, to: string): void;
20
20
  protected shouldSkipTargetTypeMigration(targetType: TargetType): boolean;
21
+ protected visitFiles(dirPath: string, visitor: (path: string) => void): void;
22
+ private updateGitAndPrettierIgnore;
21
23
  private collectTargetNames;
22
24
  private createBuilderMigrators;
23
25
  private skipProjectMigration;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectMigrator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const node_path_1 = require("node:path");
5
6
  const utilities_1 = require("../../utilities");
6
7
  const migrator_1 = require("../migrator");
7
8
  class ProjectMigrator extends migrator_1.Migrator {
@@ -42,6 +43,7 @@ class ProjectMigrator extends migrator_1.Migrator {
42
43
  migrate() {
43
44
  const validationResult = this.validate();
44
45
  if (!validationResult) {
46
+ this.updateGitAndPrettierIgnore();
45
47
  return;
46
48
  }
47
49
  this.logger.warn((0, utilities_1.getProjectValidationResultMessage)(validationResult));
@@ -138,7 +140,7 @@ class ProjectMigrator extends migrator_1.Migrator {
138
140
  return originalPath;
139
141
  }
140
142
  moveDir(from, to) {
141
- (0, devkit_1.visitNotIgnoredFiles)(this.tree, from, (file) => {
143
+ this.visitFiles(from, (file) => {
142
144
  this.moveFile(file, (0, devkit_1.normalizePath)(file).replace(from, to), true);
143
145
  });
144
146
  }
@@ -146,6 +148,41 @@ class ProjectMigrator extends migrator_1.Migrator {
146
148
  return (Array.isArray(this.skipMigration) &&
147
149
  this.skipMigration.includes(targetType));
148
150
  }
151
+ visitFiles(dirPath, visitor) {
152
+ dirPath = (0, devkit_1.normalizePath)((0, node_path_1.relative)(this.tree.root, (0, devkit_1.joinPathFragments)(this.tree.root, dirPath)));
153
+ for (const child of this.tree.children(dirPath)) {
154
+ const fullPath = (0, devkit_1.joinPathFragments)(dirPath, child);
155
+ if (this.tree.isFile(fullPath)) {
156
+ visitor(fullPath);
157
+ }
158
+ else {
159
+ this.visitFiles(fullPath, visitor);
160
+ }
161
+ }
162
+ }
163
+ updateGitAndPrettierIgnore() {
164
+ if (!this.tree.exists('.prettierignore') &&
165
+ !this.tree.exists('.gitignore')) {
166
+ return;
167
+ }
168
+ let from = this.project.oldRoot;
169
+ let to = this.project.newRoot;
170
+ if (this.project.oldRoot === '') {
171
+ from = this.project.oldSourceRoot;
172
+ to = this.project.newSourceRoot;
173
+ }
174
+ const regex = new RegExp(`(^!?\\/?)(${from})(\\/|$)`, 'gm');
175
+ if (this.tree.exists('.gitignore')) {
176
+ const gitignore = this.tree.read('.gitignore', 'utf-8');
177
+ const content = gitignore.replace(regex, `$1${to}$3`);
178
+ this.tree.write('.gitignore', content);
179
+ }
180
+ if (this.tree.exists('.prettierignore')) {
181
+ const prettierIgnore = this.tree.read('.prettierignore', 'utf-8');
182
+ const content = prettierIgnore.replace(regex, `$1${to}$3`);
183
+ this.tree.write('.prettierignore', content);
184
+ }
185
+ }
149
186
  collectTargetNames() {
150
187
  const targetTypes = Object.keys(this.targets);
151
188
  Object.entries(this.projectConfig.targets ?? {}).forEach(([targetName, target]) => {
@@ -1,3 +1,9 @@
1
1
  const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederationForSSR(config)
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ module.exports = withModuleFederationForSSR(config, { dts: false })
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederationForSSR } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederationForSSR(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederationForSSR(config, { dts: false });
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederation } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederation(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederation(config, { dts: false });
@@ -1,6 +1,11 @@
1
1
  import { withModuleFederation } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
4
9
  export default withModuleFederation({
5
10
  ...config,
6
11
  /*
@@ -13,4 +18,4 @@ export default withModuleFederation({
13
18
  * ['app2', 'https://app2.example.com'],
14
19
  * ]
15
20
  */
16
- });
21
+ }, { dts: false });
@@ -1,3 +1,9 @@
1
1
  const { withModuleFederation } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederation(config);
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ module.exports = withModuleFederation(config, { dts: false });
@@ -1,5 +1,11 @@
1
1
  const { withModuleFederation } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
3
9
  module.exports = withModuleFederation({
4
10
  ...config,
5
11
  /*
@@ -12,4 +18,4 @@ module.exports = withModuleFederation({
12
18
  * ['app2', 'https://app2.example.com'],
13
19
  * ]
14
20
  */
15
- });
21
+ }, { dts: false });
@@ -27,11 +27,13 @@
27
27
  },
28
28
  "generateCypressSpecs": {
29
29
  "type": "boolean",
30
- "description": "Specifies whether to automatically generate `*.spec.ts` files in the Cypress e2e app generated by the `cypress-configure` generator."
30
+ "description": "Specifies whether to automatically generate `*.spec.ts` files in the Cypress e2e app generated by the `cypress-configure` generator.",
31
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
31
32
  },
32
33
  "cypressProject": {
33
34
  "type": "string",
34
- "description": "The Cypress project to generate the stories under. This is inferred from `name` by default."
35
+ "description": "The Cypress project to generate the stories under. This is inferred from `name` by default.",
36
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
35
37
  },
36
38
  "skipFormat": {
37
39
  "description": "Skip formatting files.",
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;