@module-federation/dts-plugin 0.0.0-chore-bump-node-22-20260710161714
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/Action-CzhPMw2i.js +153 -0
- package/dist/Broker-CaenCqdn.js +783 -0
- package/dist/CHANGELOG.md +1390 -0
- package/dist/DtsWorker-Bt7-_SGH.d.ts +166 -0
- package/dist/README.md +1 -0
- package/dist/constant-YOdZl7sj.d.ts +42 -0
- package/dist/consumeTypes-Dle9g2SZ.js +241 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +28 -0
- package/dist/dynamic-remote-type-hints-plugin.d.ts +766 -0
- package/dist/dynamic-remote-type-hints-plugin.js +74 -0
- package/dist/esm/Action-DNNg2YDh.mjs +47 -0
- package/dist/esm/Broker-Cmbh_XVO.mjs +718 -0
- package/dist/esm/consumeTypes-3S4eCiRK.mjs +208 -0
- package/dist/esm/core.mjs +5 -0
- package/dist/esm/dynamic-remote-type-hints-plugin.mjs +73 -0
- package/dist/esm/expose-rpc-CDdqA9PX.mjs +1380 -0
- package/dist/esm/fork-dev-worker.mjs +113 -0
- package/dist/esm/fork-generate-dts.mjs +14 -0
- package/dist/esm/index.mjs +509 -0
- package/dist/esm/start-broker.mjs +22 -0
- package/dist/esm/utils-CkPvDGOy.mjs +13 -0
- package/dist/expose-rpc-BpRiu3VK.js +1489 -0
- package/dist/fork-dev-worker.d.ts +16 -0
- package/dist/fork-dev-worker.js +114 -0
- package/dist/fork-generate-dts.d.ts +6 -0
- package/dist/fork-generate-dts.js +15 -0
- package/dist/iife/launch-web-client.iife.js +117 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +517 -0
- package/dist/start-broker.d.ts +44 -0
- package/dist/start-broker.js +23 -0
- package/dist/utils-7KqCZHbb.js +19 -0
- package/package.json +108 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as DTSManagerOptions } from "./DtsWorker-Bt7-_SGH.js";
|
|
2
|
+
|
|
3
|
+
//#region src/dev-worker/DevWorker.d.ts
|
|
4
|
+
interface DevWorkerOptions extends DTSManagerOptions {
|
|
5
|
+
name: string;
|
|
6
|
+
disableLiveReload?: boolean;
|
|
7
|
+
disableHotTypesReload?: boolean;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/dev-worker/forkDevWorker.d.ts
|
|
11
|
+
interface Options extends DevWorkerOptions {
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
declare function forkDevWorker(options: Options, action?: string): Promise<void>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { forkDevWorker };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_Action = require('./Action-CzhPMw2i.js');
|
|
3
|
+
const require_Broker = require('./Broker-CaenCqdn.js');
|
|
4
|
+
const require_expose_rpc = require('./expose-rpc-BpRiu3VK.js');
|
|
5
|
+
require('./consumeTypes-Dle9g2SZ.js');
|
|
6
|
+
require('./core.js');
|
|
7
|
+
const require_utils = require('./utils-7KqCZHbb.js');
|
|
8
|
+
let _module_federation_sdk = require("@module-federation/sdk");
|
|
9
|
+
|
|
10
|
+
//#region src/dev-worker/handleWorkerMessage.ts
|
|
11
|
+
function handleDevWorkerMessage(message, options = {}) {
|
|
12
|
+
const { moduleServer, processExit = process.exit, pid = process.pid, log = () => void 0 } = options;
|
|
13
|
+
log(`ChildProcess(${pid}), message: ${JSON.stringify(message)} `, "forkDevWorker", "info");
|
|
14
|
+
if (message.type === require_expose_rpc.RpcGMCallTypes.EXIT) {
|
|
15
|
+
log(`ChildProcess(${pid}) SIGTERM, Federation DevServer will exit...`, "forkDevWorker", "error");
|
|
16
|
+
moduleServer?.exit();
|
|
17
|
+
processExit(0);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/dev-worker/forkDevWorker.ts
|
|
23
|
+
let typesManager, serverAddress, moduleServer, cacheOptions;
|
|
24
|
+
function getLocalRemoteNames(options, encodeNameIdentifier) {
|
|
25
|
+
if (!options) return [];
|
|
26
|
+
let hostConfig;
|
|
27
|
+
try {
|
|
28
|
+
hostConfig = require_expose_rpc.retrieveHostConfig(options);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
require_Broker.fileLog(`getLocalRemoteNames: retrieveHostConfig failed: ${e.message}`, "forkDevWorker", "warn");
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const { mapRemotesToDownload } = hostConfig;
|
|
34
|
+
return Object.keys(mapRemotesToDownload).reduce((sum, remoteModuleName) => {
|
|
35
|
+
const remoteInfo = mapRemotesToDownload[remoteModuleName];
|
|
36
|
+
const name = encodeNameIdentifier ? (0, _module_federation_sdk.decodeName)(remoteInfo.name, encodeNameIdentifier) : remoteInfo.name;
|
|
37
|
+
const ip = require_utils.getIpFromEntry(remoteInfo.url, require_Broker.getIPV4());
|
|
38
|
+
if (!ip) return sum;
|
|
39
|
+
sum.push({
|
|
40
|
+
name,
|
|
41
|
+
entry: remoteInfo.url,
|
|
42
|
+
ip
|
|
43
|
+
});
|
|
44
|
+
return sum;
|
|
45
|
+
}, []);
|
|
46
|
+
}
|
|
47
|
+
async function updateCallback({ updateMode, name, remoteTypeTarPath, remoteInfo, once }) {
|
|
48
|
+
const { disableHotTypesReload, disableLiveReload } = cacheOptions || {};
|
|
49
|
+
require_Broker.fileLog(`sync remote module ${name}, types to ${cacheOptions?.name},typesManager.updateTypes run`, "forkDevWorker", "info");
|
|
50
|
+
if (!disableLiveReload && moduleServer) moduleServer.update({
|
|
51
|
+
updateKind: require_Broker.UpdateKind.RELOAD_PAGE,
|
|
52
|
+
updateMode: require_Action.UpdateMode.PASSIVE
|
|
53
|
+
});
|
|
54
|
+
if (!disableHotTypesReload && typesManager) await typesManager.updateTypes({
|
|
55
|
+
updateMode,
|
|
56
|
+
remoteName: name,
|
|
57
|
+
remoteTarPath: remoteTypeTarPath,
|
|
58
|
+
remoteInfo,
|
|
59
|
+
once
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function forkDevWorker(options, action) {
|
|
63
|
+
if (!typesManager) {
|
|
64
|
+
const { name, remote, host, extraOptions } = options;
|
|
65
|
+
typesManager = new (require_expose_rpc.getDTSManagerConstructor(remote?.implementation))({
|
|
66
|
+
remote,
|
|
67
|
+
host,
|
|
68
|
+
extraOptions
|
|
69
|
+
});
|
|
70
|
+
if (!options.disableHotTypesReload && remote) {
|
|
71
|
+
const { remoteOptions, tsConfig } = require_expose_rpc.retrieveRemoteConfig(remote);
|
|
72
|
+
const mfTypesZipPath = require_expose_rpc.retrieveTypesZipPath(require_expose_rpc.retrieveMfTypesPath(tsConfig, remoteOptions), remoteOptions);
|
|
73
|
+
await Promise.all([require_expose_rpc.createHttpServer({ typeTarPath: mfTypesZipPath }).then((res) => {
|
|
74
|
+
serverAddress = res.serverAddress;
|
|
75
|
+
}), typesManager.generateTypes()]).catch((err) => {
|
|
76
|
+
require_Broker.fileLog(`${name} module generateTypes done, localServerAddress: ${JSON.stringify(err)}`, "forkDevWorker", "error");
|
|
77
|
+
});
|
|
78
|
+
require_Broker.fileLog(`${name} module generateTypes done, localServerAddress: ${serverAddress}`, "forkDevWorker", "info");
|
|
79
|
+
}
|
|
80
|
+
moduleServer = new require_expose_rpc.ModuleFederationDevServer({
|
|
81
|
+
name,
|
|
82
|
+
remotes: getLocalRemoteNames(host, extraOptions?.["encodeNameIdentifier"]),
|
|
83
|
+
updateCallback,
|
|
84
|
+
remoteTypeTarPath: `${serverAddress}/${require_Action.DEFAULT_TAR_NAME}`
|
|
85
|
+
});
|
|
86
|
+
cacheOptions = options;
|
|
87
|
+
}
|
|
88
|
+
if (action === "update" && cacheOptions) {
|
|
89
|
+
require_Broker.fileLog(`remoteModule ${cacheOptions.name} receive devWorker update, start typesManager.updateTypes `, "forkDevWorker", "info");
|
|
90
|
+
if (!cacheOptions.disableLiveReload) moduleServer?.update({
|
|
91
|
+
updateKind: require_Broker.UpdateKind.RELOAD_PAGE,
|
|
92
|
+
updateMode: require_Action.UpdateMode.POSITIVE
|
|
93
|
+
});
|
|
94
|
+
if (!cacheOptions.disableHotTypesReload) typesManager?.updateTypes({
|
|
95
|
+
updateMode: require_Action.UpdateMode.POSITIVE,
|
|
96
|
+
remoteName: cacheOptions.name
|
|
97
|
+
}).then(() => {
|
|
98
|
+
moduleServer?.update({
|
|
99
|
+
updateKind: require_Broker.UpdateKind.UPDATE_TYPE,
|
|
100
|
+
updateMode: require_Action.UpdateMode.POSITIVE
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
process.on("message", (message) => {
|
|
106
|
+
handleDevWorkerMessage(message, {
|
|
107
|
+
moduleServer,
|
|
108
|
+
log: require_Broker.fileLog
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
require_expose_rpc.exposeRpc(forkDevWorker);
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.forkDevWorker = forkDevWorker;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
require('./Broker-CaenCqdn.js');
|
|
3
|
+
const require_expose_rpc = require('./expose-rpc-BpRiu3VK.js');
|
|
4
|
+
|
|
5
|
+
//#region src/core/lib/forkGenerateDts.ts
|
|
6
|
+
async function forkGenerateDts(options) {
|
|
7
|
+
return require_expose_rpc.generateTypes(options);
|
|
8
|
+
}
|
|
9
|
+
process.on("message", (message) => {
|
|
10
|
+
if (message.type === require_expose_rpc.RpcGMCallTypes.EXIT) process.exit(0);
|
|
11
|
+
});
|
|
12
|
+
require_expose_rpc.exposeRpc(forkGenerateDts);
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.forkGenerateDts = forkGenerateDts;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
//#region src/server/constant.ts
|
|
5
|
+
const DEFAULT_WEB_SOCKET_PORT = 16322;
|
|
6
|
+
const WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/server/message/Message.ts
|
|
10
|
+
var Message = class {
|
|
11
|
+
constructor(type, kind) {
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.kind = kind;
|
|
14
|
+
this.time = Date.now();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/server/message/Action/Action.ts
|
|
20
|
+
let ActionKind = /* @__PURE__ */ function(ActionKind) {
|
|
21
|
+
ActionKind["ADD_SUBSCRIBER"] = "ADD_SUBSCRIBER";
|
|
22
|
+
ActionKind["EXIT_SUBSCRIBER"] = "EXIT_SUBSCRIBER";
|
|
23
|
+
ActionKind["ADD_PUBLISHER"] = "ADD_PUBLISHER";
|
|
24
|
+
ActionKind["UPDATE_PUBLISHER"] = "UPDATE_PUBLISHER";
|
|
25
|
+
ActionKind["NOTIFY_SUBSCRIBER"] = "NOTIFY_SUBSCRIBER";
|
|
26
|
+
ActionKind["EXIT_PUBLISHER"] = "EXIT_PUBLISHER";
|
|
27
|
+
ActionKind["ADD_WEB_CLIENT"] = "ADD_WEB_CLIENT";
|
|
28
|
+
ActionKind["NOTIFY_WEB_CLIENT"] = "NOTIFY_WEB_CLIENT";
|
|
29
|
+
ActionKind["FETCH_TYPES"] = "FETCH_TYPES";
|
|
30
|
+
ActionKind["ADD_DYNAMIC_REMOTE"] = "ADD_DYNAMIC_REMOTE";
|
|
31
|
+
return ActionKind;
|
|
32
|
+
}({});
|
|
33
|
+
var Action = class extends Message {
|
|
34
|
+
constructor(content, kind) {
|
|
35
|
+
super("Action", kind);
|
|
36
|
+
const { payload } = content;
|
|
37
|
+
this.payload = payload;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/server/message/Action/AddWebClient.ts
|
|
43
|
+
var AddWebClientAction = class extends Action {
|
|
44
|
+
constructor(payload) {
|
|
45
|
+
super({ payload }, ActionKind.ADD_WEB_CLIENT);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/server/message/API/API.ts
|
|
51
|
+
let APIKind = /* @__PURE__ */ function(APIKind) {
|
|
52
|
+
APIKind["UPDATE_SUBSCRIBER"] = "UPDATE_SUBSCRIBER";
|
|
53
|
+
APIKind["RELOAD_WEB_CLIENT"] = "RELOAD_WEB_CLIENT";
|
|
54
|
+
APIKind["FETCH_TYPES"] = "FETCH_TYPES";
|
|
55
|
+
return APIKind;
|
|
56
|
+
}({});
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../node_modules/.pnpm/isomorphic-ws@5.0.0_ws@8.21.0/node_modules/isomorphic-ws/browser.js
|
|
60
|
+
var ws = null;
|
|
61
|
+
if (typeof WebSocket !== "undefined") ws = WebSocket;
|
|
62
|
+
else if (typeof MozWebSocket !== "undefined") ws = MozWebSocket;
|
|
63
|
+
else if (typeof global !== "undefined") ws = global.WebSocket || global.MozWebSocket;
|
|
64
|
+
else if (typeof window !== "undefined") ws = window.WebSocket || window.MozWebSocket;
|
|
65
|
+
else if (typeof self !== "undefined") ws = self.WebSocket || self.MozWebSocket;
|
|
66
|
+
var browser_default = ws;
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/server/createWebsocket.ts
|
|
70
|
+
function createWebsocket() {
|
|
71
|
+
return new browser_default(`ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}?WEB_SOCKET_CONNECT_MAGIC_ID=${WEB_SOCKET_CONNECT_MAGIC_ID}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/server/WebClient.ts
|
|
76
|
+
var WebClient = class {
|
|
77
|
+
constructor(options) {
|
|
78
|
+
this._webSocket = null;
|
|
79
|
+
this._name = options.name;
|
|
80
|
+
this.logPrefix = options.logPrefix || "";
|
|
81
|
+
this._connect();
|
|
82
|
+
}
|
|
83
|
+
_connect() {
|
|
84
|
+
console.log(`${this.logPrefix}Trying to connect to {cyan ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}}...}`);
|
|
85
|
+
this._webSocket = createWebsocket();
|
|
86
|
+
this._webSocket.onopen = () => {
|
|
87
|
+
console.log(`${this.logPrefix}Connected to {cyan ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}} success!`);
|
|
88
|
+
const startWebClient = new AddWebClientAction({ name: this._name });
|
|
89
|
+
this._webSocket && this._webSocket.send(JSON.stringify(startWebClient));
|
|
90
|
+
};
|
|
91
|
+
this._webSocket.onmessage = (message) => {
|
|
92
|
+
console.log(message);
|
|
93
|
+
const parsedMessage = JSON.parse(message.data.toString());
|
|
94
|
+
if (parsedMessage.type === "API") {
|
|
95
|
+
if (parsedMessage.kind === APIKind.RELOAD_WEB_CLIENT) {
|
|
96
|
+
const { payload: { name } } = parsedMessage;
|
|
97
|
+
if (name !== this._name) return;
|
|
98
|
+
this._reload();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
this._webSocket.onerror = (err) => {
|
|
103
|
+
console.error(`${this.logPrefix}err: ${err}`);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
_reload() {
|
|
107
|
+
console.log(`${this.logPrefix}reload`);
|
|
108
|
+
location.reload();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/server/launchWebClient.ts
|
|
114
|
+
new WebClient(__WEB_CLIENT_OPTIONS__);
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
})();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { a as DTSManagerOptions } from "./DtsWorker-Bt7-_SGH.js";
|
|
2
|
+
import { d as isTSProject } from "./constant-YOdZl7sj.js";
|
|
3
|
+
import { moduleFederationPlugin } from "@module-federation/sdk";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/DtsPlugin.d.ts
|
|
6
|
+
declare const normalizeDtsOptions: (options: moduleFederationPlugin.ModuleFederationPluginOptions, context: string, defaultOptions?: {
|
|
7
|
+
defaultGenerateOptions?: moduleFederationPlugin.DtsRemoteOptions;
|
|
8
|
+
defaultConsumeOptions?: moduleFederationPlugin.DtsHostOptions;
|
|
9
|
+
}) => false | moduleFederationPlugin.PluginDtsOptions;
|
|
10
|
+
declare class DtsPlugin implements WebpackPluginInstance {
|
|
11
|
+
options: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
12
|
+
clonedOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
13
|
+
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
14
|
+
apply(compiler: Compiler): void;
|
|
15
|
+
addRuntimePlugins(): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/plugins/ConsumeTypesPlugin.d.ts
|
|
19
|
+
declare const normalizeConsumeTypesOptions: ({
|
|
20
|
+
context,
|
|
21
|
+
dtsOptions,
|
|
22
|
+
pluginOptions
|
|
23
|
+
}: {
|
|
24
|
+
context?: string;
|
|
25
|
+
dtsOptions: moduleFederationPlugin.PluginDtsOptions;
|
|
26
|
+
pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
27
|
+
}) => {
|
|
28
|
+
host: {
|
|
29
|
+
typesFolder?: string;
|
|
30
|
+
abortOnError?: boolean;
|
|
31
|
+
remoteTypesFolder?: string;
|
|
32
|
+
deleteTypesFolder?: boolean;
|
|
33
|
+
maxRetries?: number;
|
|
34
|
+
consumeAPITypes?: boolean;
|
|
35
|
+
runtimePkgs?: string[];
|
|
36
|
+
remoteTypeUrls?: (() => Promise<moduleFederationPlugin.RemoteTypeUrls>) | moduleFederationPlugin.RemoteTypeUrls;
|
|
37
|
+
timeout?: number;
|
|
38
|
+
family?: 0 | 4 | 6;
|
|
39
|
+
typesOnBuild?: boolean;
|
|
40
|
+
implementation: string | undefined;
|
|
41
|
+
context: string | undefined;
|
|
42
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
43
|
+
};
|
|
44
|
+
extraOptions: Record<string, any>;
|
|
45
|
+
displayErrorInTerminal: boolean | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
declare const consumeTypesAPI: (dtsManagerOptions: DTSManagerOptions, cb?: (options: moduleFederationPlugin.RemoteTypeUrls) => void) => Promise<void>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/plugins/GenerateTypesPlugin.d.ts
|
|
50
|
+
declare const normalizeGenerateTypesOptions: ({
|
|
51
|
+
context,
|
|
52
|
+
outputDir,
|
|
53
|
+
dtsOptions,
|
|
54
|
+
pluginOptions
|
|
55
|
+
}: {
|
|
56
|
+
context?: string;
|
|
57
|
+
outputDir?: string;
|
|
58
|
+
dtsOptions: moduleFederationPlugin.PluginDtsOptions;
|
|
59
|
+
pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
60
|
+
}) => DTSManagerOptions | undefined;
|
|
61
|
+
declare const generateTypesAPI: ({
|
|
62
|
+
dtsManagerOptions
|
|
63
|
+
}: {
|
|
64
|
+
dtsManagerOptions: DTSManagerOptions;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { DtsPlugin, consumeTypesAPI, generateTypesAPI, isTSProject, normalizeConsumeTypesOptions, normalizeDtsOptions, normalizeGenerateTypesOptions };
|