@module-federation/dts-plugin 0.9.0 → 0.9.1
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 +15 -0
- package/dist/{DtsWorker-484d9f4a.d.ts → DtsWorker-edc3f145.d.ts} +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +66 -19
- package/dist/esm/{chunk-UK7YFESF.js → chunk-LHN7ASHT.js} +1 -1
- package/dist/esm/{chunk-XXMD5NAZ.js → chunk-ZU4UW7EP.js} +66 -19
- package/dist/esm/core.js +2 -2
- package/dist/esm/fork-dev-worker.js +2 -2
- package/dist/esm/fork-generate-dts.js +1 -1
- package/dist/esm/index.js +49 -29
- package/dist/fork-dev-worker.js +66 -19
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +66 -19
- package/dist/index.js +119 -52
- package/dist/package.json +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -88,12 +88,12 @@ __export(src_exports, {
|
|
|
88
88
|
module.exports = __toCommonJS(src_exports);
|
|
89
89
|
|
|
90
90
|
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
91
|
-
var
|
|
91
|
+
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
92
92
|
var import_path9 = __toESM(require("path"));
|
|
93
93
|
|
|
94
94
|
// packages/dts-plugin/src/dev-worker/createDevWorker.ts
|
|
95
95
|
var path5 = __toESM(require("path"));
|
|
96
|
-
var
|
|
96
|
+
var fse2 = __toESM(require("fs-extra"));
|
|
97
97
|
|
|
98
98
|
// packages/dts-plugin/src/dev-worker/DevWorker.ts
|
|
99
99
|
var import_path7 = __toESM(require("path"));
|
|
@@ -117,6 +117,7 @@ var import_ansi_colors = __toESM(require("ansi-colors"));
|
|
|
117
117
|
var import_path3 = __toESM(require("path"));
|
|
118
118
|
var import_promises3 = require("fs/promises");
|
|
119
119
|
var import_fs = __toESM(require("fs"));
|
|
120
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
120
121
|
var import_sdk5 = require("@module-federation/sdk");
|
|
121
122
|
var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
|
|
122
123
|
|
|
@@ -1226,7 +1227,8 @@ var defaultOptions = {
|
|
|
1226
1227
|
context: process.cwd(),
|
|
1227
1228
|
abortOnError: true,
|
|
1228
1229
|
consumeAPITypes: false,
|
|
1229
|
-
runtimePkgs: []
|
|
1230
|
+
runtimePkgs: [],
|
|
1231
|
+
remoteTypeUrls: {}
|
|
1230
1232
|
};
|
|
1231
1233
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1232
1234
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1242,18 +1244,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
1242
1244
|
}, "buildApiTypeUrl");
|
|
1243
1245
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
1244
1246
|
const { hostOptions, remoteAlias, remote } = options;
|
|
1247
|
+
const { remoteTypeUrls } = hostOptions;
|
|
1245
1248
|
let decodedRemote = remote;
|
|
1246
1249
|
if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
|
|
1247
1250
|
decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
|
|
1248
1251
|
}
|
|
1249
1252
|
const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
|
|
1250
1253
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
1251
|
-
|
|
1254
|
+
let zipUrl = "";
|
|
1255
|
+
let apiTypeUrl = "";
|
|
1256
|
+
const name = parsedInfo.name || remoteAlias;
|
|
1257
|
+
if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
|
|
1258
|
+
zipUrl = remoteTypeUrls[name].zip;
|
|
1259
|
+
apiTypeUrl = remoteTypeUrls[name].api;
|
|
1260
|
+
}
|
|
1261
|
+
if (!zipUrl && url) {
|
|
1262
|
+
zipUrl = buildZipUrl(hostOptions, url);
|
|
1263
|
+
}
|
|
1264
|
+
if (!apiTypeUrl && zipUrl) {
|
|
1265
|
+
apiTypeUrl = buildApiTypeUrl(zipUrl);
|
|
1266
|
+
}
|
|
1252
1267
|
return {
|
|
1253
|
-
name
|
|
1268
|
+
name,
|
|
1254
1269
|
url,
|
|
1255
1270
|
zipUrl,
|
|
1256
|
-
apiTypeUrl
|
|
1271
|
+
apiTypeUrl,
|
|
1257
1272
|
alias: remoteAlias
|
|
1258
1273
|
};
|
|
1259
1274
|
}, "retrieveRemoteInfo");
|
|
@@ -1329,6 +1344,7 @@ var DTSManager = (_a = class {
|
|
|
1329
1344
|
}
|
|
1330
1345
|
extractRemoteTypes(options) {
|
|
1331
1346
|
return __async(this, null, function* () {
|
|
1347
|
+
var _a3;
|
|
1332
1348
|
const { remoteOptions, tsConfig } = options;
|
|
1333
1349
|
if (!remoteOptions.extractRemoteTypes) {
|
|
1334
1350
|
return;
|
|
@@ -1343,20 +1359,29 @@ var DTSManager = (_a = class {
|
|
|
1343
1359
|
}
|
|
1344
1360
|
}
|
|
1345
1361
|
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1346
|
-
if (hasRemotes) {
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1362
|
+
if (hasRemotes && this.options.host) {
|
|
1363
|
+
try {
|
|
1364
|
+
const { hostOptions } = retrieveHostConfig(this.options.host);
|
|
1365
|
+
const remoteTypesFolder = import_path3.default.resolve(hostOptions.context, hostOptions.typesFolder);
|
|
1366
|
+
const targetDir = import_path3.default.join(mfTypesPath, "node_modules");
|
|
1367
|
+
if (import_fs.default.existsSync(remoteTypesFolder)) {
|
|
1368
|
+
const targetFolder = import_path3.default.resolve(remoteOptions.context, targetDir);
|
|
1369
|
+
yield import_fs_extra3.default.ensureDir(targetFolder);
|
|
1370
|
+
yield import_fs_extra3.default.copy(remoteTypesFolder, targetFolder, {
|
|
1371
|
+
overwrite: true
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
} catch (err) {
|
|
1375
|
+
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1376
|
+
fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
|
|
1377
|
+
} else {
|
|
1378
|
+
throw err;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1357
1381
|
}
|
|
1358
1382
|
});
|
|
1359
1383
|
}
|
|
1384
|
+
// it must execute after consumeTypes
|
|
1360
1385
|
generateTypes() {
|
|
1361
1386
|
return __async(this, null, function* () {
|
|
1362
1387
|
var _a3;
|
|
@@ -1369,6 +1394,18 @@ var DTSManager = (_a = class {
|
|
|
1369
1394
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1370
1395
|
return;
|
|
1371
1396
|
}
|
|
1397
|
+
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1398
|
+
try {
|
|
1399
|
+
const tsBuildInfoFile = import_path3.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
1400
|
+
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1401
|
+
if (!import_fs.default.existsSync(mfTypesPath)) {
|
|
1402
|
+
import_fs.default.rmSync(tsBuildInfoFile, {
|
|
1403
|
+
force: true
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
} catch (e) {
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1372
1409
|
yield this.extractRemoteTypes({
|
|
1373
1410
|
remoteOptions,
|
|
1374
1411
|
tsConfig,
|
|
@@ -1398,7 +1435,7 @@ var DTSManager = (_a = class {
|
|
|
1398
1435
|
} catch (error2) {
|
|
1399
1436
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1400
1437
|
if (this.options.displayErrorInTerminal) {
|
|
1401
|
-
logger.error(`Unable to compile federated types${error2}`);
|
|
1438
|
+
logger.error(`Unable to compile federated types ${error2}`);
|
|
1402
1439
|
}
|
|
1403
1440
|
} else {
|
|
1404
1441
|
throw error2;
|
|
@@ -1412,6 +1449,9 @@ var DTSManager = (_a = class {
|
|
|
1412
1449
|
if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
|
|
1413
1450
|
return remoteInfo;
|
|
1414
1451
|
}
|
|
1452
|
+
if (remoteInfo.zipUrl) {
|
|
1453
|
+
return remoteInfo;
|
|
1454
|
+
}
|
|
1415
1455
|
const url = remoteInfo.url;
|
|
1416
1456
|
const res = yield axiosGet(url);
|
|
1417
1457
|
const manifestJson = res.data;
|
|
@@ -1477,8 +1517,10 @@ var DTSManager = (_a = class {
|
|
|
1477
1517
|
apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
|
|
1478
1518
|
const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
|
|
1479
1519
|
import_fs.default.writeFileSync(filePath, apiTypeFile);
|
|
1520
|
+
const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
|
|
1480
1521
|
this.loadedRemoteAPIAlias.add(remoteInfo.alias);
|
|
1481
1522
|
fileLog(`success`, "downloadAPITypes", "info");
|
|
1523
|
+
return existed;
|
|
1482
1524
|
} catch (err) {
|
|
1483
1525
|
fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
|
|
1484
1526
|
}
|
|
@@ -1620,7 +1662,10 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1620
1662
|
// use remoteTarPath first
|
|
1621
1663
|
zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
|
|
1622
1664
|
}));
|
|
1623
|
-
yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1665
|
+
const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1666
|
+
if (addNew) {
|
|
1667
|
+
this.consumeAPITypes(hostOptions);
|
|
1668
|
+
}
|
|
1624
1669
|
fileLog(`consumeTypes end`, "updateTypes", "info");
|
|
1625
1670
|
}), "consumeTypes");
|
|
1626
1671
|
fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
|
|
@@ -1638,7 +1683,6 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1638
1683
|
} else if (updatedRemoteInfo) {
|
|
1639
1684
|
const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
|
|
1640
1685
|
yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
|
|
1641
|
-
this.consumeAPITypes(hostOptions);
|
|
1642
1686
|
}), "consumeDynamicRemoteTypes");
|
|
1643
1687
|
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
|
|
1644
1688
|
const parsedRemoteInfo = retrieveRemoteInfo({
|
|
@@ -1756,10 +1800,13 @@ function cloneDeepOptions(options) {
|
|
|
1756
1800
|
"manifest",
|
|
1757
1801
|
"async"
|
|
1758
1802
|
];
|
|
1759
|
-
return (0, import_lodash.default)(options, (
|
|
1803
|
+
return (0, import_lodash.default)(options, (value, key) => {
|
|
1760
1804
|
if (typeof key === "string" && excludeKeys.includes(key)) {
|
|
1761
1805
|
return false;
|
|
1762
1806
|
}
|
|
1807
|
+
if (typeof value === "function") {
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1763
1810
|
});
|
|
1764
1811
|
}
|
|
1765
1812
|
__name(cloneDeepOptions, "cloneDeepOptions");
|
|
@@ -2287,7 +2334,7 @@ function removeLogFile() {
|
|
|
2287
2334
|
return __async(this, null, function* () {
|
|
2288
2335
|
try {
|
|
2289
2336
|
const logDir = path5.resolve(process.cwd(), ".mf/typesGenerate.log");
|
|
2290
|
-
yield
|
|
2337
|
+
yield fse2.remove(logDir);
|
|
2291
2338
|
} catch (err) {
|
|
2292
2339
|
console.error("removeLogFile error", "forkDevWorker", err);
|
|
2293
2340
|
}
|
|
@@ -2331,27 +2378,29 @@ var PROCESS_EXIT_CODE;
|
|
|
2331
2378
|
function ensureTempDir(filePath) {
|
|
2332
2379
|
try {
|
|
2333
2380
|
const dir = import_path9.default.dirname(filePath);
|
|
2334
|
-
|
|
2381
|
+
import_fs_extra4.default.ensureDirSync(dir);
|
|
2335
2382
|
} catch (_err) {
|
|
2336
2383
|
}
|
|
2337
2384
|
}
|
|
2338
2385
|
__name(ensureTempDir, "ensureTempDir");
|
|
2339
2386
|
var _DevPlugin = class _DevPlugin {
|
|
2340
|
-
constructor(options, dtsOptions,
|
|
2387
|
+
constructor(options, dtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise) {
|
|
2341
2388
|
__publicField(this, "name", "MFDevPlugin");
|
|
2342
2389
|
__publicField(this, "_options");
|
|
2343
2390
|
__publicField(this, "_devWorker");
|
|
2344
2391
|
__publicField(this, "dtsOptions");
|
|
2345
|
-
__publicField(this, "
|
|
2392
|
+
__publicField(this, "generateTypesPromise");
|
|
2393
|
+
__publicField(this, "fetchRemoteTypeUrlsPromise");
|
|
2346
2394
|
this._options = options;
|
|
2347
|
-
this.
|
|
2395
|
+
this.generateTypesPromise = generateTypesPromise;
|
|
2348
2396
|
this.dtsOptions = dtsOptions;
|
|
2397
|
+
this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
|
|
2349
2398
|
}
|
|
2350
2399
|
static ensureLiveReloadEntry(options, filePath) {
|
|
2351
2400
|
ensureTempDir(filePath);
|
|
2352
|
-
const liveReloadEntry =
|
|
2401
|
+
const liveReloadEntry = import_fs_extra4.default.readFileSync(import_path9.default.join(__dirname, "./iife/launch-web-client.js")).toString("utf-8");
|
|
2353
2402
|
const liveReloadEntryWithOptions = liveReloadEntry.replace(WEB_CLIENT_OPTIONS_IDENTIFIER, JSON.stringify(options));
|
|
2354
|
-
|
|
2403
|
+
import_fs_extra4.default.writeFileSync(filePath, liveReloadEntryWithOptions);
|
|
2355
2404
|
}
|
|
2356
2405
|
_stopWhenSIGTERMOrSIGINT() {
|
|
2357
2406
|
process.on("SIGTERM", () => {
|
|
@@ -2463,11 +2512,16 @@ var _DevPlugin = class _DevPlugin {
|
|
|
2463
2512
|
if (remote && !(remote == null ? void 0 : remote.tsConfigPath) && typeof normalizedDtsOptions === "object" && normalizedDtsOptions.tsConfigPath) {
|
|
2464
2513
|
remote.tsConfigPath = normalizedDtsOptions.tsConfigPath;
|
|
2465
2514
|
}
|
|
2466
|
-
|
|
2515
|
+
Promise.all([
|
|
2516
|
+
this.generateTypesPromise,
|
|
2517
|
+
this.fetchRemoteTypeUrlsPromise
|
|
2518
|
+
]).then(([_, remoteTypeUrls]) => {
|
|
2467
2519
|
this._devWorker = createDevWorker({
|
|
2468
2520
|
name,
|
|
2469
2521
|
remote,
|
|
2470
|
-
host,
|
|
2522
|
+
host: __spreadProps(__spreadValues({}, host), {
|
|
2523
|
+
remoteTypeUrls
|
|
2524
|
+
}),
|
|
2471
2525
|
extraOptions,
|
|
2472
2526
|
disableLiveReload: normalizedDev.disableHotTypesReload,
|
|
2473
2527
|
disableHotTypesReload: normalizedDev.disableHotTypesReload
|
|
@@ -2487,25 +2541,26 @@ var import_sdk10 = require("@module-federation/sdk");
|
|
|
2487
2541
|
// packages/dts-plugin/src/plugins/ConsumeTypesPlugin.ts
|
|
2488
2542
|
var import_sdk8 = require("@module-federation/sdk");
|
|
2489
2543
|
var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
2490
|
-
constructor(pluginOptions, dtsOptions, defaultOptions3,
|
|
2544
|
+
constructor(pluginOptions, dtsOptions, defaultOptions3, fetchRemoteTypeUrlsResolve) {
|
|
2491
2545
|
__publicField(this, "pluginOptions");
|
|
2492
2546
|
__publicField(this, "dtsOptions");
|
|
2493
2547
|
__publicField(this, "defaultOptions");
|
|
2494
2548
|
__publicField(this, "callback");
|
|
2549
|
+
__publicField(this, "fetchRemoteTypeUrlsResolve");
|
|
2495
2550
|
this.pluginOptions = pluginOptions;
|
|
2496
2551
|
this.dtsOptions = dtsOptions;
|
|
2497
2552
|
this.defaultOptions = defaultOptions3;
|
|
2498
|
-
this.
|
|
2553
|
+
this.fetchRemoteTypeUrlsResolve = fetchRemoteTypeUrlsResolve;
|
|
2499
2554
|
}
|
|
2500
2555
|
apply(compiler) {
|
|
2501
|
-
const { dtsOptions, defaultOptions: defaultOptions3, pluginOptions,
|
|
2556
|
+
const { dtsOptions, defaultOptions: defaultOptions3, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
2502
2557
|
if (isPrd()) {
|
|
2503
|
-
|
|
2558
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
2504
2559
|
return;
|
|
2505
2560
|
}
|
|
2506
2561
|
const normalizedConsumeTypes = (0, import_sdk8.normalizeOptions)(true, defaultOptions3, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
2507
2562
|
if (!normalizedConsumeTypes) {
|
|
2508
|
-
|
|
2563
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
2509
2564
|
return;
|
|
2510
2565
|
}
|
|
2511
2566
|
const finalOptions = {
|
|
@@ -2518,10 +2573,17 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2518
2573
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
2519
2574
|
};
|
|
2520
2575
|
validateOptions(finalOptions.host);
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2576
|
+
const fetchRemoteTypeUrlsPromise = typeof normalizedConsumeTypes.remoteTypeUrls === "function" ? normalizedConsumeTypes.remoteTypeUrls() : Promise.resolve(normalizedConsumeTypes.remoteTypeUrls);
|
|
2577
|
+
const promise = fetchRemoteTypeUrlsPromise.then((remoteTypeUrls) => {
|
|
2578
|
+
consumeTypes(__spreadProps(__spreadValues({}, finalOptions), {
|
|
2579
|
+
host: __spreadProps(__spreadValues({}, finalOptions.host), {
|
|
2580
|
+
remoteTypeUrls
|
|
2581
|
+
})
|
|
2582
|
+
})).then(() => {
|
|
2583
|
+
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
2584
|
+
}).catch(() => {
|
|
2585
|
+
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
2586
|
+
});
|
|
2525
2587
|
});
|
|
2526
2588
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
2527
2589
|
compilation.hooks.processAssets.tapPromise({
|
|
@@ -2544,25 +2606,26 @@ var import_fs4 = __toESM(require("fs"));
|
|
|
2544
2606
|
var import_path10 = __toESM(require("path"));
|
|
2545
2607
|
var import_sdk9 = require("@module-federation/sdk");
|
|
2546
2608
|
var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
2547
|
-
constructor(pluginOptions, dtsOptions, defaultOptions3,
|
|
2609
|
+
constructor(pluginOptions, dtsOptions, defaultOptions3, fetchRemoteTypeUrlsPromise, callback) {
|
|
2548
2610
|
__publicField(this, "pluginOptions");
|
|
2549
2611
|
__publicField(this, "dtsOptions");
|
|
2550
2612
|
__publicField(this, "defaultOptions");
|
|
2551
|
-
__publicField(this, "
|
|
2613
|
+
__publicField(this, "fetchRemoteTypeUrlsPromise");
|
|
2552
2614
|
__publicField(this, "callback");
|
|
2553
2615
|
this.pluginOptions = pluginOptions;
|
|
2554
2616
|
this.dtsOptions = dtsOptions;
|
|
2555
2617
|
this.defaultOptions = defaultOptions3;
|
|
2556
|
-
this.
|
|
2618
|
+
this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
|
|
2557
2619
|
this.callback = callback;
|
|
2558
2620
|
}
|
|
2559
2621
|
apply(compiler) {
|
|
2560
|
-
const { dtsOptions, defaultOptions: defaultOptions3, pluginOptions,
|
|
2622
|
+
const { dtsOptions, defaultOptions: defaultOptions3, pluginOptions, fetchRemoteTypeUrlsPromise, callback } = this;
|
|
2561
2623
|
const normalizedGenerateTypes = (0, import_sdk9.normalizeOptions)(true, defaultOptions3, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
|
|
2562
2624
|
if (!normalizedGenerateTypes) {
|
|
2563
2625
|
callback();
|
|
2564
2626
|
return;
|
|
2565
2627
|
}
|
|
2628
|
+
const normalizedConsumeTypes = (0, import_sdk9.normalizeOptions)(true, defaultOptions3, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
2566
2629
|
const finalOptions = {
|
|
2567
2630
|
remote: __spreadValues({
|
|
2568
2631
|
implementation: dtsOptions.implementation,
|
|
@@ -2570,6 +2633,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
2570
2633
|
outputDir: getCompilerOutputDir(compiler),
|
|
2571
2634
|
moduleFederationConfig: pluginOptions
|
|
2572
2635
|
}, normalizedGenerateTypes),
|
|
2636
|
+
host: normalizedConsumeTypes === false ? void 0 : __spreadValues({
|
|
2637
|
+
context: compiler.context,
|
|
2638
|
+
moduleFederationConfig: pluginOptions
|
|
2639
|
+
}, normalizedGenerateTypes),
|
|
2573
2640
|
extraOptions: dtsOptions.extraOptions || {},
|
|
2574
2641
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
2575
2642
|
};
|
|
@@ -2677,7 +2744,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
2677
2744
|
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2678
2745
|
)
|
|
2679
2746
|
}, () => __async(this, null, function* () {
|
|
2680
|
-
yield
|
|
2747
|
+
yield fetchRemoteTypeUrlsPromise;
|
|
2681
2748
|
const emitTypesFilesPromise = emitTypesFiles(compilation);
|
|
2682
2749
|
if (isProd) {
|
|
2683
2750
|
yield emitTypesFilesPromise;
|
|
@@ -2701,8 +2768,8 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
2701
2768
|
generateAPITypes: true,
|
|
2702
2769
|
compileInChildProcess: true,
|
|
2703
2770
|
abortOnError: false,
|
|
2704
|
-
extractThirdParty:
|
|
2705
|
-
extractRemoteTypes:
|
|
2771
|
+
extractThirdParty: false,
|
|
2772
|
+
extractRemoteTypes: false
|
|
2706
2773
|
};
|
|
2707
2774
|
const defaultConsumeTypes = {
|
|
2708
2775
|
abortOnError: false,
|
|
@@ -2717,17 +2784,17 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
2717
2784
|
if (typeof normalizedDtsOptions !== "object") {
|
|
2718
2785
|
return;
|
|
2719
2786
|
}
|
|
2720
|
-
let
|
|
2721
|
-
const
|
|
2722
|
-
|
|
2787
|
+
let fetchRemoteTypeUrlsResolve;
|
|
2788
|
+
const fetchRemoteTypeUrlsPromise = new Promise((resolve5) => {
|
|
2789
|
+
fetchRemoteTypeUrlsResolve = resolve5;
|
|
2723
2790
|
});
|
|
2724
2791
|
let generateTypesPromiseResolve;
|
|
2725
2792
|
const generateTypesPromise = new Promise((resolve5) => {
|
|
2726
2793
|
generateTypesPromiseResolve = resolve5;
|
|
2727
2794
|
});
|
|
2728
|
-
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise).apply(compiler);
|
|
2729
|
-
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes,
|
|
2730
|
-
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes,
|
|
2795
|
+
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
|
|
2796
|
+
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
|
|
2797
|
+
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes, fetchRemoteTypeUrlsResolve).apply(compiler);
|
|
2731
2798
|
}
|
|
2732
2799
|
};
|
|
2733
2800
|
__name(_DtsPlugin, "DtsPlugin");
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/dts-plugin",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"log4js": "6.9.1",
|
|
61
61
|
"node-schedule": "2.1.1",
|
|
62
62
|
"ws": "8.18.0",
|
|
63
|
-
"@module-federation/sdk": "0.9.
|
|
64
|
-
"@module-federation/managers": "0.9.
|
|
65
|
-
"@module-federation/third-party-dts-extractor": "0.9.
|
|
66
|
-
"@module-federation/error-codes": "0.9.
|
|
63
|
+
"@module-federation/sdk": "0.9.1",
|
|
64
|
+
"@module-federation/managers": "0.9.1",
|
|
65
|
+
"@module-federation/third-party-dts-extractor": "0.9.1",
|
|
66
|
+
"@module-federation/error-codes": "0.9.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/ws": "8.5.12",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@vue/tsconfig": "^0.5.1",
|
|
74
74
|
"vue-tsc": "^2.0.26",
|
|
75
75
|
"rimraf": "~3.0.2",
|
|
76
|
-
"@module-federation/runtime": "0.9.
|
|
76
|
+
"@module-federation/runtime": "0.9.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"typescript": "^4.9.0 || ^5.0.0",
|