@module-federation/dts-plugin 0.9.0 → 0.10.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/CHANGELOG.md +27 -0
- package/dist/{DtsWorker-484d9f4a.d.ts → DtsWorker-bfe21fe7.d.ts} +2 -2
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +85 -30
- package/dist/esm/{chunk-UK7YFESF.js → chunk-IPO3NMOQ.js} +1 -1
- package/dist/esm/{chunk-XXMD5NAZ.js → chunk-TKO3UU5B.js} +85 -30
- 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 +56 -30
- package/dist/fork-dev-worker.js +85 -30
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +85 -30
- package/dist/index.js +149 -68
- package/dist/package.json +1 -1
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
consumeTypes,
|
|
3
3
|
generateTypesInChildProcess,
|
|
4
4
|
rpc_exports
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-IPO3NMOQ.js";
|
|
6
6
|
import {
|
|
7
7
|
cloneDeepOptions,
|
|
8
8
|
generateTypes,
|
|
9
9
|
isTSProject,
|
|
10
10
|
retrieveTypesAssetsInfo,
|
|
11
11
|
validateOptions
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TKO3UU5B.js";
|
|
13
13
|
import {
|
|
14
14
|
getIPV4,
|
|
15
15
|
logger
|
|
@@ -126,15 +126,17 @@ function ensureTempDir(filePath) {
|
|
|
126
126
|
}
|
|
127
127
|
__name(ensureTempDir, "ensureTempDir");
|
|
128
128
|
var _DevPlugin = class _DevPlugin {
|
|
129
|
-
constructor(options, dtsOptions,
|
|
129
|
+
constructor(options, dtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise) {
|
|
130
130
|
__publicField(this, "name", "MFDevPlugin");
|
|
131
131
|
__publicField(this, "_options");
|
|
132
132
|
__publicField(this, "_devWorker");
|
|
133
133
|
__publicField(this, "dtsOptions");
|
|
134
|
-
__publicField(this, "
|
|
134
|
+
__publicField(this, "generateTypesPromise");
|
|
135
|
+
__publicField(this, "fetchRemoteTypeUrlsPromise");
|
|
135
136
|
this._options = options;
|
|
136
|
-
this.
|
|
137
|
+
this.generateTypesPromise = generateTypesPromise;
|
|
137
138
|
this.dtsOptions = dtsOptions;
|
|
139
|
+
this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
|
|
138
140
|
}
|
|
139
141
|
static ensureLiveReloadEntry(options, filePath) {
|
|
140
142
|
ensureTempDir(filePath);
|
|
@@ -252,11 +254,16 @@ var _DevPlugin = class _DevPlugin {
|
|
|
252
254
|
if (remote && !(remote == null ? void 0 : remote.tsConfigPath) && typeof normalizedDtsOptions === "object" && normalizedDtsOptions.tsConfigPath) {
|
|
253
255
|
remote.tsConfigPath = normalizedDtsOptions.tsConfigPath;
|
|
254
256
|
}
|
|
255
|
-
|
|
257
|
+
Promise.all([
|
|
258
|
+
this.generateTypesPromise,
|
|
259
|
+
this.fetchRemoteTypeUrlsPromise
|
|
260
|
+
]).then(([_, remoteTypeUrls]) => {
|
|
256
261
|
this._devWorker = createDevWorker({
|
|
257
262
|
name,
|
|
258
263
|
remote,
|
|
259
|
-
host,
|
|
264
|
+
host: __spreadProps(__spreadValues({}, host), {
|
|
265
|
+
remoteTypeUrls
|
|
266
|
+
}),
|
|
260
267
|
extraOptions,
|
|
261
268
|
disableLiveReload: normalizedDev.disableHotTypesReload,
|
|
262
269
|
disableHotTypesReload: normalizedDev.disableHotTypesReload
|
|
@@ -274,27 +281,29 @@ var DevPlugin = _DevPlugin;
|
|
|
274
281
|
import { normalizeOptions as normalizeOptions4 } from "@module-federation/sdk";
|
|
275
282
|
|
|
276
283
|
// packages/dts-plugin/src/plugins/ConsumeTypesPlugin.ts
|
|
284
|
+
import { logger as logger2 } from "@module-federation/sdk";
|
|
277
285
|
import { normalizeOptions as normalizeOptions2 } from "@module-federation/sdk";
|
|
278
286
|
var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
279
|
-
constructor(pluginOptions, dtsOptions, defaultOptions,
|
|
287
|
+
constructor(pluginOptions, dtsOptions, defaultOptions, fetchRemoteTypeUrlsResolve) {
|
|
280
288
|
__publicField(this, "pluginOptions");
|
|
281
289
|
__publicField(this, "dtsOptions");
|
|
282
290
|
__publicField(this, "defaultOptions");
|
|
283
291
|
__publicField(this, "callback");
|
|
292
|
+
__publicField(this, "fetchRemoteTypeUrlsResolve");
|
|
284
293
|
this.pluginOptions = pluginOptions;
|
|
285
294
|
this.dtsOptions = dtsOptions;
|
|
286
295
|
this.defaultOptions = defaultOptions;
|
|
287
|
-
this.
|
|
296
|
+
this.fetchRemoteTypeUrlsResolve = fetchRemoteTypeUrlsResolve;
|
|
288
297
|
}
|
|
289
298
|
apply(compiler) {
|
|
290
|
-
const { dtsOptions, defaultOptions, pluginOptions,
|
|
299
|
+
const { dtsOptions, defaultOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
291
300
|
if (isPrd()) {
|
|
292
|
-
|
|
301
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
293
302
|
return;
|
|
294
303
|
}
|
|
295
304
|
const normalizedConsumeTypes = normalizeOptions2(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
296
305
|
if (!normalizedConsumeTypes) {
|
|
297
|
-
|
|
306
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
298
307
|
return;
|
|
299
308
|
}
|
|
300
309
|
const finalOptions = {
|
|
@@ -307,10 +316,18 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
307
316
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
308
317
|
};
|
|
309
318
|
validateOptions(finalOptions.host);
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
319
|
+
const fetchRemoteTypeUrlsPromise = typeof normalizedConsumeTypes.remoteTypeUrls === "function" ? normalizedConsumeTypes.remoteTypeUrls() : Promise.resolve(normalizedConsumeTypes.remoteTypeUrls);
|
|
320
|
+
logger2.debug("start fetching remote types...");
|
|
321
|
+
const promise = fetchRemoteTypeUrlsPromise.then((remoteTypeUrls) => {
|
|
322
|
+
consumeTypes(__spreadProps(__spreadValues({}, finalOptions), {
|
|
323
|
+
host: __spreadProps(__spreadValues({}, finalOptions.host), {
|
|
324
|
+
remoteTypeUrls
|
|
325
|
+
})
|
|
326
|
+
})).then(() => {
|
|
327
|
+
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
328
|
+
}).catch(() => {
|
|
329
|
+
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
330
|
+
});
|
|
314
331
|
});
|
|
315
332
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
316
333
|
compilation.hooks.processAssets.tapPromise({
|
|
@@ -321,6 +338,7 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
321
338
|
)
|
|
322
339
|
}, () => __async(this, null, function* () {
|
|
323
340
|
yield promise;
|
|
341
|
+
logger2.debug("fetch remote types success!");
|
|
324
342
|
}));
|
|
325
343
|
});
|
|
326
344
|
}
|
|
@@ -331,27 +349,28 @@ var ConsumeTypesPlugin = _ConsumeTypesPlugin;
|
|
|
331
349
|
// packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
|
|
332
350
|
import fs2 from "fs";
|
|
333
351
|
import path5 from "path";
|
|
334
|
-
import { normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
|
|
352
|
+
import { logger as logger3, normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
|
|
335
353
|
var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
336
|
-
constructor(pluginOptions, dtsOptions, defaultOptions,
|
|
354
|
+
constructor(pluginOptions, dtsOptions, defaultOptions, fetchRemoteTypeUrlsPromise, callback) {
|
|
337
355
|
__publicField(this, "pluginOptions");
|
|
338
356
|
__publicField(this, "dtsOptions");
|
|
339
357
|
__publicField(this, "defaultOptions");
|
|
340
|
-
__publicField(this, "
|
|
358
|
+
__publicField(this, "fetchRemoteTypeUrlsPromise");
|
|
341
359
|
__publicField(this, "callback");
|
|
342
360
|
this.pluginOptions = pluginOptions;
|
|
343
361
|
this.dtsOptions = dtsOptions;
|
|
344
362
|
this.defaultOptions = defaultOptions;
|
|
345
|
-
this.
|
|
363
|
+
this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
|
|
346
364
|
this.callback = callback;
|
|
347
365
|
}
|
|
348
366
|
apply(compiler) {
|
|
349
|
-
const { dtsOptions, defaultOptions, pluginOptions,
|
|
367
|
+
const { dtsOptions, defaultOptions, pluginOptions, fetchRemoteTypeUrlsPromise, callback } = this;
|
|
350
368
|
const normalizedGenerateTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
|
|
351
369
|
if (!normalizedGenerateTypes) {
|
|
352
370
|
callback();
|
|
353
371
|
return;
|
|
354
372
|
}
|
|
373
|
+
const normalizedConsumeTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
355
374
|
const finalOptions = {
|
|
356
375
|
remote: __spreadValues({
|
|
357
376
|
implementation: dtsOptions.implementation,
|
|
@@ -359,6 +378,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
359
378
|
outputDir: getCompilerOutputDir(compiler),
|
|
360
379
|
moduleFederationConfig: pluginOptions
|
|
361
380
|
}, normalizedGenerateTypes),
|
|
381
|
+
host: normalizedConsumeTypes === false ? void 0 : __spreadValues({
|
|
382
|
+
context: compiler.context,
|
|
383
|
+
moduleFederationConfig: pluginOptions
|
|
384
|
+
}, normalizedGenerateTypes),
|
|
362
385
|
extraOptions: dtsOptions.extraOptions || {},
|
|
363
386
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
364
387
|
};
|
|
@@ -387,7 +410,9 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
387
410
|
callback();
|
|
388
411
|
return;
|
|
389
412
|
}
|
|
413
|
+
logger3.debug("start generating types...");
|
|
390
414
|
yield generateTypesFn(finalOptions);
|
|
415
|
+
logger3.debug("generate types success!");
|
|
391
416
|
const config = finalOptions.remote.moduleFederationConfig;
|
|
392
417
|
let zipPrefix = "";
|
|
393
418
|
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
@@ -456,6 +481,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
456
481
|
if (finalOptions.displayErrorInTerminal) {
|
|
457
482
|
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
458
483
|
}
|
|
484
|
+
logger3.debug("generate types fail!");
|
|
459
485
|
}
|
|
460
486
|
}), "emitTypesFiles");
|
|
461
487
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
@@ -466,7 +492,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
466
492
|
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
467
493
|
)
|
|
468
494
|
}, () => __async(this, null, function* () {
|
|
469
|
-
yield
|
|
495
|
+
yield fetchRemoteTypeUrlsPromise;
|
|
470
496
|
const emitTypesFilesPromise = emitTypesFiles(compilation);
|
|
471
497
|
if (isProd) {
|
|
472
498
|
yield emitTypesFilesPromise;
|
|
@@ -490,8 +516,8 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
490
516
|
generateAPITypes: true,
|
|
491
517
|
compileInChildProcess: true,
|
|
492
518
|
abortOnError: false,
|
|
493
|
-
extractThirdParty:
|
|
494
|
-
extractRemoteTypes:
|
|
519
|
+
extractThirdParty: false,
|
|
520
|
+
extractRemoteTypes: false
|
|
495
521
|
};
|
|
496
522
|
const defaultConsumeTypes = {
|
|
497
523
|
abortOnError: false,
|
|
@@ -506,17 +532,17 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
506
532
|
if (typeof normalizedDtsOptions !== "object") {
|
|
507
533
|
return;
|
|
508
534
|
}
|
|
509
|
-
let
|
|
510
|
-
const
|
|
511
|
-
|
|
535
|
+
let fetchRemoteTypeUrlsResolve;
|
|
536
|
+
const fetchRemoteTypeUrlsPromise = new Promise((resolve2) => {
|
|
537
|
+
fetchRemoteTypeUrlsResolve = resolve2;
|
|
512
538
|
});
|
|
513
539
|
let generateTypesPromiseResolve;
|
|
514
540
|
const generateTypesPromise = new Promise((resolve2) => {
|
|
515
541
|
generateTypesPromiseResolve = resolve2;
|
|
516
542
|
});
|
|
517
|
-
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise).apply(compiler);
|
|
518
|
-
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes,
|
|
519
|
-
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes,
|
|
543
|
+
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
|
|
544
|
+
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
|
|
545
|
+
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes, fetchRemoteTypeUrlsResolve).apply(compiler);
|
|
520
546
|
}
|
|
521
547
|
};
|
|
522
548
|
__name(_DtsPlugin, "DtsPlugin");
|
package/dist/fork-dev-worker.js
CHANGED
|
@@ -104,6 +104,7 @@ var import_ansi_colors = __toESM(require("ansi-colors"));
|
|
|
104
104
|
var import_path4 = __toESM(require("path"));
|
|
105
105
|
var import_promises3 = require("fs/promises");
|
|
106
106
|
var import_fs = __toESM(require("fs"));
|
|
107
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
107
108
|
var import_sdk5 = require("@module-federation/sdk");
|
|
108
109
|
var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
|
|
109
110
|
|
|
@@ -1676,7 +1677,8 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1676
1677
|
try {
|
|
1677
1678
|
const url = fileToDownload;
|
|
1678
1679
|
const response = yield axiosGet(url, {
|
|
1679
|
-
responseType: "arraybuffer"
|
|
1680
|
+
responseType: "arraybuffer",
|
|
1681
|
+
timeout: hostOptions.timeout
|
|
1680
1682
|
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1681
1683
|
if (typeof ((_a3 = response.headers) == null ? void 0 : _a3["content-type"]) === "string" && response.headers["content-type"].includes("text/html")) {
|
|
1682
1684
|
throw new Error(`${url} receives invalid content-type: ${response.headers["content-type"]}`);
|
|
@@ -1723,7 +1725,9 @@ var defaultOptions = {
|
|
|
1723
1725
|
context: process.cwd(),
|
|
1724
1726
|
abortOnError: true,
|
|
1725
1727
|
consumeAPITypes: false,
|
|
1726
|
-
runtimePkgs: []
|
|
1728
|
+
runtimePkgs: [],
|
|
1729
|
+
remoteTypeUrls: {},
|
|
1730
|
+
timeout: 6e4
|
|
1727
1731
|
};
|
|
1728
1732
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1729
1733
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1739,18 +1743,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
1739
1743
|
}, "buildApiTypeUrl");
|
|
1740
1744
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
1741
1745
|
const { hostOptions, remoteAlias, remote } = options;
|
|
1746
|
+
const { remoteTypeUrls } = hostOptions;
|
|
1742
1747
|
let decodedRemote = remote;
|
|
1743
1748
|
if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
|
|
1744
1749
|
decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
|
|
1745
1750
|
}
|
|
1746
1751
|
const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
|
|
1747
1752
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
1748
|
-
|
|
1753
|
+
let zipUrl = "";
|
|
1754
|
+
let apiTypeUrl = "";
|
|
1755
|
+
const name = parsedInfo.name || remoteAlias;
|
|
1756
|
+
if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
|
|
1757
|
+
zipUrl = remoteTypeUrls[name].zip;
|
|
1758
|
+
apiTypeUrl = remoteTypeUrls[name].api;
|
|
1759
|
+
}
|
|
1760
|
+
if (!zipUrl && url) {
|
|
1761
|
+
zipUrl = buildZipUrl(hostOptions, url);
|
|
1762
|
+
}
|
|
1763
|
+
if (!apiTypeUrl && zipUrl) {
|
|
1764
|
+
apiTypeUrl = buildApiTypeUrl(zipUrl);
|
|
1765
|
+
}
|
|
1749
1766
|
return {
|
|
1750
|
-
name
|
|
1767
|
+
name,
|
|
1751
1768
|
url,
|
|
1752
1769
|
zipUrl,
|
|
1753
|
-
apiTypeUrl
|
|
1770
|
+
apiTypeUrl,
|
|
1754
1771
|
alias: remoteAlias
|
|
1755
1772
|
};
|
|
1756
1773
|
}, "retrieveRemoteInfo");
|
|
@@ -1826,6 +1843,7 @@ var DTSManager = (_a = class {
|
|
|
1826
1843
|
}
|
|
1827
1844
|
extractRemoteTypes(options) {
|
|
1828
1845
|
return __async(this, null, function* () {
|
|
1846
|
+
var _a3;
|
|
1829
1847
|
const { remoteOptions, tsConfig } = options;
|
|
1830
1848
|
if (!remoteOptions.extractRemoteTypes) {
|
|
1831
1849
|
return;
|
|
@@ -1840,20 +1858,29 @@ var DTSManager = (_a = class {
|
|
|
1840
1858
|
}
|
|
1841
1859
|
}
|
|
1842
1860
|
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1843
|
-
if (hasRemotes) {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1861
|
+
if (hasRemotes && this.options.host) {
|
|
1862
|
+
try {
|
|
1863
|
+
const { hostOptions } = retrieveHostConfig(this.options.host);
|
|
1864
|
+
const remoteTypesFolder = import_path4.default.resolve(hostOptions.context, hostOptions.typesFolder);
|
|
1865
|
+
const targetDir = import_path4.default.join(mfTypesPath, "node_modules");
|
|
1866
|
+
if (import_fs.default.existsSync(remoteTypesFolder)) {
|
|
1867
|
+
const targetFolder = import_path4.default.resolve(remoteOptions.context, targetDir);
|
|
1868
|
+
yield import_fs_extra3.default.ensureDir(targetFolder);
|
|
1869
|
+
yield import_fs_extra3.default.copy(remoteTypesFolder, targetFolder, {
|
|
1870
|
+
overwrite: true
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
} catch (err) {
|
|
1874
|
+
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1875
|
+
fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
|
|
1876
|
+
} else {
|
|
1877
|
+
throw err;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1854
1880
|
}
|
|
1855
1881
|
});
|
|
1856
1882
|
}
|
|
1883
|
+
// it must execute after consumeTypes
|
|
1857
1884
|
generateTypes() {
|
|
1858
1885
|
return __async(this, null, function* () {
|
|
1859
1886
|
var _a3;
|
|
@@ -1866,6 +1893,18 @@ var DTSManager = (_a = class {
|
|
|
1866
1893
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1867
1894
|
return;
|
|
1868
1895
|
}
|
|
1896
|
+
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1897
|
+
try {
|
|
1898
|
+
const tsBuildInfoFile = import_path4.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
1899
|
+
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1900
|
+
if (!import_fs.default.existsSync(mfTypesPath)) {
|
|
1901
|
+
import_fs.default.rmSync(tsBuildInfoFile, {
|
|
1902
|
+
force: true
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
} catch (e) {
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1869
1908
|
yield this.extractRemoteTypes({
|
|
1870
1909
|
remoteOptions,
|
|
1871
1910
|
tsConfig,
|
|
@@ -1895,7 +1934,7 @@ var DTSManager = (_a = class {
|
|
|
1895
1934
|
} catch (error2) {
|
|
1896
1935
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1897
1936
|
if (this.options.displayErrorInTerminal) {
|
|
1898
|
-
logger.error(`Unable to compile federated types${error2}`);
|
|
1937
|
+
logger.error(`Unable to compile federated types ${error2}`);
|
|
1899
1938
|
}
|
|
1900
1939
|
} else {
|
|
1901
1940
|
throw error2;
|
|
@@ -1903,14 +1942,19 @@ var DTSManager = (_a = class {
|
|
|
1903
1942
|
}
|
|
1904
1943
|
});
|
|
1905
1944
|
}
|
|
1906
|
-
requestRemoteManifest(remoteInfo) {
|
|
1945
|
+
requestRemoteManifest(remoteInfo, hostOptions) {
|
|
1907
1946
|
return __async(this, null, function* () {
|
|
1908
1947
|
try {
|
|
1909
1948
|
if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
|
|
1910
1949
|
return remoteInfo;
|
|
1911
1950
|
}
|
|
1951
|
+
if (remoteInfo.zipUrl) {
|
|
1952
|
+
return remoteInfo;
|
|
1953
|
+
}
|
|
1912
1954
|
const url = remoteInfo.url;
|
|
1913
|
-
const res = yield axiosGet(url
|
|
1955
|
+
const res = yield axiosGet(url, {
|
|
1956
|
+
timeout: hostOptions.timeout
|
|
1957
|
+
});
|
|
1914
1958
|
const manifestJson = res.data;
|
|
1915
1959
|
if (!manifestJson.metaData.types.zip) {
|
|
1916
1960
|
throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
|
|
@@ -1961,7 +2005,7 @@ var DTSManager = (_a = class {
|
|
|
1961
2005
|
]);
|
|
1962
2006
|
});
|
|
1963
2007
|
}
|
|
1964
|
-
downloadAPITypes(remoteInfo, destinationPath) {
|
|
2008
|
+
downloadAPITypes(remoteInfo, destinationPath, hostOptions) {
|
|
1965
2009
|
return __async(this, null, function* () {
|
|
1966
2010
|
const { apiTypeUrl } = remoteInfo;
|
|
1967
2011
|
if (!apiTypeUrl) {
|
|
@@ -1969,13 +2013,17 @@ var DTSManager = (_a = class {
|
|
|
1969
2013
|
}
|
|
1970
2014
|
try {
|
|
1971
2015
|
const url = apiTypeUrl;
|
|
1972
|
-
const res = yield axiosGet(url
|
|
2016
|
+
const res = yield axiosGet(url, {
|
|
2017
|
+
timeout: hostOptions.timeout
|
|
2018
|
+
});
|
|
1973
2019
|
let apiTypeFile = res.data;
|
|
1974
2020
|
apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
|
|
1975
2021
|
const filePath = import_path4.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
|
|
1976
2022
|
import_fs.default.writeFileSync(filePath, apiTypeFile);
|
|
2023
|
+
const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
|
|
1977
2024
|
this.loadedRemoteAPIAlias.add(remoteInfo.alias);
|
|
1978
2025
|
fileLog(`success`, "downloadAPITypes", "info");
|
|
2026
|
+
return existed;
|
|
1979
2027
|
} catch (err) {
|
|
1980
2028
|
fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
|
|
1981
2029
|
}
|
|
@@ -2039,7 +2087,7 @@ var DTSManager = (_a = class {
|
|
|
2039
2087
|
const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
|
|
2040
2088
|
const remoteInfo = item[1];
|
|
2041
2089
|
if (!this.remoteAliasMap[remoteInfo.alias]) {
|
|
2042
|
-
const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo);
|
|
2090
|
+
const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo, hostOptions);
|
|
2043
2091
|
this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
|
|
2044
2092
|
}
|
|
2045
2093
|
return this.consumeTargetRemotes(hostOptions, this.remoteAliasMap[remoteInfo.alias]);
|
|
@@ -2074,7 +2122,7 @@ var DTSManager = (_a = class {
|
|
|
2074
2122
|
if (!remoteInfo) {
|
|
2075
2123
|
return;
|
|
2076
2124
|
}
|
|
2077
|
-
yield this.downloadAPITypes(remoteInfo, destinationPath);
|
|
2125
|
+
yield this.downloadAPITypes(remoteInfo, destinationPath, hostOptions);
|
|
2078
2126
|
})));
|
|
2079
2127
|
this.consumeAPITypes(hostOptions);
|
|
2080
2128
|
}
|
|
@@ -2117,7 +2165,10 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
2117
2165
|
// use remoteTarPath first
|
|
2118
2166
|
zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
|
|
2119
2167
|
}));
|
|
2120
|
-
yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
2168
|
+
const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath, hostOptions);
|
|
2169
|
+
if (addNew) {
|
|
2170
|
+
this.consumeAPITypes(hostOptions);
|
|
2171
|
+
}
|
|
2121
2172
|
fileLog(`consumeTypes end`, "updateTypes", "info");
|
|
2122
2173
|
}), "consumeTypes");
|
|
2123
2174
|
fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
|
|
@@ -2128,14 +2179,13 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
2128
2179
|
fileLog(`remoteInfo: ${JSON.stringify(remoteInfo, null, 2)}`, "updateTypes", "info");
|
|
2129
2180
|
if (remoteInfo) {
|
|
2130
2181
|
if (!this.remoteAliasMap[remoteInfo.alias]) {
|
|
2131
|
-
const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo);
|
|
2182
|
+
const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo, hostOptions);
|
|
2132
2183
|
this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
|
|
2133
2184
|
}
|
|
2134
2185
|
yield consumeTypes2(this.remoteAliasMap[remoteInfo.alias]);
|
|
2135
2186
|
} else if (updatedRemoteInfo) {
|
|
2136
2187
|
const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
|
|
2137
2188
|
yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
|
|
2138
|
-
this.consumeAPITypes(hostOptions);
|
|
2139
2189
|
}), "consumeDynamicRemoteTypes");
|
|
2140
2190
|
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
|
|
2141
2191
|
const parsedRemoteInfo = retrieveRemoteInfo({
|
|
@@ -2144,7 +2194,7 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
2144
2194
|
remote: updatedRemoteInfo.url
|
|
2145
2195
|
});
|
|
2146
2196
|
fileLog(`start request manifest`, "consumeTypes", "info");
|
|
2147
|
-
this.updatedRemoteInfos[updatedRemoteInfo.name] = yield this.requestRemoteManifest(parsedRemoteInfo);
|
|
2197
|
+
this.updatedRemoteInfos[updatedRemoteInfo.name] = yield this.requestRemoteManifest(parsedRemoteInfo, hostOptions);
|
|
2148
2198
|
fileLog(`end request manifest, this.updatedRemoteInfos[updatedRemoteInfo.name]: ${JSON.stringify(this.updatedRemoteInfos[updatedRemoteInfo.name], null, 2)}`, "updateTypes", "info");
|
|
2149
2199
|
yield consumeDynamicRemoteTypes();
|
|
2150
2200
|
}
|
|
@@ -2187,10 +2237,13 @@ function cloneDeepOptions(options) {
|
|
|
2187
2237
|
"manifest",
|
|
2188
2238
|
"async"
|
|
2189
2239
|
];
|
|
2190
|
-
return (0, import_lodash.default)(options, (
|
|
2240
|
+
return (0, import_lodash.default)(options, (value, key) => {
|
|
2191
2241
|
if (typeof key === "string" && excludeKeys.includes(key)) {
|
|
2192
2242
|
return false;
|
|
2193
2243
|
}
|
|
2244
|
+
if (typeof value === "function") {
|
|
2245
|
+
return false;
|
|
2246
|
+
}
|
|
2194
2247
|
});
|
|
2195
2248
|
}
|
|
2196
2249
|
__name(cloneDeepOptions, "cloneDeepOptions");
|
|
@@ -2206,12 +2259,14 @@ function axiosGet(url, config) {
|
|
|
2206
2259
|
const httpsAgent = new import_https.default.Agent({
|
|
2207
2260
|
family: 4
|
|
2208
2261
|
});
|
|
2209
|
-
return import_axios.default.get(url, __spreadValues(__spreadValues({
|
|
2262
|
+
return import_axios.default.get(url, __spreadProps(__spreadValues(__spreadValues({
|
|
2210
2263
|
httpAgent,
|
|
2211
2264
|
httpsAgent
|
|
2212
2265
|
}, {
|
|
2213
2266
|
headers: getEnvHeaders()
|
|
2214
|
-
}), config)
|
|
2267
|
+
}), config), {
|
|
2268
|
+
timeout: (config == null ? void 0 : config.timeout) || 6e4
|
|
2269
|
+
}));
|
|
2215
2270
|
});
|
|
2216
2271
|
}
|
|
2217
2272
|
__name(axiosGet, "axiosGet");
|