@nx/angular 20.2.0-canary.20241203-6b87005 → 20.2.0-canary.20241204-75b2080
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.
- package/migrations.json +11 -2
- package/package.json +12 -12
- package/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
- package/src/executors/module-federation-dev-server/lib/index.js +0 -2
- package/src/executors/module-federation-dev-server/lib/normalize-options.js +1 -0
- package/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +1 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -26
- package/src/executors/module-federation-dev-server/schema.d.ts +1 -0
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +2 -2
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +1 -0
- package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +1 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +10 -32
- package/src/executors/module-federation-ssr-dev-server/schema.d.ts +6 -0
- package/src/generators/utils/add-jest.js +4 -8
- package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.d.ts +2 -0
- package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.js +55 -0
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +0 -65
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts +0 -9
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +0 -51
- package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.js +0 -65
- package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.js +0 -41
package/migrations.json
CHANGED
|
@@ -292,7 +292,7 @@
|
|
|
292
292
|
"cli": "nx",
|
|
293
293
|
"version": "20.2.0-beta.5",
|
|
294
294
|
"requires": {
|
|
295
|
-
"@angular/core": ">=19.0.0
|
|
295
|
+
"@angular/core": ">=19.0.0"
|
|
296
296
|
},
|
|
297
297
|
"description": "Add the '@angular/localize/init' polyfill to the 'polyfills' option of targets using esbuild-based executors.",
|
|
298
298
|
"factory": "./src/migrations/update-20-2-0/add-localize-polyfill-to-targets"
|
|
@@ -301,10 +301,19 @@
|
|
|
301
301
|
"cli": "nx",
|
|
302
302
|
"version": "20.2.0-beta.5",
|
|
303
303
|
"requires": {
|
|
304
|
-
"@angular/core": ">=19.0.0
|
|
304
|
+
"@angular/core": ">=19.0.0"
|
|
305
305
|
},
|
|
306
306
|
"description": "Update '@angular/ssr' import paths to use the new '/node' entry point when 'CommonEngine' is detected.",
|
|
307
307
|
"factory": "./src/migrations/update-20-2-0/update-angular-ssr-imports-to-use-node-entry-point"
|
|
308
|
+
},
|
|
309
|
+
"disable-angular-eslint-prefer-standalone": {
|
|
310
|
+
"cli": "nx",
|
|
311
|
+
"version": "20.2.0-beta.6",
|
|
312
|
+
"requires": {
|
|
313
|
+
"@angular/core": ">=19.0.0"
|
|
314
|
+
},
|
|
315
|
+
"description": "Disable the Angular ESLint prefer-standalone rule if not set.",
|
|
316
|
+
"factory": "./src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone"
|
|
308
317
|
}
|
|
309
318
|
},
|
|
310
319
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "20.2.0-canary.
|
|
3
|
+
"version": "20.2.0-canary.20241204-75b2080",
|
|
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, Playwright 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": {
|
|
@@ -71,20 +71,20 @@
|
|
|
71
71
|
"semver": "^7.5.3",
|
|
72
72
|
"tslib": "^2.3.0",
|
|
73
73
|
"webpack-merge": "^5.8.0",
|
|
74
|
-
"@nx/devkit": "20.2.0-canary.
|
|
75
|
-
"@nx/js": "20.2.0-canary.
|
|
76
|
-
"@nx/eslint": "20.2.0-canary.
|
|
77
|
-
"@nx/webpack": "20.2.0-canary.
|
|
78
|
-
"@nx/module-federation": "20.2.0-canary.
|
|
79
|
-
"@nx/web": "20.2.0-canary.
|
|
80
|
-
"@nx/workspace": "20.2.0-canary.
|
|
74
|
+
"@nx/devkit": "20.2.0-canary.20241204-75b2080",
|
|
75
|
+
"@nx/js": "20.2.0-canary.20241204-75b2080",
|
|
76
|
+
"@nx/eslint": "20.2.0-canary.20241204-75b2080",
|
|
77
|
+
"@nx/webpack": "20.2.0-canary.20241204-75b2080",
|
|
78
|
+
"@nx/module-federation": "20.2.0-canary.20241204-75b2080",
|
|
79
|
+
"@nx/web": "20.2.0-canary.20241204-75b2080",
|
|
80
|
+
"@nx/workspace": "20.2.0-canary.20241204-75b2080",
|
|
81
81
|
"piscina": "^4.4.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@angular-devkit/build-angular": ">=
|
|
85
|
-
"@angular-devkit/core": ">=
|
|
86
|
-
"@angular-devkit/schematics": ">=
|
|
87
|
-
"@schematics/angular": ">=
|
|
84
|
+
"@angular-devkit/build-angular": ">= 17.0.0 < 20.0.0",
|
|
85
|
+
"@angular-devkit/core": ">= 17.0.0 < 20.0.0",
|
|
86
|
+
"@angular-devkit/schematics": ">= 17.0.0 < 20.0.0",
|
|
87
|
+
"@schematics/angular": ">= 17.0.0 < 20.0.0",
|
|
88
88
|
"rxjs": "^6.5.3 || ^7.5.0"
|
|
89
89
|
},
|
|
90
90
|
"publishConfig": {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./build-static-remotes"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./start-dev-remotes"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
|
|
@@ -21,6 +21,7 @@ function normalizeOptions(schema) {
|
|
|
21
21
|
liveReload: schema.liveReload ?? true,
|
|
22
22
|
open: schema.open ?? false,
|
|
23
23
|
ssl: schema.ssl ?? false,
|
|
24
|
+
verbose: schema.verbose ?? false,
|
|
24
25
|
sslCert: schema.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslCert) : undefined,
|
|
25
26
|
sslKey: schema.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslKey) : undefined,
|
|
26
27
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Schema } from '../schema';
|
|
2
2
|
import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
|
|
3
|
-
export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Schema, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
|
|
3
|
+
export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<Schema, 'devRemotes' | 'verbose'>, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
|
|
4
4
|
success: boolean;
|
|
5
5
|
}>[]>;
|
|
@@ -6,7 +6,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const lib_1 = require("./lib");
|
|
7
7
|
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
8
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
9
|
-
const utils_1 = require("@nx/module-federation/src/utils");
|
|
9
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
10
10
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
11
11
|
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
|
|
12
12
|
const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
|
|
@@ -15,8 +15,6 @@ const module_federation_1 = require("../../builders/utilities/module-federation"
|
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
async function* moduleFederationDevServerExecutor(schema, context) {
|
|
18
|
-
// Force Node to resolve to look for the nx binary that is inside node_modules
|
|
19
|
-
const nxBin = require.resolve('nx/bin/nx');
|
|
20
18
|
const options = (0, lib_1.normalizeOptions)(schema);
|
|
21
19
|
const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
|
|
22
20
|
const project = workspaceProjects[context.projectName];
|
|
@@ -55,29 +53,7 @@ async function* moduleFederationDevServerExecutor(schema, context) {
|
|
|
55
53
|
pathToManifestFile = userPathToManifestFile;
|
|
56
54
|
}
|
|
57
55
|
(0, module_federation_1.validateDevRemotes)(options, workspaceProjects);
|
|
58
|
-
const
|
|
59
|
-
const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
|
|
60
|
-
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
|
61
|
-
projectName: project.name,
|
|
62
|
-
projectGraph: context.projectGraph,
|
|
63
|
-
root: context.root,
|
|
64
|
-
}, pathToManifestFile);
|
|
65
|
-
options.staticRemotesPort ??= remotes.staticRemotePort;
|
|
66
|
-
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
|
67
|
-
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
|
|
68
|
-
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
|
69
|
-
project.name.replace(/-/g, '_'),
|
|
70
|
-
]);
|
|
71
|
-
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
72
|
-
const mappedLocationsOfStaticRemotes = await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
|
73
|
-
const devRemoteIters = await (0, lib_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context, 'serve');
|
|
74
|
-
const staticRemotesIter = (0, lib_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options);
|
|
75
|
-
(0, utils_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
76
|
-
? {
|
|
77
|
-
pathToCert: options.sslCert,
|
|
78
|
-
pathToKey: options.sslKey,
|
|
79
|
-
}
|
|
80
|
-
: undefined);
|
|
56
|
+
const { remotes, staticRemotesIter, devRemoteIters } = await (0, utils_1.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'angular');
|
|
81
57
|
const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
|
|
82
58
|
...v,
|
|
83
59
|
baseUrl: undefined,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Schema } from '../schema';
|
|
2
|
-
export declare function normalizeOptions(options: Schema):
|
|
1
|
+
import type { NormalizedSchema, Schema } from '../schema';
|
|
2
|
+
export declare function normalizeOptions(options: Schema): NormalizedSchema;
|
|
@@ -12,6 +12,7 @@ function normalizeOptions(options) {
|
|
|
12
12
|
return {
|
|
13
13
|
...options,
|
|
14
14
|
devRemotes: devServeRemotes,
|
|
15
|
+
verbose: options.verbose ?? false,
|
|
15
16
|
ssl: options.ssl ?? false,
|
|
16
17
|
sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
|
|
17
18
|
sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Schema } from '../schema';
|
|
2
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<{
|
|
3
|
+
export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<Schema, 'devRemotes' | 'verbose'>, context: ExecutorContext): Promise<AsyncIterable<{
|
|
4
4
|
success: boolean;
|
|
5
5
|
}>[]>;
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
|
@@ -3,21 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.moduleFederationSsrDevServerExecutor = moduleFederationSsrDevServerExecutor;
|
|
4
4
|
const build_angular_1 = require("@angular-devkit/build-angular");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
|
-
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
8
|
-
const utils_1 = require("@nx/module-federation/src/utils");
|
|
9
|
-
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
10
6
|
const fs_1 = require("fs");
|
|
11
|
-
const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
|
|
12
7
|
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
13
8
|
const path_1 = require("path");
|
|
14
9
|
const module_federation_1 = require("../../builders/utilities/module-federation");
|
|
15
|
-
const
|
|
16
|
-
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
17
11
|
const start_dev_remotes_1 = require("./lib/start-dev-remotes");
|
|
18
|
-
const
|
|
12
|
+
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
13
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
14
|
+
const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
|
|
15
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
16
|
+
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
19
17
|
async function* moduleFederationSsrDevServerExecutor(schema, context) {
|
|
20
|
-
const nxBin = require.resolve('nx/bin/nx');
|
|
21
18
|
const options = (0, normalize_options_1.normalizeOptions)(schema);
|
|
22
19
|
const currIter = (0, rxjs_for_await_1.eachValueFrom)((0, build_angular_1.executeSSRDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
|
|
23
20
|
builderName: '@nx/angular:webpack-server',
|
|
@@ -44,31 +41,12 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
|
|
|
44
41
|
pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
|
|
45
42
|
}
|
|
46
43
|
(0, module_federation_1.validateDevRemotes)({ devRemotes: options.devRemotes }, workspaceProjects);
|
|
47
|
-
const
|
|
48
|
-
const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
|
|
49
|
-
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
|
50
|
-
projectName: project.name,
|
|
51
|
-
projectGraph: context.projectGraph,
|
|
52
|
-
root: context.root,
|
|
53
|
-
}, pathToManifestFile);
|
|
54
|
-
options.staticRemotesPort ??= remotes.staticRemotePort;
|
|
55
|
-
const staticRemotesConfig = (0, utils_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
56
|
-
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
|
57
|
-
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
|
58
|
-
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
|
|
59
|
-
...(options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
|
60
|
-
project.name.replace(/-/g, '_'),
|
|
61
|
-
]);
|
|
62
|
-
const devRemotes = await (0, start_dev_remotes_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context);
|
|
63
|
-
const staticRemotes = (0, start_static_remotes_1.startStaticRemotes)(staticRemotesConfig, context, options);
|
|
64
|
-
(0, utils_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
65
|
-
? { pathToCert: options.sslCert, pathToKey: options.sslKey }
|
|
66
|
-
: undefined);
|
|
44
|
+
const { remotes, staticRemotesIter, devRemoteIters } = await (0, utils_1.startRemoteIterators)(options, context, start_dev_remotes_1.startRemotes, pathToManifestFile, 'angular', true);
|
|
67
45
|
const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
|
|
68
46
|
...v,
|
|
69
47
|
baseUrl: undefined,
|
|
70
48
|
}));
|
|
71
|
-
const combined = (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(
|
|
49
|
+
const combined = (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(staticRemotesIter), ...(devRemoteIters ? devRemoteIters.map(removeBaseUrlEmission) : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
72
50
|
if (!options.isInitialHost) {
|
|
73
51
|
done();
|
|
74
52
|
return;
|
|
@@ -80,7 +58,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
|
|
|
80
58
|
return;
|
|
81
59
|
}
|
|
82
60
|
try {
|
|
83
|
-
const portsToWaitFor =
|
|
61
|
+
const portsToWaitFor = staticRemotesIter
|
|
84
62
|
? [options.staticRemotesPort, ...remotes.remotePorts]
|
|
85
63
|
: [...remotes.remotePorts];
|
|
86
64
|
await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
|
|
@@ -99,7 +77,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
|
|
|
99
77
|
done();
|
|
100
78
|
}
|
|
101
79
|
}));
|
|
102
|
-
let refs = 2 + (
|
|
80
|
+
let refs = 2 + (devRemoteIters?.length ?? 0);
|
|
103
81
|
for await (const result of combined) {
|
|
104
82
|
if (result.success === false)
|
|
105
83
|
throw new Error('Remotes failed to start');
|
|
@@ -22,13 +22,9 @@ async function addJest(tree, options) {
|
|
|
22
22
|
const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'test-setup.ts');
|
|
23
23
|
if (options.strict && tree.exists(setupFile)) {
|
|
24
24
|
const contents = tree.read(setupFile, 'utf-8');
|
|
25
|
-
tree.write(setupFile,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
errorOnUnknownProperties: true,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
${contents}`);
|
|
25
|
+
tree.write(setupFile, contents.replace('setupZoneTestEnv();', `setupZoneTestEnv({
|
|
26
|
+
errorOnUnknownElements: true,
|
|
27
|
+
errorOnUnknownProperties: true
|
|
28
|
+
});`));
|
|
33
29
|
}
|
|
34
30
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
6
|
+
const projects_1 = require("../utils/projects");
|
|
7
|
+
const preferStandaloneRule = '@angular-eslint/prefer-standalone';
|
|
8
|
+
async function default_1(tree) {
|
|
9
|
+
const projects = await (0, projects_1.getProjectsFilteredByDependencies)(tree, [
|
|
10
|
+
'npm:@angular/core',
|
|
11
|
+
]);
|
|
12
|
+
for (const { project: { root }, } of projects) {
|
|
13
|
+
if (!(0, eslint_file_1.isEslintConfigSupported)(tree, root)) {
|
|
14
|
+
// ESLint config is not supported, skip
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, (o) => !!o.rules?.[preferStandaloneRule], true)) {
|
|
18
|
+
// the @angular-eslint/prefer-standalone rule is set in an override, skip
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const ngEslintOverrideLookup = (o) => o.files?.includes('*.ts') &&
|
|
22
|
+
Object.keys(o.rules ?? {}).some((r) => r.startsWith('@angular-eslint/'));
|
|
23
|
+
const tsFilesOverrideLookup = (o) => o.files?.length === 1 && o.files[0] === '*.ts';
|
|
24
|
+
if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, ngEslintOverrideLookup, false)) {
|
|
25
|
+
// there is an override containing an Angular ESLint rule
|
|
26
|
+
(0, eslint_file_1.updateOverrideInLintConfig)(tree, root, ngEslintOverrideLookup, (o) => {
|
|
27
|
+
o.rules = {
|
|
28
|
+
...o.rules,
|
|
29
|
+
[preferStandaloneRule]: 'off',
|
|
30
|
+
};
|
|
31
|
+
return o;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, tsFilesOverrideLookup, false)) {
|
|
35
|
+
// there is an override for just *.ts files
|
|
36
|
+
(0, eslint_file_1.updateOverrideInLintConfig)(tree, root, tsFilesOverrideLookup, (o) => {
|
|
37
|
+
o.rules = {
|
|
38
|
+
...o.rules,
|
|
39
|
+
[preferStandaloneRule]: 'off',
|
|
40
|
+
};
|
|
41
|
+
return o;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// there are no overrides for any Angular ESLint rule or just *.ts files, add a new override
|
|
46
|
+
(0, eslint_file_1.addOverrideToLintConfig)(tree, root, {
|
|
47
|
+
files: ['*.ts'],
|
|
48
|
+
rules: {
|
|
49
|
+
[preferStandaloneRule]: 'off',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
55
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type Schema } from '../schema';
|
|
2
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
3
|
-
import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
4
|
-
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
|
|
@@ -1,65 +0,0 @@
|
|
|
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((res, rej) => {
|
|
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=build`,
|
|
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 build')) {
|
|
44
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
45
|
-
devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
46
|
-
res();
|
|
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
|
-
rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
res();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
62
|
-
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
63
|
-
});
|
|
64
|
-
return mappedLocationOfRemotes;
|
|
65
|
-
}
|
package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type Schema } from '../schema';
|
|
3
|
-
import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
4
|
-
export declare function startStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
|
|
5
|
-
success: boolean;
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
}, {
|
|
8
|
-
success: boolean;
|
|
9
|
-
}, unknown>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startStaticRemotesFileServer = startStaticRemotesFileServer;
|
|
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 startStaticRemotesFileServer(staticRemotesConfig, context, options) {
|
|
10
|
-
if (!staticRemotesConfig.remotes ||
|
|
11
|
-
staticRemotesConfig.remotes.length === 0) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
let shouldMoveToCommonLocation = false;
|
|
15
|
-
let commonOutputDirectory;
|
|
16
|
-
for (const app of staticRemotesConfig.remotes) {
|
|
17
|
-
const remoteBasePath = staticRemotesConfig.config[app].basePath;
|
|
18
|
-
if (!commonOutputDirectory) {
|
|
19
|
-
commonOutputDirectory = remoteBasePath;
|
|
20
|
-
}
|
|
21
|
-
else if (commonOutputDirectory !== remoteBasePath) {
|
|
22
|
-
shouldMoveToCommonLocation = true;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (shouldMoveToCommonLocation) {
|
|
27
|
-
commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
|
|
28
|
-
for (const app of staticRemotesConfig.remotes) {
|
|
29
|
-
const remoteConfig = staticRemotesConfig.config[app];
|
|
30
|
-
(0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
|
|
31
|
-
force: true,
|
|
32
|
-
recursive: true,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const staticRemotesIter = (0, file_server_impl_1.default)({
|
|
37
|
-
cors: true,
|
|
38
|
-
watch: false,
|
|
39
|
-
staticFilePath: commonOutputDirectory,
|
|
40
|
-
parallel: false,
|
|
41
|
-
spa: false,
|
|
42
|
-
withDeps: false,
|
|
43
|
-
host: options.host,
|
|
44
|
-
port: options.staticRemotesPort,
|
|
45
|
-
ssl: options.ssl,
|
|
46
|
-
sslCert: options.sslCert,
|
|
47
|
-
sslKey: options.sslKey,
|
|
48
|
-
cacheSeconds: -1,
|
|
49
|
-
}, context);
|
|
50
|
-
return staticRemotesIter;
|
|
51
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Schema } from '../schema';
|
|
2
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
3
|
-
import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
4
|
-
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type Schema } from '../schema';
|
|
3
|
-
import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
4
|
-
export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncIterable<unknown>;
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
|
-
function startStaticRemotes(ssrStaticRemotesConfig, context, options) {
|
|
11
|
-
if (ssrStaticRemotesConfig.remotes.length === 0) {
|
|
12
|
-
return (0, async_iterable_1.createAsyncIterable)(({ next, done }) => {
|
|
13
|
-
next({ success: true });
|
|
14
|
-
done();
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
// The directories are usually generated with /browser and /server suffixes so we need to copy them to a common directory
|
|
18
|
-
const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
|
|
19
|
-
for (const app of ssrStaticRemotesConfig.remotes) {
|
|
20
|
-
const remoteConfig = ssrStaticRemotesConfig.config[app];
|
|
21
|
-
(0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
|
|
22
|
-
force: true,
|
|
23
|
-
recursive: true,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const staticRemotesIter = (0, file_server_impl_1.default)({
|
|
27
|
-
cors: true,
|
|
28
|
-
watch: false,
|
|
29
|
-
staticFilePath: commonOutputDirectory,
|
|
30
|
-
parallel: false,
|
|
31
|
-
spa: false,
|
|
32
|
-
withDeps: false,
|
|
33
|
-
host: options.host,
|
|
34
|
-
port: options.staticRemotesPort,
|
|
35
|
-
ssl: options.ssl,
|
|
36
|
-
sslCert: options.sslCert,
|
|
37
|
-
sslKey: options.sslKey,
|
|
38
|
-
cacheSeconds: -1,
|
|
39
|
-
}, context);
|
|
40
|
-
return staticRemotesIter;
|
|
41
|
-
}
|