@module-federation/dts-plugin 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/Action-CzhPMw2i.js +153 -0
  2. package/dist/Broker-C-uWF8l5.js +802 -0
  3. package/dist/CHANGELOG.md +297 -6
  4. package/dist/DtsWorker-SBLpkK-D.d.ts +178 -0
  5. package/dist/constant-C0QI9ddQ.d.ts +42 -0
  6. package/dist/consumeTypes-DhrUgkUW.js +241 -0
  7. package/dist/core.d.ts +3 -68
  8. package/dist/core.js +26 -2380
  9. package/dist/dynamic-remote-type-hints-plugin.d.ts +819 -3
  10. package/dist/dynamic-remote-type-hints-plugin.js +65 -187
  11. package/dist/esm/Action-DNNg2YDh.mjs +47 -0
  12. package/dist/esm/Broker-BfFUcTHm.mjs +738 -0
  13. package/dist/esm/consumeTypes-WKYNaS9i.mjs +208 -0
  14. package/dist/esm/core.mjs +5 -0
  15. package/dist/esm/dynamic-remote-type-hints-plugin.mjs +73 -0
  16. package/dist/esm/expose-rpc-B0rqtOKP.mjs +1593 -0
  17. package/dist/esm/fork-dev-worker.mjs +113 -0
  18. package/dist/esm/fork-generate-dts.mjs +14 -0
  19. package/dist/esm/index.mjs +509 -0
  20. package/dist/esm/start-broker.mjs +22 -0
  21. package/dist/esm/utils-CkPvDGOy.mjs +13 -0
  22. package/dist/expose-rpc-jaGpsAVL.js +1701 -0
  23. package/dist/fork-dev-worker.d.ts +10 -9
  24. package/dist/fork-dev-worker.js +110 -2869
  25. package/dist/fork-generate-dts.d.ts +4 -8
  26. package/dist/fork-generate-dts.js +11 -2040
  27. package/dist/iife/launch-web-client.iife.js +117 -0
  28. package/dist/index.d.ts +46 -50
  29. package/dist/index.js +493 -2978
  30. package/dist/start-broker.d.ts +41 -39
  31. package/dist/start-broker.js +17 -952
  32. package/dist/utils-7KqCZHbb.js +19 -0
  33. package/package.json +50 -30
  34. package/dist/DTSManager-b15Gfat3.d.ts +0 -53
  35. package/dist/DTSManagerOptions-QVchWb0x.d.ts +0 -32
  36. package/dist/DtsWorker-BrHsGz8C.d.ts +0 -56
  37. package/dist/core.d.mts +0 -68
  38. package/dist/dynamic-remote-type-hints-plugin.d.mts +0 -5
  39. package/dist/esm/chunk-647HGGGS.js +0 -241
  40. package/dist/esm/chunk-G65LOFTY.js +0 -24
  41. package/dist/esm/chunk-N7GTIQUA.js +0 -282
  42. package/dist/esm/chunk-RWXNVNFM.js +0 -1579
  43. package/dist/esm/chunk-WWV5RWOP.js +0 -902
  44. package/dist/esm/core.js +0 -44
  45. package/dist/esm/dynamic-remote-type-hints-plugin.js +0 -73
  46. package/dist/esm/fork-dev-worker.js +0 -145
  47. package/dist/esm/fork-generate-dts.js +0 -27
  48. package/dist/esm/index.js +0 -644
  49. package/dist/esm/start-broker.js +0 -36
  50. package/dist/fork-dev-worker.d.mts +0 -15
  51. package/dist/fork-generate-dts.d.mts +0 -10
  52. package/dist/iife/launch-web-client.js +0 -152
  53. package/dist/index.d.mts +0 -56
  54. package/dist/package.json +0 -87
  55. package/dist/start-broker.d.mts +0 -42
  56. package/dist/utils-DxGrqb9N.d.ts +0 -15
@@ -0,0 +1,241 @@
1
+ const require_Action = require('./Action-CzhPMw2i.js');
2
+ const require_expose_rpc = require('./expose-rpc-jaGpsAVL.js');
3
+ let url = require("url");
4
+ let path = require("path");
5
+ path = require_Action.__toESM(path);
6
+ let crypto = require("crypto");
7
+ let child_process = require("child_process");
8
+ child_process = require_Action.__toESM(child_process);
9
+ let process$1 = require("process");
10
+ process$1 = require_Action.__toESM(process$1);
11
+
12
+ //#region src/core/rpc/rpc-error.ts
13
+ var RpcExitError = class extends Error {
14
+ constructor(message, code, signal) {
15
+ super(message);
16
+ this.code = code;
17
+ this.signal = signal;
18
+ this.name = "RpcExitError";
19
+ }
20
+ };
21
+
22
+ //#endregion
23
+ //#region src/core/rpc/wrap-rpc.ts
24
+ function createControlledPromise() {
25
+ let resolve = () => void 0;
26
+ let reject = () => void 0;
27
+ return {
28
+ promise: new Promise((aResolve, aReject) => {
29
+ resolve = aResolve;
30
+ reject = aReject;
31
+ }),
32
+ resolve,
33
+ reject
34
+ };
35
+ }
36
+ function wrapRpc(childProcess, options) {
37
+ return (async (...args) => {
38
+ if (!childProcess.send) throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
39
+ else if (!childProcess.connected) throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
40
+ const { id, once } = options;
41
+ const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
42
+ const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
43
+ const handleMessage = (message) => {
44
+ if (message?.id === id) {
45
+ if (message.type === require_expose_rpc.RpcGMCallTypes.RESOLVE) resolveResult(message.value);
46
+ else if (message.type === require_expose_rpc.RpcGMCallTypes.REJECT) rejectResult(message.error);
47
+ }
48
+ if (once && childProcess?.kill) childProcess.kill("SIGTERM");
49
+ };
50
+ const handleClose = (code, signal) => {
51
+ rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
52
+ removeHandlers();
53
+ };
54
+ const removeHandlers = () => {
55
+ childProcess.off("message", handleMessage);
56
+ childProcess.off("close", handleClose);
57
+ };
58
+ if (once) childProcess.once("message", handleMessage);
59
+ else childProcess.on("message", handleMessage);
60
+ childProcess.on("close", handleClose);
61
+ childProcess.send({
62
+ type: require_expose_rpc.RpcGMCallTypes.CALL,
63
+ id,
64
+ args
65
+ }, (error) => {
66
+ if (error) {
67
+ rejectSend(error);
68
+ removeHandlers();
69
+ } else resolveSend(void 0);
70
+ });
71
+ return sendPromise.then(() => resultPromise);
72
+ });
73
+ }
74
+
75
+ //#endregion
76
+ //#region src/core/rpc/rpc-worker.ts
77
+ const FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
78
+ function createRpcWorker(modulePath, data, memoryLimit, once) {
79
+ const options = {
80
+ env: {
81
+ ...process$1.env,
82
+ [FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
83
+ },
84
+ stdio: [
85
+ "inherit",
86
+ "inherit",
87
+ "inherit",
88
+ "ipc"
89
+ ],
90
+ serialization: "advanced"
91
+ };
92
+ if (memoryLimit) options.execArgv = [`--max-old-space-size=${memoryLimit}`];
93
+ let childProcess, remoteMethod;
94
+ const id = (0, crypto.randomUUID)();
95
+ return {
96
+ connect(...args) {
97
+ if (childProcess && !childProcess.connected) {
98
+ childProcess.send({
99
+ type: require_expose_rpc.RpcGMCallTypes.EXIT,
100
+ id
101
+ });
102
+ childProcess = void 0;
103
+ remoteMethod = void 0;
104
+ }
105
+ if (!childProcess?.connected) {
106
+ childProcess = child_process.fork(modulePath, options);
107
+ remoteMethod = wrapRpc(childProcess, {
108
+ id,
109
+ once
110
+ });
111
+ }
112
+ if (!remoteMethod) return Promise.reject(/* @__PURE__ */ new Error("Worker is not connected - cannot perform RPC."));
113
+ return remoteMethod(...args);
114
+ },
115
+ terminate() {
116
+ try {
117
+ if (childProcess.connected) childProcess.send({
118
+ type: require_expose_rpc.RpcGMCallTypes.EXIT,
119
+ id
120
+ }, (err) => {
121
+ if (err) console.error("Error sending message:", err);
122
+ });
123
+ } catch (error) {
124
+ if (error.code === "EPIPE") console.error("Pipe closed before message could be sent:", error);
125
+ else console.error("Unexpected error:", error);
126
+ }
127
+ childProcess = void 0;
128
+ remoteMethod = void 0;
129
+ },
130
+ get connected() {
131
+ return Boolean(childProcess?.connected);
132
+ },
133
+ get process() {
134
+ return childProcess;
135
+ },
136
+ get id() {
137
+ return id;
138
+ }
139
+ };
140
+ }
141
+ function getRpcWorkerData() {
142
+ return JSON.parse(process$1.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
143
+ }
144
+
145
+ //#endregion
146
+ //#region src/core/rpc/index.ts
147
+ var rpc_exports = /* @__PURE__ */ require_Action.__exportAll({
148
+ RpcExitError: () => RpcExitError,
149
+ RpcGMCallTypes: () => require_expose_rpc.RpcGMCallTypes,
150
+ createRpcWorker: () => createRpcWorker,
151
+ exposeRpc: () => require_expose_rpc.exposeRpc,
152
+ getRpcWorkerData: () => getRpcWorkerData,
153
+ wrapRpc: () => wrapRpc
154
+ });
155
+
156
+ //#endregion
157
+ //#region src/core/lib/DtsWorker.ts
158
+ const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
159
+ const __dirname$1 = path.default.dirname(__filename$1);
160
+ const __extname = path.default.extname(__filename$1);
161
+ var DtsWorker = class {
162
+ constructor(options) {
163
+ this._options = require_expose_rpc.cloneDeepOptions(options);
164
+ this.removeUnSerializationOptions();
165
+ this.rpcWorker = createRpcWorker(path.default.resolve(__dirname$1, `./fork-generate-dts${__extname}`), {}, void 0, true);
166
+ this._res = this.rpcWorker.connect(this._options);
167
+ }
168
+ removeUnSerializationOptions() {
169
+ if (this._options.remote?.moduleFederationConfig?.manifest) delete this._options.remote?.moduleFederationConfig?.manifest;
170
+ if (this._options.host?.moduleFederationConfig?.manifest) delete this._options.host?.moduleFederationConfig?.manifest;
171
+ }
172
+ get controlledPromise() {
173
+ const ensureChildProcessExit = () => {
174
+ try {
175
+ const pid = this.rpcWorker.process?.pid;
176
+ const rootPid = process.pid;
177
+ if (pid && rootPid !== pid) process.kill(pid, 0);
178
+ } catch (error) {
179
+ if (require_expose_rpc.isDebugMode()) console.error(error);
180
+ }
181
+ };
182
+ return Promise.resolve(this._res).then(() => {
183
+ this.exit();
184
+ ensureChildProcessExit();
185
+ }).catch((err) => {
186
+ if (require_expose_rpc.isDebugMode()) console.error(err);
187
+ ensureChildProcessExit();
188
+ });
189
+ }
190
+ exit() {
191
+ try {
192
+ this.rpcWorker?.terminate();
193
+ } catch (err) {
194
+ if (require_expose_rpc.isDebugMode()) console.error(err);
195
+ }
196
+ }
197
+ };
198
+
199
+ //#endregion
200
+ //#region src/core/lib/generateTypesInChildProcess.ts
201
+ async function generateTypesInChildProcess(options) {
202
+ return new DtsWorker(options).controlledPromise;
203
+ }
204
+
205
+ //#endregion
206
+ //#region src/core/lib/consumeTypes.ts
207
+ async function consumeTypes(options) {
208
+ await new (require_expose_rpc.getDTSManagerConstructor(options.host?.implementation))(options).consumeTypes();
209
+ }
210
+
211
+ //#endregion
212
+ Object.defineProperty(exports, 'DtsWorker', {
213
+ enumerable: true,
214
+ get: function () {
215
+ return DtsWorker;
216
+ }
217
+ });
218
+ Object.defineProperty(exports, 'consumeTypes', {
219
+ enumerable: true,
220
+ get: function () {
221
+ return consumeTypes;
222
+ }
223
+ });
224
+ Object.defineProperty(exports, 'createRpcWorker', {
225
+ enumerable: true,
226
+ get: function () {
227
+ return createRpcWorker;
228
+ }
229
+ });
230
+ Object.defineProperty(exports, 'generateTypesInChildProcess', {
231
+ enumerable: true,
232
+ get: function () {
233
+ return generateTypesInChildProcess;
234
+ }
235
+ });
236
+ Object.defineProperty(exports, 'rpc_exports', {
237
+ enumerable: true,
238
+ get: function () {
239
+ return rpc_exports;
240
+ }
241
+ });
package/dist/core.d.ts CHANGED
@@ -1,68 +1,3 @@
1
- import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
2
- export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
3
- import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
4
- export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-DxGrqb9N.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-SBLpkK-D.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-C0QI9ddQ.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 };