@module-federation/dts-plugin 2.0.1 → 2.1.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.
- package/dist/Action-CzhPMw2i.js +153 -0
- package/dist/Broker-DRlzScTT.js +800 -0
- package/dist/CHANGELOG.md +15 -0
- package/dist/DtsWorker-Dtem3-FM.d.ts +166 -0
- package/dist/constant-BwEkyidO.d.ts +42 -0
- package/dist/consumeTypes-AD2ig87l.js +237 -0
- package/dist/core.d.ts +3 -68
- package/dist/core.js +26 -2443
- package/dist/dynamic-remote-type-hints-plugin.d.ts +622 -3
- package/dist/dynamic-remote-type-hints-plugin.js +65 -187
- package/dist/esm/Action-DNNg2YDh.mjs +47 -0
- package/dist/esm/Broker-BU4gToNr.mjs +736 -0
- package/dist/esm/consumeTypes-D51rVbSt.mjs +204 -0
- package/dist/esm/core.mjs +5 -0
- package/dist/esm/dynamic-remote-type-hints-plugin.mjs +73 -0
- package/dist/esm/expose-rpc-DMhY1i8A.mjs +1301 -0
- package/dist/esm/fork-dev-worker.mjs +103 -0
- package/dist/esm/fork-generate-dts.mjs +14 -0
- package/dist/esm/index.mjs +465 -0
- package/dist/esm/start-broker.mjs +22 -0
- package/dist/esm/utils-CkPvDGOy.mjs +13 -0
- package/dist/expose-rpc-BLAH20uj.js +1415 -0
- package/dist/fork-dev-worker.d.ts +10 -9
- package/dist/fork-dev-worker.js +100 -2932
- package/dist/fork-generate-dts.d.ts +4 -8
- package/dist/fork-generate-dts.js +11 -2103
- package/dist/iife/launch-web-client.iife.js +117 -0
- package/dist/index.d.ts +57 -46
- package/dist/index.js +449 -3043
- package/dist/package.json +26 -11
- package/dist/start-broker.d.ts +41 -39
- package/dist/start-broker.js +17 -952
- package/dist/utils-7KqCZHbb.js +19 -0
- package/package.json +31 -16
- package/dist/DTSManager-b15Gfat3.d.ts +0 -53
- package/dist/DTSManagerOptions-QVchWb0x.d.ts +0 -32
- package/dist/DtsWorker-BrHsGz8C.d.ts +0 -56
- package/dist/core.d.mts +0 -68
- package/dist/dynamic-remote-type-hints-plugin.d.mts +0 -5
- package/dist/esm/chunk-647HGGGS.js +0 -241
- package/dist/esm/chunk-G65LOFTY.js +0 -24
- package/dist/esm/chunk-LJTUMI5K.js +0 -282
- package/dist/esm/chunk-MV6M4VFH.js +0 -1642
- package/dist/esm/chunk-WWV5RWOP.js +0 -902
- package/dist/esm/core.js +0 -44
- package/dist/esm/dynamic-remote-type-hints-plugin.js +0 -73
- package/dist/esm/fork-dev-worker.js +0 -145
- package/dist/esm/fork-generate-dts.js +0 -27
- package/dist/esm/index.js +0 -646
- package/dist/esm/start-broker.js +0 -36
- package/dist/fork-dev-worker.d.mts +0 -15
- package/dist/fork-generate-dts.d.mts +0 -10
- package/dist/iife/launch-web-client.js +0 -152
- package/dist/index.d.mts +0 -56
- package/dist/start-broker.d.mts +0 -42
- package/dist/utils-C4sQemLR.d.ts +0 -15
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6235711: Replace the Koa-based dev types server with a native Node HTTP server to reduce dependencies and keep type generation behavior unchanged.
|
|
8
|
+
- 5954fe7: Fix fork-dev-worker crashes in dts-plugin when consumeTypes is disabled
|
|
9
|
+
- Updated dependencies [918294f]
|
|
10
|
+
- Updated dependencies [24bf84d]
|
|
11
|
+
- Updated dependencies [918294f]
|
|
12
|
+
- Updated dependencies [918294f]
|
|
13
|
+
- @module-federation/error-codes@2.1.0
|
|
14
|
+
- @module-federation/managers@2.1.0
|
|
15
|
+
- @module-federation/sdk@2.1.0
|
|
16
|
+
- @module-federation/third-party-dts-extractor@2.1.0
|
|
17
|
+
|
|
3
18
|
## 2.0.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { moduleFederationPlugin } from "@module-federation/sdk";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { ChildProcess } from "child_process";
|
|
4
|
+
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/core/interfaces/RemoteOptions.d.ts
|
|
8
|
+
interface RemoteOptions extends moduleFederationPlugin.DtsRemoteOptions {
|
|
9
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
10
|
+
context?: string;
|
|
11
|
+
implementation?: string;
|
|
12
|
+
hostRemoteTypesFolder?: string;
|
|
13
|
+
outputDir?: string;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/interfaces/TsConfigJson.d.ts
|
|
17
|
+
interface TsConfigJson {
|
|
18
|
+
extends?: string;
|
|
19
|
+
compilerOptions?: ts.CompilerOptions;
|
|
20
|
+
exclude?: string[];
|
|
21
|
+
include?: string[];
|
|
22
|
+
files?: string[];
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/configurations/remotePlugin.d.ts
|
|
26
|
+
declare const retrieveRemoteConfig: (options: RemoteOptions) => {
|
|
27
|
+
tsConfig: TsConfigJson;
|
|
28
|
+
mapComponentsToExpose: Record<string, string>;
|
|
29
|
+
remoteOptions: Required<RemoteOptions>;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/core/interfaces/HostOptions.d.ts
|
|
33
|
+
interface HostOptions extends moduleFederationPlugin.DtsHostOptions {
|
|
34
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
35
|
+
context?: string;
|
|
36
|
+
implementation?: string;
|
|
37
|
+
runtimePkgs?: string[];
|
|
38
|
+
}
|
|
39
|
+
interface RemoteInfo {
|
|
40
|
+
name: string;
|
|
41
|
+
url: string;
|
|
42
|
+
alias: string;
|
|
43
|
+
zipUrl?: string;
|
|
44
|
+
apiTypeUrl?: string;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/interfaces/DTSManagerOptions.d.ts
|
|
48
|
+
interface DTSManagerOptions {
|
|
49
|
+
remote?: RemoteOptions;
|
|
50
|
+
host?: HostOptions;
|
|
51
|
+
extraOptions?: Record<string, any>;
|
|
52
|
+
displayErrorInTerminal?: moduleFederationPlugin.PluginDtsOptions['displayErrorInTerminal'];
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/server/constant.d.ts
|
|
56
|
+
declare const enum UpdateMode {
|
|
57
|
+
POSITIVE = "POSITIVE",
|
|
58
|
+
PASSIVE = "PASSIVE"
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/core/lib/DTSManager.d.ts
|
|
62
|
+
interface UpdateTypesOptions {
|
|
63
|
+
updateMode: UpdateMode;
|
|
64
|
+
remoteName?: string;
|
|
65
|
+
remoteTarPath?: string;
|
|
66
|
+
remoteInfo?: RemoteInfo;
|
|
67
|
+
once?: boolean;
|
|
68
|
+
}
|
|
69
|
+
declare class DTSManager {
|
|
70
|
+
options: DTSManagerOptions;
|
|
71
|
+
runtimePkgs: string[];
|
|
72
|
+
remoteAliasMap: Record<string, Required<RemoteInfo>>;
|
|
73
|
+
loadedRemoteAPIAlias: Set<string>;
|
|
74
|
+
extraOptions: Record<string, any>;
|
|
75
|
+
updatedRemoteInfos: Record<string, Required<RemoteInfo>>;
|
|
76
|
+
constructor(options: DTSManagerOptions);
|
|
77
|
+
generateAPITypes(mapComponentsToExpose: Record<string, string>): string;
|
|
78
|
+
extractRemoteTypes(options: ReturnType<typeof retrieveRemoteConfig>): Promise<void>;
|
|
79
|
+
generateTypes(): Promise<void>;
|
|
80
|
+
requestRemoteManifest(remoteInfo: RemoteInfo, hostOptions: Required<HostOptions>): Promise<Required<RemoteInfo>>;
|
|
81
|
+
consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string]>;
|
|
82
|
+
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string, hostOptions: Required<HostOptions>): Promise<boolean>;
|
|
83
|
+
consumeAPITypes(hostOptions: Required<HostOptions>): void;
|
|
84
|
+
consumeArchiveTypes(options: HostOptions): Promise<{
|
|
85
|
+
hostOptions: Required<HostOptions>;
|
|
86
|
+
downloadPromisesResult: PromiseSettledResult<[string, string]>[];
|
|
87
|
+
}>;
|
|
88
|
+
consumeTypes(): Promise<void>;
|
|
89
|
+
updateTypes(options: UpdateTypesOptions): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/core/rpc/expose-rpc.d.ts
|
|
93
|
+
declare function exposeRpc(fn: (...args: any[]) => any): void;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/core/rpc/types.d.ts
|
|
96
|
+
declare enum RpcGMCallTypes {
|
|
97
|
+
CALL = "mf_call",
|
|
98
|
+
RESOLVE = "mf_resolve",
|
|
99
|
+
REJECT = "mf_reject",
|
|
100
|
+
EXIT = "mf_exit"
|
|
101
|
+
}
|
|
102
|
+
interface RpcCallMessage {
|
|
103
|
+
type: RpcGMCallTypes.CALL;
|
|
104
|
+
id: string;
|
|
105
|
+
args: unknown[];
|
|
106
|
+
}
|
|
107
|
+
interface RpcResolveMessage {
|
|
108
|
+
type: RpcGMCallTypes.RESOLVE;
|
|
109
|
+
id: string;
|
|
110
|
+
value: unknown;
|
|
111
|
+
}
|
|
112
|
+
interface RpcRejectMessage {
|
|
113
|
+
type: RpcGMCallTypes.REJECT;
|
|
114
|
+
id: string;
|
|
115
|
+
error: unknown;
|
|
116
|
+
}
|
|
117
|
+
interface RpcExitMessage {
|
|
118
|
+
type: RpcGMCallTypes.EXIT;
|
|
119
|
+
id: string;
|
|
120
|
+
}
|
|
121
|
+
type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage | RpcExitMessage;
|
|
122
|
+
type RpcMethod = (...args: any[]) => any;
|
|
123
|
+
type RpcRemoteMethod<T extends RpcMethod> = T extends ((...args: infer A) => infer R) ? R extends Promise<any> ? (...args: A) => R : (...args: A) => Promise<R> : (...args: unknown[]) => Promise<unknown>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/core/rpc/wrap-rpc.d.ts
|
|
126
|
+
interface WrapRpcOptions {
|
|
127
|
+
id: string;
|
|
128
|
+
once?: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/core/rpc/rpc-worker.d.ts
|
|
133
|
+
interface RpcWorkerBase {
|
|
134
|
+
connect(...args: unknown[]): any;
|
|
135
|
+
terminate(): void;
|
|
136
|
+
readonly connected: boolean;
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly process: ChildProcess | undefined;
|
|
139
|
+
}
|
|
140
|
+
type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
|
|
141
|
+
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number, once?: boolean): RpcWorker<T>;
|
|
142
|
+
declare function getRpcWorkerData(): unknown;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/core/rpc/rpc-error.d.ts
|
|
145
|
+
declare class RpcExitError extends Error {
|
|
146
|
+
readonly code?: string | number | null;
|
|
147
|
+
readonly signal?: string | null;
|
|
148
|
+
constructor(message: string, code?: string | number | null, signal?: string | null);
|
|
149
|
+
}
|
|
150
|
+
declare namespace index_d_exports {
|
|
151
|
+
export { RpcCallMessage, RpcExitError, RpcGMCallTypes, RpcMessage, RpcMethod, RpcRejectMessage, RpcRemoteMethod, RpcResolveMessage, RpcWorker, createRpcWorker, exposeRpc, getRpcWorkerData, wrapRpc };
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/core/lib/DtsWorker.d.ts
|
|
155
|
+
type DtsWorkerOptions = DTSManagerOptions;
|
|
156
|
+
declare class DtsWorker {
|
|
157
|
+
rpcWorker: RpcWorker<RpcMethod>;
|
|
158
|
+
private _options;
|
|
159
|
+
private _res;
|
|
160
|
+
constructor(options: DtsWorkerOptions);
|
|
161
|
+
removeUnSerializationOptions(): void;
|
|
162
|
+
get controlledPromise(): ReturnType<DTSManager['generateTypes']>;
|
|
163
|
+
exit(): void;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { DTSManagerOptions as a, retrieveRemoteConfig as c, DTSManager as i, TsConfigJson as l, DtsWorkerOptions as n, HostOptions as o, index_d_exports as r, RemoteInfo as s, DtsWorker as t, RemoteOptions as u };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { a as DTSManagerOptions, i as DTSManager, l as TsConfigJson, o as HostOptions, s as RemoteInfo, u as RemoteOptions } from "./DtsWorker-Dtem3-FM.js";
|
|
2
|
+
import { moduleFederationPlugin } from "@module-federation/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/core/configurations/hostPlugin.d.ts
|
|
5
|
+
declare const retrieveHostConfig: (options: HostOptions) => {
|
|
6
|
+
hostOptions: Required<HostOptions>;
|
|
7
|
+
mapRemotesToDownload: Record<string, RemoteInfo>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/core/lib/utils.d.ts
|
|
11
|
+
declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
|
|
12
|
+
declare const validateOptions: (options: HostOptions) => void;
|
|
13
|
+
declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
|
|
14
|
+
apiTypesPath: string;
|
|
15
|
+
zipTypesPath: string;
|
|
16
|
+
zipName: string;
|
|
17
|
+
apiFileName: string;
|
|
18
|
+
};
|
|
19
|
+
declare const isTSProject: (dtsOptions: moduleFederationPlugin.ModuleFederationPluginOptions["dts"], context?: string) => boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/core/lib/typeScriptCompiler.d.ts
|
|
22
|
+
declare const retrieveMfTypesPath: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
23
|
+
declare const retrieveOriginalOutDir: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/lib/archiveHandler.d.ts
|
|
26
|
+
declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/lib/generateTypes.d.ts
|
|
29
|
+
declare function generateTypes(options: DTSManagerOptions): Promise<void>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/core/lib/generateTypesInChildProcess.d.ts
|
|
32
|
+
declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/core/lib/consumeTypes.d.ts
|
|
35
|
+
declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/core/constant.d.ts
|
|
38
|
+
declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
39
|
+
declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
40
|
+
declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
41
|
+
//#endregion
|
|
42
|
+
export { generateTypesInChildProcess as a, retrieveMfTypesPath as c, isTSProject as d, retrieveTypesAssetsInfo as f, consumeTypes as i, retrieveOriginalOutDir as l, retrieveHostConfig as m, REMOTE_ALIAS_IDENTIFIER as n, generateTypes as o, validateOptions as p, REMOTE_API_TYPES_FILE_NAME as r, retrieveTypesZipPath as s, HOST_API_TYPES_FILE_NAME as t, getDTSManagerConstructor as u };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const require_Action = require('./Action-CzhPMw2i.js');
|
|
2
|
+
const require_expose_rpc = require('./expose-rpc-BLAH20uj.js');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_Action.__toESM(path);
|
|
5
|
+
let crypto = require("crypto");
|
|
6
|
+
let child_process = require("child_process");
|
|
7
|
+
child_process = require_Action.__toESM(child_process);
|
|
8
|
+
let process$1 = require("process");
|
|
9
|
+
process$1 = require_Action.__toESM(process$1);
|
|
10
|
+
|
|
11
|
+
//#region src/core/rpc/rpc-error.ts
|
|
12
|
+
var RpcExitError = class extends Error {
|
|
13
|
+
constructor(message, code, signal) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.signal = signal;
|
|
17
|
+
this.name = "RpcExitError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/core/rpc/wrap-rpc.ts
|
|
23
|
+
function createControlledPromise() {
|
|
24
|
+
let resolve = () => void 0;
|
|
25
|
+
let reject = () => void 0;
|
|
26
|
+
return {
|
|
27
|
+
promise: new Promise((aResolve, aReject) => {
|
|
28
|
+
resolve = aResolve;
|
|
29
|
+
reject = aReject;
|
|
30
|
+
}),
|
|
31
|
+
resolve,
|
|
32
|
+
reject
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function wrapRpc(childProcess, options) {
|
|
36
|
+
return (async (...args) => {
|
|
37
|
+
if (!childProcess.send) throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
38
|
+
else if (!childProcess.connected) throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
|
|
39
|
+
const { id, once } = options;
|
|
40
|
+
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
|
|
41
|
+
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
|
|
42
|
+
const handleMessage = (message) => {
|
|
43
|
+
if (message?.id === id) {
|
|
44
|
+
if (message.type === require_expose_rpc.RpcGMCallTypes.RESOLVE) resolveResult(message.value);
|
|
45
|
+
else if (message.type === require_expose_rpc.RpcGMCallTypes.REJECT) rejectResult(message.error);
|
|
46
|
+
}
|
|
47
|
+
if (once && childProcess?.kill) childProcess.kill("SIGTERM");
|
|
48
|
+
};
|
|
49
|
+
const handleClose = (code, signal) => {
|
|
50
|
+
rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
|
|
51
|
+
removeHandlers();
|
|
52
|
+
};
|
|
53
|
+
const removeHandlers = () => {
|
|
54
|
+
childProcess.off("message", handleMessage);
|
|
55
|
+
childProcess.off("close", handleClose);
|
|
56
|
+
};
|
|
57
|
+
if (once) childProcess.once("message", handleMessage);
|
|
58
|
+
else childProcess.on("message", handleMessage);
|
|
59
|
+
childProcess.on("close", handleClose);
|
|
60
|
+
childProcess.send({
|
|
61
|
+
type: require_expose_rpc.RpcGMCallTypes.CALL,
|
|
62
|
+
id,
|
|
63
|
+
args
|
|
64
|
+
}, (error) => {
|
|
65
|
+
if (error) {
|
|
66
|
+
rejectSend(error);
|
|
67
|
+
removeHandlers();
|
|
68
|
+
} else resolveSend(void 0);
|
|
69
|
+
});
|
|
70
|
+
return sendPromise.then(() => resultPromise);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/core/rpc/rpc-worker.ts
|
|
76
|
+
const FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
77
|
+
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
78
|
+
const options = {
|
|
79
|
+
env: {
|
|
80
|
+
...process$1.env,
|
|
81
|
+
[FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
|
|
82
|
+
},
|
|
83
|
+
stdio: [
|
|
84
|
+
"inherit",
|
|
85
|
+
"inherit",
|
|
86
|
+
"inherit",
|
|
87
|
+
"ipc"
|
|
88
|
+
],
|
|
89
|
+
serialization: "advanced"
|
|
90
|
+
};
|
|
91
|
+
if (memoryLimit) options.execArgv = [`--max-old-space-size=${memoryLimit}`];
|
|
92
|
+
let childProcess, remoteMethod;
|
|
93
|
+
const id = (0, crypto.randomUUID)();
|
|
94
|
+
return {
|
|
95
|
+
connect(...args) {
|
|
96
|
+
if (childProcess && !childProcess.connected) {
|
|
97
|
+
childProcess.send({
|
|
98
|
+
type: require_expose_rpc.RpcGMCallTypes.EXIT,
|
|
99
|
+
id
|
|
100
|
+
});
|
|
101
|
+
childProcess = void 0;
|
|
102
|
+
remoteMethod = void 0;
|
|
103
|
+
}
|
|
104
|
+
if (!childProcess?.connected) {
|
|
105
|
+
childProcess = child_process.fork(modulePath, options);
|
|
106
|
+
remoteMethod = wrapRpc(childProcess, {
|
|
107
|
+
id,
|
|
108
|
+
once
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (!remoteMethod) return Promise.reject(/* @__PURE__ */ new Error("Worker is not connected - cannot perform RPC."));
|
|
112
|
+
return remoteMethod(...args);
|
|
113
|
+
},
|
|
114
|
+
terminate() {
|
|
115
|
+
try {
|
|
116
|
+
if (childProcess.connected) childProcess.send({
|
|
117
|
+
type: require_expose_rpc.RpcGMCallTypes.EXIT,
|
|
118
|
+
id
|
|
119
|
+
}, (err) => {
|
|
120
|
+
if (err) console.error("Error sending message:", err);
|
|
121
|
+
});
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (error.code === "EPIPE") console.error("Pipe closed before message could be sent:", error);
|
|
124
|
+
else console.error("Unexpected error:", error);
|
|
125
|
+
}
|
|
126
|
+
childProcess = void 0;
|
|
127
|
+
remoteMethod = void 0;
|
|
128
|
+
},
|
|
129
|
+
get connected() {
|
|
130
|
+
return Boolean(childProcess?.connected);
|
|
131
|
+
},
|
|
132
|
+
get process() {
|
|
133
|
+
return childProcess;
|
|
134
|
+
},
|
|
135
|
+
get id() {
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function getRpcWorkerData() {
|
|
141
|
+
return JSON.parse(process$1.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/core/rpc/index.ts
|
|
146
|
+
var rpc_exports = /* @__PURE__ */ require_Action.__exportAll({
|
|
147
|
+
RpcExitError: () => RpcExitError,
|
|
148
|
+
RpcGMCallTypes: () => require_expose_rpc.RpcGMCallTypes,
|
|
149
|
+
createRpcWorker: () => createRpcWorker,
|
|
150
|
+
exposeRpc: () => require_expose_rpc.exposeRpc,
|
|
151
|
+
getRpcWorkerData: () => getRpcWorkerData,
|
|
152
|
+
wrapRpc: () => wrapRpc
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/core/lib/DtsWorker.ts
|
|
157
|
+
var DtsWorker = class {
|
|
158
|
+
constructor(options) {
|
|
159
|
+
this._options = require_expose_rpc.cloneDeepOptions(options);
|
|
160
|
+
this.removeUnSerializationOptions();
|
|
161
|
+
this.rpcWorker = createRpcWorker(path.default.resolve(__dirname, "./fork-generate-dts.js"), {}, void 0, true);
|
|
162
|
+
this._res = this.rpcWorker.connect(this._options);
|
|
163
|
+
}
|
|
164
|
+
removeUnSerializationOptions() {
|
|
165
|
+
if (this._options.remote?.moduleFederationConfig?.manifest) delete this._options.remote?.moduleFederationConfig?.manifest;
|
|
166
|
+
if (this._options.host?.moduleFederationConfig?.manifest) delete this._options.host?.moduleFederationConfig?.manifest;
|
|
167
|
+
}
|
|
168
|
+
get controlledPromise() {
|
|
169
|
+
const ensureChildProcessExit = () => {
|
|
170
|
+
try {
|
|
171
|
+
const pid = this.rpcWorker.process?.pid;
|
|
172
|
+
const rootPid = process.pid;
|
|
173
|
+
if (pid && rootPid !== pid) process.kill(pid, 0);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (require_expose_rpc.isDebugMode()) console.error(error);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
return Promise.resolve(this._res).then(() => {
|
|
179
|
+
this.exit();
|
|
180
|
+
ensureChildProcessExit();
|
|
181
|
+
}).catch((err) => {
|
|
182
|
+
if (require_expose_rpc.isDebugMode()) console.error(err);
|
|
183
|
+
ensureChildProcessExit();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
exit() {
|
|
187
|
+
try {
|
|
188
|
+
this.rpcWorker?.terminate();
|
|
189
|
+
} catch (err) {
|
|
190
|
+
if (require_expose_rpc.isDebugMode()) console.error(err);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/core/lib/generateTypesInChildProcess.ts
|
|
197
|
+
async function generateTypesInChildProcess(options) {
|
|
198
|
+
return new DtsWorker(options).controlledPromise;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/core/lib/consumeTypes.ts
|
|
203
|
+
async function consumeTypes(options) {
|
|
204
|
+
await new (require_expose_rpc.getDTSManagerConstructor(options.host?.implementation))(options).consumeTypes();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
Object.defineProperty(exports, 'DtsWorker', {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () {
|
|
211
|
+
return DtsWorker;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(exports, 'consumeTypes', {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function () {
|
|
217
|
+
return consumeTypes;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, 'createRpcWorker', {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () {
|
|
223
|
+
return createRpcWorker;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(exports, 'generateTypesInChildProcess', {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
get: function () {
|
|
229
|
+
return generateTypesInChildProcess;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, 'rpc_exports', {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () {
|
|
235
|
+
return rpc_exports;
|
|
236
|
+
}
|
|
237
|
+
});
|
package/dist/core.d.ts
CHANGED
|
@@ -1,68 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-C4sQemLR.js';
|
|
5
|
-
import { R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-BrHsGz8C.js';
|
|
6
|
-
export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
|
|
7
|
-
import { ChildProcess } from 'child_process';
|
|
8
|
-
import 'typescript';
|
|
9
|
-
import '@module-federation/sdk';
|
|
10
|
-
|
|
11
|
-
declare const retrieveHostConfig: (options: HostOptions) => {
|
|
12
|
-
hostOptions: Required<HostOptions>;
|
|
13
|
-
mapRemotesToDownload: Record<string, RemoteInfo>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare const retrieveMfTypesPath: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
17
|
-
declare const retrieveOriginalOutDir: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
18
|
-
|
|
19
|
-
declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
|
|
20
|
-
|
|
21
|
-
declare function generateTypes(options: DTSManagerOptions): Promise<void>;
|
|
22
|
-
|
|
23
|
-
declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
|
|
24
|
-
|
|
25
|
-
declare function exposeRpc(fn: (...args: any[]) => any): void;
|
|
26
|
-
|
|
27
|
-
interface WrapRpcOptions {
|
|
28
|
-
id: string;
|
|
29
|
-
once?: boolean;
|
|
30
|
-
}
|
|
31
|
-
declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
|
|
32
|
-
|
|
33
|
-
declare class RpcExitError extends Error {
|
|
34
|
-
readonly code?: string | number | null;
|
|
35
|
-
readonly signal?: string | null;
|
|
36
|
-
constructor(message: string, code?: string | number | null, signal?: string | null);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* forked from https://github.com/TypeStrong/fork-ts-checker-webpack-plugin
|
|
41
|
-
* license at https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/LICENSE
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
declare const index_RpcCallMessage: typeof RpcCallMessage;
|
|
45
|
-
type index_RpcExitError = RpcExitError;
|
|
46
|
-
declare const index_RpcExitError: typeof RpcExitError;
|
|
47
|
-
declare const index_RpcGMCallTypes: typeof RpcGMCallTypes;
|
|
48
|
-
declare const index_RpcMessage: typeof RpcMessage;
|
|
49
|
-
declare const index_RpcMethod: typeof RpcMethod;
|
|
50
|
-
declare const index_RpcRejectMessage: typeof RpcRejectMessage;
|
|
51
|
-
declare const index_RpcRemoteMethod: typeof RpcRemoteMethod;
|
|
52
|
-
declare const index_RpcResolveMessage: typeof RpcResolveMessage;
|
|
53
|
-
declare const index_RpcWorker: typeof RpcWorker;
|
|
54
|
-
declare const index_createRpcWorker: typeof createRpcWorker;
|
|
55
|
-
declare const index_exposeRpc: typeof exposeRpc;
|
|
56
|
-
declare const index_getRpcWorkerData: typeof getRpcWorkerData;
|
|
57
|
-
declare const index_wrapRpc: typeof wrapRpc;
|
|
58
|
-
declare namespace index {
|
|
59
|
-
export { index_RpcCallMessage as RpcCallMessage, index_RpcExitError as RpcExitError, index_RpcGMCallTypes as RpcGMCallTypes, index_RpcMessage as RpcMessage, index_RpcMethod as RpcMethod, index_RpcRejectMessage as RpcRejectMessage, index_RpcRemoteMethod as RpcRemoteMethod, index_RpcResolveMessage as RpcResolveMessage, index_RpcWorker as RpcWorker, index_createRpcWorker as createRpcWorker, index_exposeRpc as exposeRpc, index_getRpcWorkerData as getRpcWorkerData, index_wrapRpc as wrapRpc };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
|
|
63
|
-
|
|
64
|
-
declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
65
|
-
declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
66
|
-
declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
67
|
-
|
|
68
|
-
export { DTSManagerOptions, HOST_API_TYPES_FILE_NAME, HostOptions, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, RemoteOptions, consumeTypes, generateTypes, generateTypesInChildProcess, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveTypesZipPath, index as rpc };
|
|
1
|
+
import { a as DTSManagerOptions, c as retrieveRemoteConfig, i as DTSManager, o as HostOptions, r as index_d_exports, t as DtsWorker, u as RemoteOptions } from "./DtsWorker-Dtem3-FM.js";
|
|
2
|
+
import { a as generateTypesInChildProcess, c as retrieveMfTypesPath, d as isTSProject, f as retrieveTypesAssetsInfo, i as consumeTypes, l as retrieveOriginalOutDir, m as retrieveHostConfig, n as REMOTE_ALIAS_IDENTIFIER, o as generateTypes, p as validateOptions, r as REMOTE_API_TYPES_FILE_NAME, s as retrieveTypesZipPath, t as HOST_API_TYPES_FILE_NAME, u as getDTSManagerConstructor } from "./constant-BwEkyidO.js";
|
|
3
|
+
export { DTSManager, type DTSManagerOptions, DtsWorker, HOST_API_TYPES_FILE_NAME, type HostOptions, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, type RemoteOptions, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, isTSProject, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveRemoteConfig, retrieveTypesAssetsInfo, retrieveTypesZipPath, index_d_exports as rpc, validateOptions };
|