@nx/module-federation 23.0.0-beta.23 → 23.0.0-beta.25
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/{angular.d.ts → dist/angular.d.ts} +0 -1
- package/{index.d.ts → dist/index.d.ts} +0 -1
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +13 -0
- package/{rspack.d.ts → dist/rspack.d.ts} +0 -1
- package/{src → dist/src}/executors/utils/build-static-remotes.d.ts +0 -1
- package/{src → dist/src}/executors/utils/index.d.ts +0 -1
- package/{src → dist/src}/executors/utils/models.d.ts +0 -1
- package/{src → dist/src}/executors/utils/start-remote-iterators.d.ts +0 -1
- package/{src → dist/src}/executors/utils/start-static-remotes-file-server.d.ts +0 -1
- package/{src → dist/src}/executors/utils/start-static-remotes-file-server.js +2 -3
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +214 -0
- package/{src → dist/src}/plugins/models/index.d.ts +0 -1
- package/{src/plugins/nx-module-federation-plugin/rspack → dist/src/plugins/nx-module-federation-plugin/angular}/nx-module-federation-dev-server-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -1
- package/{src/plugins/nx-module-federation-plugin/angular → dist/src/plugins/nx-module-federation-plugin/rspack}/nx-module-federation-dev-server-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/build-static-remotes.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/get-dynamic-manifest-file.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/get-remotes.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/get-static-remotes.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/get-static-remotes.js +2 -2
- package/{src → dist/src}/plugins/utils/index.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/parse-remotes-config.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/start-remote-proxies.d.ts +0 -1
- package/{src → dist/src}/plugins/utils/start-static-remotes-file-server.d.ts +0 -1
- package/{src → dist/src}/utils/dependencies.d.ts +0 -1
- package/{src → dist/src}/utils/framework-detection.d.ts +0 -1
- package/{src → dist/src}/utils/get-remotes-for-host.d.ts +0 -1
- package/{src → dist/src}/utils/index.d.ts +0 -1
- package/{src → dist/src}/utils/models/index.d.ts +1 -2
- package/{src → dist/src}/utils/module-federation-config.d.ts +0 -1
- package/{src → dist/src}/utils/normalize-project-name.d.ts +0 -1
- package/{src → dist/src}/utils/package-json.d.ts +0 -1
- package/{src → dist/src}/utils/parse-static-remotes-config.d.ts +0 -1
- package/{src → dist/src}/utils/plugins/runtime-library-control.plugin.d.ts +0 -1
- package/{src → dist/src}/utils/port-utils.d.ts +0 -1
- package/{src → dist/src}/utils/port-utils.js +2 -2
- package/{src → dist/src}/utils/public-api.d.ts +0 -1
- package/{src → dist/src}/utils/remotes.d.ts +0 -1
- package/{src → dist/src}/utils/secondary-entry-points.d.ts +0 -1
- package/{src → dist/src}/utils/share.d.ts +0 -1
- package/{src → dist/src}/utils/start-remote-proxies.d.ts +0 -1
- package/{src → dist/src}/utils/start-ssr-remote-proxies.d.ts +0 -1
- package/{src → dist/src}/utils/typescript.d.ts +0 -1
- package/{url-helpers.d.ts → dist/src/utils/url-helpers.d.ts} +0 -1
- package/{src → dist/src}/with-module-federation/angular/utils.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/angular/with-module-federation-ssr.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/angular/with-module-federation-ssr.js +1 -1
- package/{src → dist/src}/with-module-federation/angular/with-module-federation.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/angular/with-module-federation.js +1 -1
- package/{src → dist/src}/with-module-federation/react/utils.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/rspack/utils.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/rspack/with-module-federation-ssr.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/rspack/with-module-federation-ssr.js +1 -1
- package/{src → dist/src}/with-module-federation/rspack/with-module-federation.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/rspack/with-module-federation.js +1 -1
- package/{src → dist/src}/with-module-federation/webpack/utils.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/webpack/with-module-federation-ssr.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/webpack/with-module-federation-ssr.js +1 -1
- package/{src → dist/src}/with-module-federation/webpack/with-module-federation.d.ts +0 -1
- package/{src → dist/src}/with-module-federation/webpack/with-module-federation.js +1 -1
- package/{src/utils → dist}/url-helpers.d.ts +0 -1
- package/{webpack.d.ts → dist/webpack.d.ts} +0 -1
- package/migrations.json +34 -46
- package/package.json +93 -56
- package/angular.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/rspack.d.ts.map +0 -1
- package/src/executors/utils/build-static-remotes.d.ts.map +0 -1
- package/src/executors/utils/index.d.ts.map +0 -1
- package/src/executors/utils/models.d.ts.map +0 -1
- package/src/executors/utils/start-remote-iterators.d.ts.map +0 -1
- package/src/executors/utils/start-static-remotes-file-server.d.ts.map +0 -1
- package/src/plugins/models/index.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.d.ts.map +0 -1
- package/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.d.ts.map +0 -1
- package/src/plugins/utils/build-static-remotes.d.ts.map +0 -1
- package/src/plugins/utils/get-dynamic-manifest-file.d.ts.map +0 -1
- package/src/plugins/utils/get-remotes.d.ts.map +0 -1
- package/src/plugins/utils/get-static-remotes.d.ts.map +0 -1
- package/src/plugins/utils/index.d.ts.map +0 -1
- package/src/plugins/utils/parse-remotes-config.d.ts.map +0 -1
- package/src/plugins/utils/start-remote-proxies.d.ts.map +0 -1
- package/src/plugins/utils/start-static-remotes-file-server.d.ts.map +0 -1
- package/src/utils/dependencies.d.ts.map +0 -1
- package/src/utils/framework-detection.d.ts.map +0 -1
- package/src/utils/get-remotes-for-host.d.ts.map +0 -1
- package/src/utils/index.d.ts.map +0 -1
- package/src/utils/models/index.d.ts.map +0 -1
- package/src/utils/module-federation-config.d.ts.map +0 -1
- package/src/utils/normalize-project-name.d.ts.map +0 -1
- package/src/utils/package-json.d.ts.map +0 -1
- package/src/utils/parse-static-remotes-config.d.ts.map +0 -1
- package/src/utils/plugins/runtime-library-control.plugin.d.ts.map +0 -1
- package/src/utils/port-utils.d.ts.map +0 -1
- package/src/utils/public-api.d.ts.map +0 -1
- package/src/utils/remotes.d.ts.map +0 -1
- package/src/utils/secondary-entry-points.d.ts.map +0 -1
- package/src/utils/share.d.ts.map +0 -1
- package/src/utils/start-remote-proxies.d.ts.map +0 -1
- package/src/utils/start-ssr-remote-proxies.d.ts.map +0 -1
- package/src/utils/typescript.d.ts.map +0 -1
- package/src/utils/url-helpers.d.ts.map +0 -1
- package/src/with-module-federation/angular/utils.d.ts.map +0 -1
- package/src/with-module-federation/angular/with-module-federation-ssr.d.ts.map +0 -1
- package/src/with-module-federation/angular/with-module-federation.d.ts.map +0 -1
- package/src/with-module-federation/react/utils.d.ts.map +0 -1
- package/src/with-module-federation/rspack/utils.d.ts.map +0 -1
- package/src/with-module-federation/rspack/with-module-federation-ssr.d.ts.map +0 -1
- package/src/with-module-federation/rspack/with-module-federation.d.ts.map +0 -1
- package/src/with-module-federation/webpack/utils.d.ts.map +0 -1
- package/src/with-module-federation/webpack/with-module-federation-ssr.d.ts.map +0 -1
- package/src/with-module-federation/webpack/with-module-federation.d.ts.map +0 -1
- package/url-helpers.d.ts.map +0 -1
- package/webpack.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{angular.js → dist/angular.js} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{rspack.js → dist/rspack.js} +0 -0
- /package/{src → dist/src}/executors/utils/build-static-remotes.js +0 -0
- /package/{src → dist/src}/executors/utils/index.js +0 -0
- /package/{src → dist/src}/executors/utils/models.js +0 -0
- /package/{src → dist/src}/executors/utils/start-remote-iterators.js +0 -0
- /package/{src → dist/src}/plugins/models/index.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.js +0 -0
- /package/{src → dist/src}/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.js +0 -0
- /package/{src → dist/src}/plugins/utils/build-static-remotes.js +0 -0
- /package/{src → dist/src}/plugins/utils/get-dynamic-manifest-file.js +0 -0
- /package/{src → dist/src}/plugins/utils/get-remotes.js +0 -0
- /package/{src → dist/src}/plugins/utils/index.js +0 -0
- /package/{src → dist/src}/plugins/utils/parse-remotes-config.js +0 -0
- /package/{src → dist/src}/plugins/utils/start-remote-proxies.js +0 -0
- /package/{src → dist/src}/plugins/utils/start-static-remotes-file-server.js +0 -0
- /package/{src → dist/src}/utils/dependencies.js +0 -0
- /package/{src → dist/src}/utils/framework-detection.js +0 -0
- /package/{src → dist/src}/utils/get-remotes-for-host.js +0 -0
- /package/{src → dist/src}/utils/index.js +0 -0
- /package/{src → dist/src}/utils/models/index.js +0 -0
- /package/{src → dist/src}/utils/module-federation-config.js +0 -0
- /package/{src → dist/src}/utils/normalize-project-name.js +0 -0
- /package/{src → dist/src}/utils/package-json.js +0 -0
- /package/{src → dist/src}/utils/parse-static-remotes-config.js +0 -0
- /package/{src → dist/src}/utils/plugins/runtime-library-control.plugin.js +0 -0
- /package/{src → dist/src}/utils/public-api.js +0 -0
- /package/{src → dist/src}/utils/remotes.js +0 -0
- /package/{src → dist/src}/utils/secondary-entry-points.js +0 -0
- /package/{src → dist/src}/utils/share.js +0 -0
- /package/{src → dist/src}/utils/start-remote-proxies.js +0 -0
- /package/{src → dist/src}/utils/start-ssr-remote-proxies.js +0 -0
- /package/{src → dist/src}/utils/typescript.js +0 -0
- /package/{src → dist/src}/utils/url-helpers.js +0 -0
- /package/{src → dist/src}/with-module-federation/angular/utils.js +0 -0
- /package/{src → dist/src}/with-module-federation/react/utils.js +0 -0
- /package/{src → dist/src}/with-module-federation/rspack/utils.js +0 -0
- /package/{src → dist/src}/with-module-federation/webpack/utils.js +0 -0
- /package/{url-helpers.js → dist/url-helpers.js} +0 -0
- /package/{webpack.js → dist/webpack.js} +0 -0
|
@@ -3,4 +3,3 @@ export * from './src/with-module-federation/angular/with-module-federation-ssr';
|
|
|
3
3
|
export * from './src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin';
|
|
4
4
|
export * from './src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin';
|
|
5
5
|
export * from './src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin';
|
|
6
|
-
//# sourceMappingURL=angular.d.ts.map
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStaticRemotesConfig = exports.getRemotes = exports.getModuleFederationConfig = exports.startRemoteIterators = exports.buildStaticRemotes = void 0;
|
|
4
|
+
// Curated internal API surface for other first-party Nx plugins (e.g. @nx/react,
|
|
5
|
+
// @nx/angular, @nx/rspack). Prefer this over deep `@nx/module-federation/src/*`
|
|
6
|
+
// imports — those are not part of the public API.
|
|
7
|
+
var utils_1 = require("./src/executors/utils");
|
|
8
|
+
Object.defineProperty(exports, "buildStaticRemotes", { enumerable: true, get: function () { return utils_1.buildStaticRemotes; } });
|
|
9
|
+
Object.defineProperty(exports, "startRemoteIterators", { enumerable: true, get: function () { return utils_1.startRemoteIterators; } });
|
|
10
|
+
var utils_2 = require("./src/utils");
|
|
11
|
+
Object.defineProperty(exports, "getModuleFederationConfig", { enumerable: true, get: function () { return utils_2.getModuleFederationConfig; } });
|
|
12
|
+
Object.defineProperty(exports, "getRemotes", { enumerable: true, get: function () { return utils_2.getRemotes; } });
|
|
13
|
+
Object.defineProperty(exports, "parseStaticRemotesConfig", { enumerable: true, get: function () { return utils_2.parseStaticRemotesConfig; } });
|
|
@@ -3,4 +3,3 @@ export * from './src/with-module-federation/rspack/with-module-federation-ssr';
|
|
|
3
3
|
export * from './src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin';
|
|
4
4
|
export * from './src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin';
|
|
5
5
|
export * from './src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin';
|
|
6
|
-
//# sourceMappingURL=rspack.d.ts.map
|
|
@@ -2,4 +2,3 @@ import { ExecutorContext } from '@nx/devkit';
|
|
|
2
2
|
import { type StaticRemotesConfig } from '../../utils';
|
|
3
3
|
import { type BuildStaticRemotesOptions } from './models';
|
|
4
4
|
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: BuildStaticRemotesOptions, buildTarget?: 'build' | 'server'): Promise<Record<string, string>>;
|
|
5
|
-
//# sourceMappingURL=build-static-remotes.d.ts.map
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.startStaticRemotesFileServer = startStaticRemotesFileServer;
|
|
4
4
|
exports.startSsrStaticRemotesFileServer = startSsrStaticRemotesFileServer;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/web/internal");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const fs_1 = require("fs");
|
|
10
9
|
function startStaticRemotesFileServer(staticRemotesConfig, context, options, forceMoveToCommonLocation = false) {
|
|
@@ -36,7 +35,7 @@ function startStaticRemotesFileServer(staticRemotesConfig, context, options, for
|
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
const staticRemotesIter = (0,
|
|
38
|
+
const staticRemotesIter = (0, internal_1.fileServerExecutor)({
|
|
40
39
|
cors: true,
|
|
41
40
|
watch: false,
|
|
42
41
|
staticFilePath: commonOutputDirectory,
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = rewriteInternalSubpathImports;
|
|
4
|
+
exports.rewriteSubpathImports = rewriteSubpathImports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const FROM_PREFIX = '@nx/module-federation/src/';
|
|
8
|
+
const TO_PUBLIC = '@nx/module-federation';
|
|
9
|
+
const TO_INTERNAL = '@nx/module-federation/internal';
|
|
10
|
+
// Symbols exported from `@nx/module-federation`'s public entry (packages/module-federation/index.ts).
|
|
11
|
+
// A named import/export of one of these from `@nx/module-federation/src/*` is routed to
|
|
12
|
+
// the public `@nx/module-federation` entry; everything else goes to `@nx/module-federation/internal`.
|
|
13
|
+
const PUBLIC_SYMBOLS = new Set([
|
|
14
|
+
'AdditionalSharedConfig',
|
|
15
|
+
'ModuleFederationConfig',
|
|
16
|
+
'ModuleFederationLibrary',
|
|
17
|
+
'NxModuleFederationConfigOverride',
|
|
18
|
+
'Remotes',
|
|
19
|
+
'SharedFunction',
|
|
20
|
+
'SharedLibraryConfig',
|
|
21
|
+
'SharedWorkspaceLibraryConfig',
|
|
22
|
+
'WorkspaceLibrary',
|
|
23
|
+
'WorkspaceLibrarySecondaryEntryPoint',
|
|
24
|
+
'applyAdditionalShared',
|
|
25
|
+
'applySharedFunction',
|
|
26
|
+
'getDependentPackagesForProject',
|
|
27
|
+
'getNpmPackageSharedConfig',
|
|
28
|
+
'mapRemotes',
|
|
29
|
+
'mapRemotesForSSR',
|
|
30
|
+
'normalizeProjectName',
|
|
31
|
+
'readRootPackageJson',
|
|
32
|
+
'sharePackages',
|
|
33
|
+
'shareWorkspaceLibraries',
|
|
34
|
+
]);
|
|
35
|
+
// Methods on `jest` and `vi` that take a module specifier as their first arg.
|
|
36
|
+
const MOCK_HELPER_METHODS = new Set([
|
|
37
|
+
'mock',
|
|
38
|
+
'unmock',
|
|
39
|
+
'doMock',
|
|
40
|
+
'dontMock',
|
|
41
|
+
'requireActual',
|
|
42
|
+
'requireMock',
|
|
43
|
+
'importActual',
|
|
44
|
+
'importMock',
|
|
45
|
+
]);
|
|
46
|
+
let ts;
|
|
47
|
+
async function rewriteInternalSubpathImports(tree) {
|
|
48
|
+
let touchedCount = 0;
|
|
49
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
50
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const original = tree.read(filePath, 'utf-8');
|
|
54
|
+
if (!original || !original.includes(FROM_PREFIX)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const updated = rewriteSubpathImports(original);
|
|
58
|
+
if (updated !== original) {
|
|
59
|
+
tree.write(filePath, updated);
|
|
60
|
+
touchedCount += 1;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (touchedCount > 0) {
|
|
64
|
+
devkit_1.logger.info(`Rewrote @nx/module-federation/src/* imports in ${touchedCount} file(s) ` +
|
|
65
|
+
`(public symbols to @nx/module-federation, internals to @nx/module-federation/internal).`);
|
|
66
|
+
}
|
|
67
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
68
|
+
}
|
|
69
|
+
function rewriteSubpathImports(source) {
|
|
70
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
71
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
72
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
73
|
+
const changes = [];
|
|
74
|
+
for (const stmt of sourceFile.statements) {
|
|
75
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
76
|
+
collectImportRewrite(sourceFile, stmt, changes);
|
|
77
|
+
}
|
|
78
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
79
|
+
collectExportRewrite(sourceFile, stmt, changes);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
collectCallExpressionRewrites(sourceFile, changes);
|
|
83
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
84
|
+
}
|
|
85
|
+
function isSubpathSpecifier(node) {
|
|
86
|
+
return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
|
|
87
|
+
}
|
|
88
|
+
function collectImportRewrite(sourceFile, stmt, changes) {
|
|
89
|
+
if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const clause = stmt.importClause;
|
|
93
|
+
// Pure named imports (`import { a, b } from '...'`) can be split by symbol.
|
|
94
|
+
// A default or namespace import grabs the whole module, so it can't be
|
|
95
|
+
// split — route it wholesale to the internal entry.
|
|
96
|
+
if (clause &&
|
|
97
|
+
!clause.name &&
|
|
98
|
+
clause.namedBindings &&
|
|
99
|
+
ts.isNamedImports(clause.namedBindings)) {
|
|
100
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
104
|
+
}
|
|
105
|
+
function collectExportRewrite(sourceFile, stmt, changes) {
|
|
106
|
+
if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// `export { a, b } from '...'` can be split; `export * from '...'` cannot.
|
|
110
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
111
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Partition the named bindings of an import/export declaration into the ones
|
|
118
|
+
* that resolve to `@nx/module-federation`'s public entry and the ones that don't. If both
|
|
119
|
+
* groups are non-empty, the single declaration is split into two.
|
|
120
|
+
*/
|
|
121
|
+
function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
|
|
122
|
+
const publicEls = [];
|
|
123
|
+
const internalEls = [];
|
|
124
|
+
for (const el of elements) {
|
|
125
|
+
// `propertyName` is the original name in `orig as alias`; fall back to
|
|
126
|
+
// `name` for the plain `orig` form.
|
|
127
|
+
const importedName = (el.propertyName ?? el.name).text;
|
|
128
|
+
(PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
|
|
129
|
+
}
|
|
130
|
+
if (publicEls.length === 0) {
|
|
131
|
+
replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (internalEls.length === 0) {
|
|
135
|
+
replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Mixed — replace the whole declaration with one statement per target.
|
|
139
|
+
const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
|
|
140
|
+
const start = decl.getStart(sourceFile);
|
|
141
|
+
const end = decl.getEnd();
|
|
142
|
+
const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
|
|
143
|
+
const prefix = isTypeOnly ? `${keyword} type` : keyword;
|
|
144
|
+
const render = (els, target) => `${prefix} { ${els
|
|
145
|
+
.map((el) => el.getText(sourceFile))
|
|
146
|
+
.join(', ')} } from ${quote}${target}${quote}${semicolon}`;
|
|
147
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
148
|
+
type: devkit_1.ChangeType.Insert,
|
|
149
|
+
index: start,
|
|
150
|
+
text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function collectCallExpressionRewrites(sourceFile, changes) {
|
|
154
|
+
const visit = (node) => {
|
|
155
|
+
if (ts.isCallExpression(node) &&
|
|
156
|
+
shouldRewriteCallExpression(node) &&
|
|
157
|
+
node.arguments.length >= 1 &&
|
|
158
|
+
isSubpathSpecifier(node.arguments[0])) {
|
|
159
|
+
// `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
|
|
160
|
+
// the module as a whole and can't be symbol-split, so they go to the
|
|
161
|
+
// internal entry.
|
|
162
|
+
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
163
|
+
}
|
|
164
|
+
else if (ts.isImportTypeNode(node)) {
|
|
165
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
166
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
167
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
168
|
+
const literal = getImportTypeStringLiteral(node);
|
|
169
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
170
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
ts.forEachChild(node, visit);
|
|
174
|
+
};
|
|
175
|
+
visit(sourceFile);
|
|
176
|
+
}
|
|
177
|
+
function getImportTypeStringLiteral(node) {
|
|
178
|
+
const arg = node.argument;
|
|
179
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
180
|
+
return arg.literal;
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
function shouldRewriteCallExpression(call) {
|
|
185
|
+
const callee = call.expression;
|
|
186
|
+
// `require('...')`
|
|
187
|
+
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
188
|
+
return true;
|
|
189
|
+
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
190
|
+
// callee is the `import` keyword). The `typeof import('...')` type-position
|
|
191
|
+
// form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
|
|
192
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
193
|
+
return true;
|
|
194
|
+
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
|
195
|
+
if (ts.isPropertyAccessExpression(callee)) {
|
|
196
|
+
const obj = callee.expression;
|
|
197
|
+
if (ts.isIdentifier(obj) &&
|
|
198
|
+
(obj.text === 'jest' || obj.text === 'vi') &&
|
|
199
|
+
MOCK_HELPER_METHODS.has(callee.name.text)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
function replaceSpecifier(sourceFile, literal, target, changes) {
|
|
206
|
+
const start = literal.getStart(sourceFile);
|
|
207
|
+
const end = literal.getEnd();
|
|
208
|
+
const quote = sourceFile.text.charAt(start);
|
|
209
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
210
|
+
type: devkit_1.ChangeType.Insert,
|
|
211
|
+
index: start,
|
|
212
|
+
text: `${quote}${target}${quote}`,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { StaticRemoteConfig } from '../../utils';
|
|
2
2
|
import { NxModuleFederationDevServerConfig } from '../models';
|
|
3
3
|
export declare function buildStaticRemotes(staticRemotesConfig: Record<string, StaticRemoteConfig>, options: NxModuleFederationDevServerConfig, nxBin: string): Promise<Record<string, string>>;
|
|
4
|
-
//# sourceMappingURL=build-static-remotes.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { StaticRemoteConfig } from '../../utils';
|
|
2
2
|
import { DevRemoteFindOptions } from '../models';
|
|
3
3
|
export declare function getStaticRemotes(remotesConfig: Record<string, StaticRemoteConfig>, devRemoteFindOptions?: DevRemoteFindOptions, host?: string): Promise<Record<string, StaticRemoteConfig>>;
|
|
4
|
-
//# sourceMappingURL=get-static-remotes.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStaticRemotes = getStaticRemotes;
|
|
4
|
-
const
|
|
4
|
+
const internal_1 = require("@nx/web/internal");
|
|
5
5
|
async function getStaticRemotes(remotesConfig, devRemoteFindOptions, host = '127.0.0.1') {
|
|
6
6
|
const remotes = Object.keys(remotesConfig);
|
|
7
7
|
const findStaticRemotesPromises = [];
|
|
8
8
|
for (const remote of remotes) {
|
|
9
9
|
findStaticRemotesPromises.push(new Promise((resolve, reject) => {
|
|
10
|
-
(0,
|
|
10
|
+
(0, internal_1.waitForPortOpen)(remotesConfig[remote].port, {
|
|
11
11
|
retries: devRemoteFindOptions?.retries ?? 3,
|
|
12
12
|
retryDelay: devRemoteFindOptions?.retryDelay ?? 1000,
|
|
13
13
|
host,
|
|
@@ -15,4 +15,3 @@ export declare function getRemotes(devRemotes: string[], skipRemotes: string[],
|
|
|
15
15
|
};
|
|
16
16
|
export declare function getModuleFederationConfig(tsconfigPath: string | undefined, workspaceRoot: string, projectRoot: string, pluginName?: 'react' | 'angular'): any;
|
|
17
17
|
export {};
|
|
18
|
-
//# sourceMappingURL=get-remotes-for-host.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { moduleFederationPlugin } from '@module-federation/
|
|
1
|
+
import type { moduleFederationPlugin } from '@module-federation/enhanced';
|
|
2
2
|
import { NormalModuleReplacementPlugin as RspackNormalModuleReplacementPlugin } from '@rspack/core';
|
|
3
3
|
export type ModuleFederationLibrary = {
|
|
4
4
|
type: string;
|
|
@@ -45,4 +45,3 @@ export type WorkspaceLibrarySecondaryEntryPoint = {
|
|
|
45
45
|
name: string;
|
|
46
46
|
path: string;
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -11,4 +11,3 @@ export type StaticRemotesConfig = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
13
13
|
export declare function parseStaticSsrRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
14
|
-
//# sourceMappingURL=parse-static-remotes-config.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
|
|
2
2
|
declare const nxRuntimeLibraryControlPlugin: () => ModuleFederationRuntimePlugin;
|
|
3
3
|
export default nxRuntimeLibraryControlPlugin;
|
|
4
|
-
//# sourceMappingURL=runtime-library-control.plugin.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPortInUse = isPortInUse;
|
|
4
|
-
const
|
|
4
|
+
const internal_1 = require("@nx/web/internal");
|
|
5
5
|
/**
|
|
6
6
|
* Check if a port is already in use by attempting to connect to it.
|
|
7
7
|
* Uses waitForPortOpen with retries: 0 for an immediate check.
|
|
8
8
|
*/
|
|
9
9
|
async function isPortInUse(port, host = 'localhost') {
|
|
10
10
|
try {
|
|
11
|
-
await (0,
|
|
11
|
+
await (0, internal_1.waitForPortOpen)(port, { retries: 0, host });
|
|
12
12
|
return true; // Port is open/in use
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
@@ -5,4 +5,3 @@ import { mapRemotes, mapRemotesForSSR } from './remotes';
|
|
|
5
5
|
import { getDependentPackagesForProject } from './dependencies';
|
|
6
6
|
import { readRootPackageJson } from './package-json';
|
|
7
7
|
export { ModuleFederationConfig, NxModuleFederationConfigOverride, SharedLibraryConfig, SharedWorkspaceLibraryConfig, AdditionalSharedConfig, WorkspaceLibrary, SharedFunction, WorkspaceLibrarySecondaryEntryPoint, Remotes, ModuleFederationLibrary, applySharedFunction, applyAdditionalShared, getNpmPackageSharedConfig, shareWorkspaceLibraries, sharePackages, mapRemotes, mapRemotesForSSR, normalizeProjectName, getDependentPackagesForProject, readRootPackageJson, };
|
|
8
|
-
//# sourceMappingURL=public-api.d.ts.map
|
|
@@ -17,4 +17,3 @@ export declare function mapRemotes(remotes: Remotes, remoteEntryExt: 'js' | 'mjs
|
|
|
17
17
|
* @param determineRemoteUrl - The function used to lookup the URL of the served remote
|
|
18
18
|
*/
|
|
19
19
|
export declare function mapRemotesForSSR(remotes: Remotes, remoteEntryExt: 'js' | 'mjs', determineRemoteUrl: (remote: string) => string): Record<string, string>;
|
|
20
|
-
//# sourceMappingURL=remotes.d.ts.map
|
|
@@ -47,4 +47,3 @@ export declare function applySharedFunction(sharedConfig: Record<string, SharedL
|
|
|
47
47
|
* @param projectGraph - The Nx project graph
|
|
48
48
|
*/
|
|
49
49
|
export declare function applyAdditionalShared(sharedConfig: Record<string, SharedLibraryConfig>, additionalShared: AdditionalSharedConfig | undefined, projectGraph: ProjectGraph): void;
|
|
50
|
-
//# sourceMappingURL=share.d.ts.map
|
|
@@ -2,4 +2,3 @@ import { ParsedCommandLine } from 'typescript';
|
|
|
2
2
|
export declare function readTsPathMappings(tsConfigPath?: string): ParsedCommandLine['options']['paths'];
|
|
3
3
|
export declare function readTsConfig(tsConfigPath: string): ParsedCommandLine;
|
|
4
4
|
export declare function getRootTsConfigPath(): string | null;
|
|
5
|
-
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -11,4 +11,3 @@ export declare function processRemoteLocation(remoteLocation: string, remoteEntr
|
|
|
11
11
|
* Processes remote URLs for runtime environments, resolving relative URLs against window.location.origin
|
|
12
12
|
*/
|
|
13
13
|
export declare function processRuntimeRemoteUrl(remoteUrl: string, remoteEntryExt: 'js' | 'mjs'): string;
|
|
14
|
-
//# sourceMappingURL=url-helpers.d.ts.map
|
|
@@ -25,4 +25,3 @@ export declare function getModuleFederationConfigSync(mfConfig: ModuleFederation
|
|
|
25
25
|
isServer: boolean;
|
|
26
26
|
determineRemoteUrl?: (remote: string) => string;
|
|
27
27
|
}, useRspack?: boolean): import("../../utils/module-federation-config").ModuleFederationConfigResult;
|
|
28
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type ModuleFederationConfig, type NxModuleFederationConfigOverride } from '../../utils';
|
|
2
2
|
export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any) => any>;
|
|
3
|
-
//# sourceMappingURL=with-module-federation-ssr.d.ts.map
|
|
@@ -65,7 +65,7 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
65
65
|
? [
|
|
66
66
|
...(configOverride?.runtimePlugins ?? []),
|
|
67
67
|
require.resolve('@module-federation/node/runtimePlugin'),
|
|
68
|
-
require.resolve('@nx/module-federation/
|
|
68
|
+
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
69
69
|
]
|
|
70
70
|
: [
|
|
71
71
|
...(configOverride?.runtimePlugins ?? []),
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type ModuleFederationConfig, type NxModuleFederationConfigOverride } from '../../utils';
|
|
2
2
|
export declare function withModuleFederation(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any) => any>;
|
|
3
|
-
//# sourceMappingURL=with-module-federation.d.ts.map
|
|
@@ -67,7 +67,7 @@ async function withModuleFederation(options, configOverride) {
|
|
|
67
67
|
!options.disableNxRuntimeLibraryControlPlugin
|
|
68
68
|
? [
|
|
69
69
|
...(configOverride?.runtimePlugins ?? []),
|
|
70
|
-
require.resolve('@nx/module-federation/
|
|
70
|
+
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
71
71
|
]
|
|
72
72
|
: configOverride?.runtimePlugins,
|
|
73
73
|
}),
|
|
@@ -8,4 +8,3 @@ export declare function getModuleFederationConfig(mfConfig: ModuleFederationConf
|
|
|
8
8
|
isServer: boolean;
|
|
9
9
|
determineRemoteUrl?: (remote: string) => string;
|
|
10
10
|
}): import("../../utils/module-federation-config").ModuleFederationConfigResult;
|
|
11
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -2,4 +2,3 @@ import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../
|
|
|
2
2
|
export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any, { context }: {
|
|
3
3
|
context: any;
|
|
4
4
|
}) => any>;
|
|
5
|
-
//# sourceMappingURL=with-module-federation-ssr.d.ts.map
|