@module-federation/dts-plugin 0.1.19 → 0.1.21
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/CHANGELOG.md +27 -0
- package/dist/{DtsWorker-d731dc2b.d.ts → DtsWorker-7113d2b0.d.ts} +6 -3
- package/dist/core.d.mts +85 -0
- package/dist/core.d.ts +5 -5
- package/dist/core.js +1105 -1008
- package/dist/dynamic-remote-type-hints-plugin.d.mts +5 -0
- package/dist/dynamic-remote-type-hints-plugin.d.ts +5 -0
- package/dist/dynamic-remote-type-hints-plugin.js +198 -0
- package/dist/esm/chunk-55BKSNZ4.js +2372 -0
- package/dist/esm/chunk-G7ONFBMA.js +24 -0
- package/dist/esm/chunk-MQRIERJP.js +236 -0
- package/dist/esm/core.js +44 -0
- package/dist/esm/dynamic-remote-type-hints-plugin.js +73 -0
- package/dist/esm/fork-dev-worker.js +141 -0
- package/dist/esm/fork-generate-dts.js +26 -0
- package/dist/esm/index.js +406 -0
- package/dist/esm/start-broker.js +36 -0
- package/dist/fork-dev-worker.d.ts +15 -0
- package/dist/fork-dev-worker.js +2543 -0
- package/dist/{forkGenerateDts.d.ts → fork-generate-dts.d.mts} +1 -1
- package/dist/fork-generate-dts.d.ts +9 -0
- package/dist/fork-generate-dts.js +1902 -0
- package/dist/iife/launch-web-client.js +91 -42
- package/dist/index.d.mts +10 -0
- package/dist/index.js +1287 -1181
- package/dist/package.json +11 -2
- package/dist/{startBroker.d.ts → start-broker.d.mts} +2 -0
- package/dist/start-broker.d.ts +42 -0
- package/dist/start-broker.js +1273 -0
- package/package.json +14 -5
- package/dist/forkDevWorker.js +0 -2523
- package/dist/forkGenerateDts.js +0 -1618
- package/dist/launch-web-client.d.ts +0 -2
- package/dist/startBroker.js +0 -902
- /package/dist/{forkDevWorker.d.ts → fork-dev-worker.d.mts} +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import {
|
|
2
|
+
consumeTypes,
|
|
3
|
+
generateTypes,
|
|
4
|
+
generateTypesInChildProcess,
|
|
5
|
+
getIPV4,
|
|
6
|
+
isTSProject,
|
|
7
|
+
retrieveTypesAssetsInfo,
|
|
8
|
+
rpc_exports,
|
|
9
|
+
validateOptions
|
|
10
|
+
} from "./chunk-55BKSNZ4.js";
|
|
11
|
+
import {
|
|
12
|
+
WEB_CLIENT_OPTIONS_IDENTIFIER,
|
|
13
|
+
__async,
|
|
14
|
+
__name,
|
|
15
|
+
__publicField,
|
|
16
|
+
__spreadProps,
|
|
17
|
+
__spreadValues
|
|
18
|
+
} from "./chunk-MQRIERJP.js";
|
|
19
|
+
|
|
20
|
+
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
21
|
+
import fs from "fs-extra";
|
|
22
|
+
import chalk from "chalk";
|
|
23
|
+
|
|
24
|
+
// packages/dts-plugin/src/dev-worker/createDevWorker.ts
|
|
25
|
+
import * as path2 from "path";
|
|
26
|
+
import * as fse from "fs-extra";
|
|
27
|
+
|
|
28
|
+
// packages/dts-plugin/src/dev-worker/DevWorker.ts
|
|
29
|
+
import path from "path";
|
|
30
|
+
import cloneDeepWith from "lodash.clonedeepwith";
|
|
31
|
+
var _DevWorker = class _DevWorker {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
__publicField(this, "_rpcWorker");
|
|
34
|
+
__publicField(this, "_options");
|
|
35
|
+
__publicField(this, "_res");
|
|
36
|
+
this._options = cloneDeepWith(options, (_value, key) => {
|
|
37
|
+
if (key === "manifest") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.removeUnSerializationOptions();
|
|
42
|
+
this._rpcWorker = rpc_exports.createRpcWorker(path.resolve(__dirname, "./fork-dev-worker.js"), {}, void 0, false);
|
|
43
|
+
this._res = this._rpcWorker.connect(this._options);
|
|
44
|
+
}
|
|
45
|
+
// moduleFederationConfig.manifest may have un serialization options
|
|
46
|
+
removeUnSerializationOptions() {
|
|
47
|
+
var _a2, _b, _c, _d;
|
|
48
|
+
(_b = (_a2 = this._options.host) == null ? void 0 : _a2.moduleFederationConfig) == null ? true : delete _b.manifest;
|
|
49
|
+
(_d = (_c = this._options.remote) == null ? void 0 : _c.moduleFederationConfig) == null ? true : delete _d.manifest;
|
|
50
|
+
}
|
|
51
|
+
get controlledPromise() {
|
|
52
|
+
return this._res;
|
|
53
|
+
}
|
|
54
|
+
update() {
|
|
55
|
+
var _a2, _b;
|
|
56
|
+
(_b = (_a2 = this._rpcWorker.process) == null ? void 0 : _a2.send) == null ? void 0 : _b.call(_a2, {
|
|
57
|
+
type: rpc_exports.RpcGMCallTypes.CALL,
|
|
58
|
+
id: this._rpcWorker.id,
|
|
59
|
+
args: [
|
|
60
|
+
void 0,
|
|
61
|
+
"update"
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exit() {
|
|
66
|
+
var _a2;
|
|
67
|
+
(_a2 = this._rpcWorker) == null ? void 0 : _a2.terminate();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
__name(_DevWorker, "DevWorker");
|
|
71
|
+
var DevWorker = _DevWorker;
|
|
72
|
+
|
|
73
|
+
// packages/dts-plugin/src/dev-worker/createDevWorker.ts
|
|
74
|
+
function removeLogFile() {
|
|
75
|
+
return __async(this, null, function* () {
|
|
76
|
+
try {
|
|
77
|
+
const logDir = path2.resolve(process.cwd(), ".mf/typesGenerate.log");
|
|
78
|
+
yield fse.remove(logDir);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error("removeLogFile error", "forkDevWorker", err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
__name(removeLogFile, "removeLogFile");
|
|
85
|
+
function createDevWorker(options) {
|
|
86
|
+
removeLogFile();
|
|
87
|
+
return new DevWorker(__spreadValues({}, options));
|
|
88
|
+
}
|
|
89
|
+
__name(createDevWorker, "createDevWorker");
|
|
90
|
+
|
|
91
|
+
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
92
|
+
import { normalizeOptions } from "@module-federation/sdk";
|
|
93
|
+
import path3 from "path";
|
|
94
|
+
|
|
95
|
+
// packages/dts-plugin/src/plugins/utils.ts
|
|
96
|
+
function isDev() {
|
|
97
|
+
return process.env["NODE_ENV"] === "development";
|
|
98
|
+
}
|
|
99
|
+
__name(isDev, "isDev");
|
|
100
|
+
|
|
101
|
+
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
102
|
+
var PROCESS_EXIT_CODE;
|
|
103
|
+
(function(PROCESS_EXIT_CODE2) {
|
|
104
|
+
PROCESS_EXIT_CODE2[PROCESS_EXIT_CODE2["SUCCESS"] = 0] = "SUCCESS";
|
|
105
|
+
PROCESS_EXIT_CODE2[PROCESS_EXIT_CODE2["FAILURE"] = 1] = "FAILURE";
|
|
106
|
+
})(PROCESS_EXIT_CODE || (PROCESS_EXIT_CODE = {}));
|
|
107
|
+
function ensureTempDir(filePath) {
|
|
108
|
+
try {
|
|
109
|
+
const dir = path3.dirname(filePath);
|
|
110
|
+
fs.ensureDirSync(dir);
|
|
111
|
+
} catch (_err) {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
__name(ensureTempDir, "ensureTempDir");
|
|
115
|
+
var _DevPlugin = class _DevPlugin {
|
|
116
|
+
constructor(options) {
|
|
117
|
+
__publicField(this, "name", "MFDevPlugin");
|
|
118
|
+
__publicField(this, "_options");
|
|
119
|
+
__publicField(this, "_devWorker");
|
|
120
|
+
this._options = options;
|
|
121
|
+
}
|
|
122
|
+
static ensureLiveReloadEntry(options, filePath) {
|
|
123
|
+
ensureTempDir(filePath);
|
|
124
|
+
const liveReloadEntry = fs.readFileSync(path3.join(__dirname, "./iife/launch-web-client.js")).toString("utf-8");
|
|
125
|
+
const liveReloadEntryWithOptions = liveReloadEntry.replace(WEB_CLIENT_OPTIONS_IDENTIFIER, JSON.stringify(options));
|
|
126
|
+
fs.writeFileSync(filePath, liveReloadEntryWithOptions);
|
|
127
|
+
}
|
|
128
|
+
_stopWhenSIGTERMOrSIGINT() {
|
|
129
|
+
process.on("SIGTERM", () => {
|
|
130
|
+
console.log(chalk`{cyan ${this._options.name} Process(${process.pid}) SIGTERM, mf server will exit...}`);
|
|
131
|
+
this._exit(0);
|
|
132
|
+
});
|
|
133
|
+
process.on("SIGINT", () => {
|
|
134
|
+
console.log(chalk`{cyan ${this._options.name} Process(${process.pid}) SIGINT, mf server will exit...}`);
|
|
135
|
+
this._exit(0);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
_handleUnexpectedExit() {
|
|
139
|
+
process.on("unhandledRejection", (error) => {
|
|
140
|
+
console.error("Unhandled Rejection Error: ", error);
|
|
141
|
+
console.log(chalk`{cyan ${this._options.name} Process(${process.pid}) unhandledRejection, mf server will exit...}`);
|
|
142
|
+
this._exit(1);
|
|
143
|
+
});
|
|
144
|
+
process.on("uncaughtException", (error) => {
|
|
145
|
+
console.error("Unhandled Rejection Error: ", error);
|
|
146
|
+
console.log(chalk`{cyan ${this._options.name} Process(${process.pid}) uncaughtException, mf server will exit...}`);
|
|
147
|
+
this._exit(1);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
_exit(exitCode = 0) {
|
|
151
|
+
var _a2;
|
|
152
|
+
(_a2 = this._devWorker) == null ? void 0 : _a2.exit();
|
|
153
|
+
process.exit(exitCode);
|
|
154
|
+
}
|
|
155
|
+
_afterEmit() {
|
|
156
|
+
var _a2;
|
|
157
|
+
(_a2 = this._devWorker) == null ? void 0 : _a2.update();
|
|
158
|
+
}
|
|
159
|
+
apply(compiler) {
|
|
160
|
+
const { _options: { name, dev, dts } } = this;
|
|
161
|
+
new compiler.webpack.DefinePlugin({
|
|
162
|
+
FEDERATION_IPV4: JSON.stringify(getIPV4())
|
|
163
|
+
}).apply(compiler);
|
|
164
|
+
const normalizedDev = normalizeOptions(true, {
|
|
165
|
+
disableLiveReload: true,
|
|
166
|
+
disableHotTypesReload: false,
|
|
167
|
+
disableDynamicRemoteTypeHints: false
|
|
168
|
+
}, "mfOptions.dev")(dev);
|
|
169
|
+
if (!isDev() || normalizedDev === false) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (normalizedDev.disableHotTypesReload && normalizedDev.disableLiveReload && normalizedDev.disableDynamicRemoteTypeHints) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!name) {
|
|
176
|
+
throw new Error("name is required if you want to enable dev server!");
|
|
177
|
+
}
|
|
178
|
+
if (!normalizedDev.disableDynamicRemoteTypeHints) {
|
|
179
|
+
if (!this._options.runtimePlugins) {
|
|
180
|
+
this._options.runtimePlugins = [];
|
|
181
|
+
}
|
|
182
|
+
this._options.runtimePlugins.push(path3.resolve(__dirname, "dynamic-remote-type-hints-plugin.js"));
|
|
183
|
+
}
|
|
184
|
+
if (!normalizedDev.disableLiveReload) {
|
|
185
|
+
const TEMP_DIR = path3.join(`${process.cwd()}/node_modules`, `.federation`);
|
|
186
|
+
const filepath = path3.join(TEMP_DIR, `live-reload.js`);
|
|
187
|
+
_DevPlugin.ensureLiveReloadEntry({
|
|
188
|
+
name
|
|
189
|
+
}, filepath);
|
|
190
|
+
compiler.hooks.afterPlugins.tap("MFDevPlugin", () => {
|
|
191
|
+
new compiler.webpack.EntryPlugin(compiler.context, filepath, {
|
|
192
|
+
name
|
|
193
|
+
}).apply(compiler);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const defaultGenerateTypes = {
|
|
197
|
+
compileInChildProcess: true
|
|
198
|
+
};
|
|
199
|
+
const defaultConsumeTypes = {
|
|
200
|
+
consumeAPITypes: true
|
|
201
|
+
};
|
|
202
|
+
const normalizedDtsOptions = normalizeOptions(isTSProject(dts, compiler.context), {
|
|
203
|
+
// remote types dist(.dev-server) not be used currently, so no need to set extractThirdParty etc
|
|
204
|
+
generateTypes: defaultGenerateTypes,
|
|
205
|
+
consumeTypes: defaultConsumeTypes,
|
|
206
|
+
extraOptions: {}
|
|
207
|
+
}, "mfOptions.dts")(dts);
|
|
208
|
+
const normalizedGenerateTypes = normalizeOptions(Boolean(normalizedDtsOptions), defaultGenerateTypes, "mfOptions.dts.generateTypes")(normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.generateTypes);
|
|
209
|
+
const remote = normalizedGenerateTypes === false ? void 0 : __spreadProps(__spreadValues({
|
|
210
|
+
implementation: normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.implementation,
|
|
211
|
+
context: compiler.context,
|
|
212
|
+
moduleFederationConfig: __spreadValues({}, this._options),
|
|
213
|
+
hostRemoteTypesFolder: normalizedGenerateTypes.typesFolder || "@mf-types"
|
|
214
|
+
}, normalizedGenerateTypes), {
|
|
215
|
+
typesFolder: `.dev-server`
|
|
216
|
+
});
|
|
217
|
+
const normalizedConsumeTypes = normalizeOptions(Boolean(normalizedDtsOptions), defaultConsumeTypes, "mfOptions.dts.consumeTypes")(normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.consumeTypes);
|
|
218
|
+
const host = normalizedConsumeTypes === false ? void 0 : __spreadValues({
|
|
219
|
+
implementation: normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.implementation,
|
|
220
|
+
context: compiler.context,
|
|
221
|
+
moduleFederationConfig: this._options,
|
|
222
|
+
typesFolder: normalizedConsumeTypes.typesFolder || "@mf-types",
|
|
223
|
+
abortOnError: false
|
|
224
|
+
}, normalizedConsumeTypes);
|
|
225
|
+
const extraOptions = normalizedDtsOptions ? normalizedDtsOptions.extraOptions || {} : {};
|
|
226
|
+
if (!remote && !host && normalizedDev.disableLiveReload) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (remote && !(remote == null ? void 0 : remote.tsConfigPath) && typeof normalizedDtsOptions === "object" && normalizedDtsOptions.tsConfigPath) {
|
|
230
|
+
remote.tsConfigPath = normalizedDtsOptions.tsConfigPath;
|
|
231
|
+
}
|
|
232
|
+
this._devWorker = createDevWorker({
|
|
233
|
+
name,
|
|
234
|
+
remote,
|
|
235
|
+
host,
|
|
236
|
+
extraOptions,
|
|
237
|
+
disableLiveReload: normalizedDev.disableHotTypesReload,
|
|
238
|
+
disableHotTypesReload: normalizedDev.disableHotTypesReload
|
|
239
|
+
});
|
|
240
|
+
this._stopWhenSIGTERMOrSIGINT();
|
|
241
|
+
this._handleUnexpectedExit();
|
|
242
|
+
compiler.hooks.afterEmit.tap(this.name, this._afterEmit.bind(this));
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
__name(_DevPlugin, "DevPlugin");
|
|
246
|
+
var DevPlugin = _DevPlugin;
|
|
247
|
+
|
|
248
|
+
// packages/dts-plugin/src/plugins/TypesPlugin.ts
|
|
249
|
+
import { normalizeOptions as normalizeOptions4 } from "@module-federation/sdk";
|
|
250
|
+
|
|
251
|
+
// packages/dts-plugin/src/plugins/ConsumeTypesPlugin.ts
|
|
252
|
+
import { normalizeOptions as normalizeOptions2 } from "@module-federation/sdk";
|
|
253
|
+
var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
254
|
+
constructor(pluginOptions, dtsOptions, defaultOptions) {
|
|
255
|
+
__publicField(this, "pluginOptions");
|
|
256
|
+
__publicField(this, "dtsOptions");
|
|
257
|
+
__publicField(this, "defaultOptions");
|
|
258
|
+
this.pluginOptions = pluginOptions;
|
|
259
|
+
this.dtsOptions = dtsOptions;
|
|
260
|
+
this.defaultOptions = defaultOptions;
|
|
261
|
+
}
|
|
262
|
+
apply(compiler) {
|
|
263
|
+
const { dtsOptions, defaultOptions, pluginOptions } = this;
|
|
264
|
+
const normalizedConsumeTypes = normalizeOptions2(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
265
|
+
if (!normalizedConsumeTypes) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const finalOptions = {
|
|
269
|
+
host: __spreadValues({
|
|
270
|
+
implementation: dtsOptions.implementation,
|
|
271
|
+
context: compiler.context,
|
|
272
|
+
moduleFederationConfig: pluginOptions
|
|
273
|
+
}, normalizedConsumeTypes),
|
|
274
|
+
extraOptions: dtsOptions.extraOptions || {}
|
|
275
|
+
};
|
|
276
|
+
validateOptions(finalOptions.host);
|
|
277
|
+
consumeTypes(finalOptions);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
__name(_ConsumeTypesPlugin, "ConsumeTypesPlugin");
|
|
281
|
+
var ConsumeTypesPlugin = _ConsumeTypesPlugin;
|
|
282
|
+
|
|
283
|
+
// packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
|
|
284
|
+
import fs2 from "fs";
|
|
285
|
+
import { normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
|
|
286
|
+
var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
287
|
+
constructor(pluginOptions, dtsOptions, defaultOptions) {
|
|
288
|
+
__publicField(this, "pluginOptions");
|
|
289
|
+
__publicField(this, "dtsOptions");
|
|
290
|
+
__publicField(this, "defaultOptions");
|
|
291
|
+
this.pluginOptions = pluginOptions;
|
|
292
|
+
this.dtsOptions = dtsOptions;
|
|
293
|
+
this.defaultOptions = defaultOptions;
|
|
294
|
+
}
|
|
295
|
+
apply(compiler) {
|
|
296
|
+
const { dtsOptions, defaultOptions, pluginOptions } = this;
|
|
297
|
+
const normalizedGenerateTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
|
|
298
|
+
if (!normalizedGenerateTypes) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const finalOptions = {
|
|
302
|
+
remote: __spreadValues({
|
|
303
|
+
implementation: dtsOptions.implementation,
|
|
304
|
+
context: compiler.context,
|
|
305
|
+
moduleFederationConfig: pluginOptions
|
|
306
|
+
}, normalizedGenerateTypes),
|
|
307
|
+
extraOptions: dtsOptions.extraOptions || {}
|
|
308
|
+
};
|
|
309
|
+
if (dtsOptions.tsConfigPath && !finalOptions.remote.tsConfigPath) {
|
|
310
|
+
finalOptions.remote.tsConfigPath = dtsOptions.tsConfigPath;
|
|
311
|
+
}
|
|
312
|
+
validateOptions(finalOptions.remote);
|
|
313
|
+
const isProd = !isDev();
|
|
314
|
+
const getGenerateTypesFn = /* @__PURE__ */ __name(() => {
|
|
315
|
+
let fn = generateTypes;
|
|
316
|
+
let res;
|
|
317
|
+
if (finalOptions.remote.compileInChildProcess) {
|
|
318
|
+
fn = generateTypesInChildProcess;
|
|
319
|
+
}
|
|
320
|
+
if (isProd) {
|
|
321
|
+
res = fn(finalOptions);
|
|
322
|
+
return () => res;
|
|
323
|
+
}
|
|
324
|
+
return fn;
|
|
325
|
+
}, "getGenerateTypesFn");
|
|
326
|
+
const generateTypesFn = getGenerateTypesFn();
|
|
327
|
+
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
328
|
+
compilation.hooks.processAssets.tapPromise({
|
|
329
|
+
name: "mf:generateTypes",
|
|
330
|
+
stage: (
|
|
331
|
+
// @ts-expect-error use runtime variable in case peer dep not installed
|
|
332
|
+
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
333
|
+
)
|
|
334
|
+
}, () => __async(this, null, function* () {
|
|
335
|
+
try {
|
|
336
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
|
|
337
|
+
if (zipName && compilation.getAsset(zipName)) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
yield generateTypesFn(finalOptions);
|
|
341
|
+
if (zipTypesPath) {
|
|
342
|
+
compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
|
|
343
|
+
}
|
|
344
|
+
if (apiTypesPath) {
|
|
345
|
+
compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
|
|
346
|
+
}
|
|
347
|
+
} catch (err) {
|
|
348
|
+
console.error(err);
|
|
349
|
+
}
|
|
350
|
+
}));
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
__name(_GenerateTypesPlugin, "GenerateTypesPlugin");
|
|
355
|
+
var GenerateTypesPlugin = _GenerateTypesPlugin;
|
|
356
|
+
|
|
357
|
+
// packages/dts-plugin/src/plugins/TypesPlugin.ts
|
|
358
|
+
var _a;
|
|
359
|
+
var TypesPlugin = (_a = class {
|
|
360
|
+
constructor(options) {
|
|
361
|
+
__publicField(this, "options");
|
|
362
|
+
this.options = options;
|
|
363
|
+
}
|
|
364
|
+
apply(compiler) {
|
|
365
|
+
const { options } = this;
|
|
366
|
+
const defaultGenerateTypes = {
|
|
367
|
+
generateAPITypes: true,
|
|
368
|
+
compileInChildProcess: true,
|
|
369
|
+
abortOnError: false,
|
|
370
|
+
extractThirdParty: true,
|
|
371
|
+
extractRemoteTypes: true
|
|
372
|
+
};
|
|
373
|
+
const defaultConsumeTypes = {
|
|
374
|
+
abortOnError: false,
|
|
375
|
+
consumeAPITypes: true
|
|
376
|
+
};
|
|
377
|
+
const normalizedDtsOptions = normalizeOptions4(isTSProject(options.dts, compiler.context), {
|
|
378
|
+
generateTypes: defaultGenerateTypes,
|
|
379
|
+
consumeTypes: defaultConsumeTypes,
|
|
380
|
+
extraOptions: {}
|
|
381
|
+
}, "mfOptions.dts")(options.dts);
|
|
382
|
+
if (typeof normalizedDtsOptions !== "object") {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes).apply(compiler);
|
|
386
|
+
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes).apply(compiler);
|
|
387
|
+
}
|
|
388
|
+
}, __name(_a, "TypesPlugin"), _a);
|
|
389
|
+
|
|
390
|
+
// packages/dts-plugin/src/plugins/DtsPlugin.ts
|
|
391
|
+
var _DtsPlugin = class _DtsPlugin {
|
|
392
|
+
constructor(options) {
|
|
393
|
+
__publicField(this, "options");
|
|
394
|
+
this.options = options;
|
|
395
|
+
}
|
|
396
|
+
apply(compiler) {
|
|
397
|
+
const { options } = this;
|
|
398
|
+
new DevPlugin(options).apply(compiler);
|
|
399
|
+
new TypesPlugin(options).apply(compiler);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
__name(_DtsPlugin, "DtsPlugin");
|
|
403
|
+
var DtsPlugin = _DtsPlugin;
|
|
404
|
+
export {
|
|
405
|
+
DtsPlugin
|
|
406
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Broker,
|
|
3
|
+
fileLog
|
|
4
|
+
} from "./chunk-55BKSNZ4.js";
|
|
5
|
+
import {
|
|
6
|
+
__async,
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-MQRIERJP.js";
|
|
9
|
+
|
|
10
|
+
// packages/dts-plugin/src/server/broker/startBroker.ts
|
|
11
|
+
var broker;
|
|
12
|
+
function getBroker() {
|
|
13
|
+
return broker;
|
|
14
|
+
}
|
|
15
|
+
__name(getBroker, "getBroker");
|
|
16
|
+
function startBroker() {
|
|
17
|
+
return __async(this, null, function* () {
|
|
18
|
+
var _a;
|
|
19
|
+
if (getBroker()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
broker = new Broker();
|
|
23
|
+
yield broker.start();
|
|
24
|
+
(_a = process.send) == null ? void 0 : _a.call(process, "ready");
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
__name(startBroker, "startBroker");
|
|
28
|
+
process.on("message", (message) => {
|
|
29
|
+
if (message === "start") {
|
|
30
|
+
fileLog(`startBroker... ${process.pid}`, "StartBroker", "info");
|
|
31
|
+
startBroker();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export {
|
|
35
|
+
getBroker
|
|
36
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { D as DTSManagerOptions } from './DTSManagerOptions-c0728719.js';
|
|
2
|
+
import '@module-federation/sdk';
|
|
3
|
+
|
|
4
|
+
interface DevWorkerOptions extends DTSManagerOptions {
|
|
5
|
+
name: string;
|
|
6
|
+
disableLiveReload?: boolean;
|
|
7
|
+
disableHotTypesReload?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface Options extends DevWorkerOptions {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
declare function forkDevWorker(options: Options, action?: string): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { forkDevWorker };
|