@module-federation/dts-plugin 0.8.12 → 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 +29 -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 +74 -21
- package/dist/esm/{chunk-2B3WPOMZ.js → chunk-LHN7ASHT.js} +1 -1
- package/dist/esm/{chunk-7XB7PFWZ.js → chunk-ZU4UW7EP.js} +74 -21
- 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 +74 -21
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +74 -21
- package/dist/index.js +127 -54
- package/dist/package.json +4 -3
- package/package.json +8 -7
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 35d925b: feat(dts-plugin): support remoteTypeUrls option which allow user to specify the remote types url
|
|
8
|
+
- 35d925b: fix(dts-plugin): support parse @scope@manifest-url.json entry
|
|
9
|
+
- 7a37360: fix(dts-plugin): consume api types if adding new one
|
|
10
|
+
- Updated dependencies [35d925b]
|
|
11
|
+
- Updated dependencies [35d925b]
|
|
12
|
+
- Updated dependencies [8acd217]
|
|
13
|
+
- @module-federation/sdk@0.9.1
|
|
14
|
+
- @module-federation/managers@0.9.1
|
|
15
|
+
- @module-federation/third-party-dts-extractor@0.9.1
|
|
16
|
+
- @module-federation/error-codes@0.9.1
|
|
17
|
+
|
|
18
|
+
## 0.9.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 5ebc53f: feat: enable tsc incremental build
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- d872b35: fix(dts-plugin): cache file should have name as its unique path
|
|
27
|
+
- @module-federation/sdk@0.9.0
|
|
28
|
+
- @module-federation/managers@0.9.0
|
|
29
|
+
- @module-federation/third-party-dts-extractor@0.9.0
|
|
30
|
+
- @module-federation/error-codes@0.9.0
|
|
31
|
+
|
|
3
32
|
## 0.8.12
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -41,7 +41,7 @@ declare class DTSManager {
|
|
|
41
41
|
generateTypes(): Promise<void>;
|
|
42
42
|
requestRemoteManifest(remoteInfo: RemoteInfo): Promise<Required<RemoteInfo>>;
|
|
43
43
|
consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string]>;
|
|
44
|
-
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<
|
|
44
|
+
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<boolean>;
|
|
45
45
|
consumeAPITypes(hostOptions: Required<HostOptions>): void;
|
|
46
46
|
consumeArchiveTypes(options: HostOptions): Promise<{
|
|
47
47
|
hostOptions: Required<HostOptions>;
|
package/dist/core.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DTSManager, T as TsConfigJson, 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-
|
|
2
|
-
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-
|
|
1
|
+
import { D as DTSManager, T as TsConfigJson, 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-edc3f145.js';
|
|
2
|
+
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-edc3f145.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
|
|
4
4
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
5
5
|
import { ChildProcess } from 'child_process';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DTSManager, T as TsConfigJson, 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-
|
|
2
|
-
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-
|
|
1
|
+
import { D as DTSManager, T as TsConfigJson, 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-edc3f145.js';
|
|
2
|
+
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-edc3f145.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
|
|
4
4
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
5
5
|
import { ChildProcess } from 'child_process';
|
package/dist/core.js
CHANGED
|
@@ -123,6 +123,7 @@ var import_ansi_colors = __toESM(require("ansi-colors"));
|
|
|
123
123
|
var import_path3 = __toESM(require("path"));
|
|
124
124
|
var import_promises3 = require("fs/promises");
|
|
125
125
|
var import_fs = __toESM(require("fs"));
|
|
126
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
126
127
|
var import_sdk5 = require("@module-federation/sdk");
|
|
127
128
|
var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
|
|
128
129
|
|
|
@@ -1203,7 +1204,8 @@ var defaultOptions = {
|
|
|
1203
1204
|
context: process.cwd(),
|
|
1204
1205
|
abortOnError: true,
|
|
1205
1206
|
consumeAPITypes: false,
|
|
1206
|
-
runtimePkgs: []
|
|
1207
|
+
runtimePkgs: [],
|
|
1208
|
+
remoteTypeUrls: {}
|
|
1207
1209
|
};
|
|
1208
1210
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1209
1211
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1219,18 +1221,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
1219
1221
|
}, "buildApiTypeUrl");
|
|
1220
1222
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
1221
1223
|
const { hostOptions, remoteAlias, remote } = options;
|
|
1224
|
+
const { remoteTypeUrls } = hostOptions;
|
|
1222
1225
|
let decodedRemote = remote;
|
|
1223
1226
|
if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
|
|
1224
1227
|
decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
|
|
1225
1228
|
}
|
|
1226
1229
|
const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
|
|
1227
1230
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
1228
|
-
|
|
1231
|
+
let zipUrl = "";
|
|
1232
|
+
let apiTypeUrl = "";
|
|
1233
|
+
const name = parsedInfo.name || remoteAlias;
|
|
1234
|
+
if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
|
|
1235
|
+
zipUrl = remoteTypeUrls[name].zip;
|
|
1236
|
+
apiTypeUrl = remoteTypeUrls[name].api;
|
|
1237
|
+
}
|
|
1238
|
+
if (!zipUrl && url) {
|
|
1239
|
+
zipUrl = buildZipUrl(hostOptions, url);
|
|
1240
|
+
}
|
|
1241
|
+
if (!apiTypeUrl && zipUrl) {
|
|
1242
|
+
apiTypeUrl = buildApiTypeUrl(zipUrl);
|
|
1243
|
+
}
|
|
1229
1244
|
return {
|
|
1230
|
-
name
|
|
1245
|
+
name,
|
|
1231
1246
|
url,
|
|
1232
1247
|
zipUrl,
|
|
1233
|
-
apiTypeUrl
|
|
1248
|
+
apiTypeUrl,
|
|
1234
1249
|
alias: remoteAlias
|
|
1235
1250
|
};
|
|
1236
1251
|
}, "retrieveRemoteInfo");
|
|
@@ -1306,6 +1321,7 @@ var DTSManager = (_a = class {
|
|
|
1306
1321
|
}
|
|
1307
1322
|
extractRemoteTypes(options) {
|
|
1308
1323
|
return __async(this, null, function* () {
|
|
1324
|
+
var _a3;
|
|
1309
1325
|
const { remoteOptions, tsConfig } = options;
|
|
1310
1326
|
if (!remoteOptions.extractRemoteTypes) {
|
|
1311
1327
|
return;
|
|
@@ -1320,20 +1336,29 @@ var DTSManager = (_a = class {
|
|
|
1320
1336
|
}
|
|
1321
1337
|
}
|
|
1322
1338
|
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1323
|
-
if (hasRemotes) {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1339
|
+
if (hasRemotes && this.options.host) {
|
|
1340
|
+
try {
|
|
1341
|
+
const { hostOptions } = retrieveHostConfig(this.options.host);
|
|
1342
|
+
const remoteTypesFolder = import_path3.default.resolve(hostOptions.context, hostOptions.typesFolder);
|
|
1343
|
+
const targetDir = import_path3.default.join(mfTypesPath, "node_modules");
|
|
1344
|
+
if (import_fs.default.existsSync(remoteTypesFolder)) {
|
|
1345
|
+
const targetFolder = import_path3.default.resolve(remoteOptions.context, targetDir);
|
|
1346
|
+
yield import_fs_extra3.default.ensureDir(targetFolder);
|
|
1347
|
+
yield import_fs_extra3.default.copy(remoteTypesFolder, targetFolder, {
|
|
1348
|
+
overwrite: true
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1353
|
+
fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
|
|
1354
|
+
} else {
|
|
1355
|
+
throw err;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1334
1358
|
}
|
|
1335
1359
|
});
|
|
1336
1360
|
}
|
|
1361
|
+
// it must execute after consumeTypes
|
|
1337
1362
|
generateTypes() {
|
|
1338
1363
|
return __async(this, null, function* () {
|
|
1339
1364
|
var _a3;
|
|
@@ -1346,6 +1371,18 @@ var DTSManager = (_a = class {
|
|
|
1346
1371
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1347
1372
|
return;
|
|
1348
1373
|
}
|
|
1374
|
+
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1375
|
+
try {
|
|
1376
|
+
const tsBuildInfoFile = import_path3.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
1377
|
+
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1378
|
+
if (!import_fs.default.existsSync(mfTypesPath)) {
|
|
1379
|
+
import_fs.default.rmSync(tsBuildInfoFile, {
|
|
1380
|
+
force: true
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
} catch (e) {
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1349
1386
|
yield this.extractRemoteTypes({
|
|
1350
1387
|
remoteOptions,
|
|
1351
1388
|
tsConfig,
|
|
@@ -1375,7 +1412,7 @@ var DTSManager = (_a = class {
|
|
|
1375
1412
|
} catch (error2) {
|
|
1376
1413
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1377
1414
|
if (this.options.displayErrorInTerminal) {
|
|
1378
|
-
logger.error(`Unable to compile federated types${error2}`);
|
|
1415
|
+
logger.error(`Unable to compile federated types ${error2}`);
|
|
1379
1416
|
}
|
|
1380
1417
|
} else {
|
|
1381
1418
|
throw error2;
|
|
@@ -1389,6 +1426,9 @@ var DTSManager = (_a = class {
|
|
|
1389
1426
|
if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
|
|
1390
1427
|
return remoteInfo;
|
|
1391
1428
|
}
|
|
1429
|
+
if (remoteInfo.zipUrl) {
|
|
1430
|
+
return remoteInfo;
|
|
1431
|
+
}
|
|
1392
1432
|
const url = remoteInfo.url;
|
|
1393
1433
|
const res = yield axiosGet(url);
|
|
1394
1434
|
const manifestJson = res.data;
|
|
@@ -1454,8 +1494,10 @@ var DTSManager = (_a = class {
|
|
|
1454
1494
|
apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
|
|
1455
1495
|
const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
|
|
1456
1496
|
import_fs.default.writeFileSync(filePath, apiTypeFile);
|
|
1497
|
+
const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
|
|
1457
1498
|
this.loadedRemoteAPIAlias.add(remoteInfo.alias);
|
|
1458
1499
|
fileLog(`success`, "downloadAPITypes", "info");
|
|
1500
|
+
return existed;
|
|
1459
1501
|
} catch (err) {
|
|
1460
1502
|
fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
|
|
1461
1503
|
}
|
|
@@ -1597,7 +1639,10 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1597
1639
|
// use remoteTarPath first
|
|
1598
1640
|
zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
|
|
1599
1641
|
}));
|
|
1600
|
-
yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1642
|
+
const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1643
|
+
if (addNew) {
|
|
1644
|
+
this.consumeAPITypes(hostOptions);
|
|
1645
|
+
}
|
|
1601
1646
|
fileLog(`consumeTypes end`, "updateTypes", "info");
|
|
1602
1647
|
}), "consumeTypes");
|
|
1603
1648
|
fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
|
|
@@ -1615,7 +1660,6 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1615
1660
|
} else if (updatedRemoteInfo) {
|
|
1616
1661
|
const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
|
|
1617
1662
|
yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
|
|
1618
|
-
this.consumeAPITypes(hostOptions);
|
|
1619
1663
|
}), "consumeDynamicRemoteTypes");
|
|
1620
1664
|
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
|
|
1621
1665
|
const parsedRemoteInfo = retrieveRemoteInfo({
|
|
@@ -1733,10 +1777,13 @@ function cloneDeepOptions(options) {
|
|
|
1733
1777
|
"manifest",
|
|
1734
1778
|
"async"
|
|
1735
1779
|
];
|
|
1736
|
-
return (0, import_lodash.default)(options, (
|
|
1780
|
+
return (0, import_lodash.default)(options, (value, key) => {
|
|
1737
1781
|
if (typeof key === "string" && excludeKeys.includes(key)) {
|
|
1738
1782
|
return false;
|
|
1739
1783
|
}
|
|
1784
|
+
if (typeof value === "function") {
|
|
1785
|
+
return false;
|
|
1786
|
+
}
|
|
1740
1787
|
});
|
|
1741
1788
|
}
|
|
1742
1789
|
__name(cloneDeepOptions, "cloneDeepOptions");
|
|
@@ -1798,7 +1845,7 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
1798
1845
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
1799
1846
|
}
|
|
1800
1847
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
1801
|
-
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
1848
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
|
|
1802
1849
|
const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
|
|
1803
1850
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
1804
1851
|
if (readResult.error) {
|
|
@@ -1816,7 +1863,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1816
1863
|
outDir
|
|
1817
1864
|
};
|
|
1818
1865
|
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
1819
|
-
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
|
|
1866
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
|
|
1867
|
+
incremental: true,
|
|
1868
|
+
tsBuildInfoFile: (0, import_path5.resolve)(context, "node_modules/.cache/mf-types/.tsbuildinfo")
|
|
1869
|
+
}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
1820
1870
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
1821
1871
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
1822
1872
|
const filesToCompile = [
|
|
@@ -1868,6 +1918,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
1868
1918
|
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
1869
1919
|
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
1870
1920
|
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
1921
|
+
if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
|
|
1922
|
+
remoteOptions.deleteTypesFolder = false;
|
|
1923
|
+
}
|
|
1871
1924
|
return {
|
|
1872
1925
|
tsConfig,
|
|
1873
1926
|
mapComponentsToExpose,
|
|
@@ -619,7 +619,7 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
619
619
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
620
620
|
}
|
|
621
621
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
622
|
-
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
622
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
|
|
623
623
|
const resolvedTsConfigPath = resolve2(context, tsConfigPath);
|
|
624
624
|
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
625
625
|
if (readResult.error) {
|
|
@@ -637,7 +637,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
637
637
|
outDir
|
|
638
638
|
};
|
|
639
639
|
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
640
|
-
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
|
|
640
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
|
|
641
|
+
incremental: true,
|
|
642
|
+
tsBuildInfoFile: resolve2(context, "node_modules/.cache/mf-types/.tsbuildinfo")
|
|
643
|
+
}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
641
644
|
const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
|
|
642
645
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
643
646
|
const filesToCompile = [
|
|
@@ -689,6 +692,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
689
692
|
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions), options);
|
|
690
693
|
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
691
694
|
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
695
|
+
if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
|
|
696
|
+
remoteOptions.deleteTypesFolder = false;
|
|
697
|
+
}
|
|
692
698
|
return {
|
|
693
699
|
tsConfig,
|
|
694
700
|
mapComponentsToExpose,
|
|
@@ -700,6 +706,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
700
706
|
import path2 from "path";
|
|
701
707
|
import { rm as rm2 } from "fs/promises";
|
|
702
708
|
import fs2 from "fs";
|
|
709
|
+
import fse from "fs-extra";
|
|
703
710
|
import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
|
|
704
711
|
import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/third-party-dts-extractor";
|
|
705
712
|
|
|
@@ -715,7 +722,8 @@ var defaultOptions2 = {
|
|
|
715
722
|
context: process.cwd(),
|
|
716
723
|
abortOnError: true,
|
|
717
724
|
consumeAPITypes: false,
|
|
718
|
-
runtimePkgs: []
|
|
725
|
+
runtimePkgs: [],
|
|
726
|
+
remoteTypeUrls: {}
|
|
719
727
|
};
|
|
720
728
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
721
729
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -731,18 +739,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
731
739
|
}, "buildApiTypeUrl");
|
|
732
740
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
733
741
|
const { hostOptions, remoteAlias, remote } = options;
|
|
742
|
+
const { remoteTypeUrls } = hostOptions;
|
|
734
743
|
let decodedRemote = remote;
|
|
735
744
|
if (decodedRemote.startsWith(ENCODE_NAME_PREFIX)) {
|
|
736
745
|
decodedRemote = decodeName(decodedRemote, ENCODE_NAME_PREFIX);
|
|
737
746
|
}
|
|
738
747
|
const parsedInfo = parseEntry(decodedRemote, void 0, "@");
|
|
739
748
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
740
|
-
|
|
749
|
+
let zipUrl = "";
|
|
750
|
+
let apiTypeUrl = "";
|
|
751
|
+
const name = parsedInfo.name || remoteAlias;
|
|
752
|
+
if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
|
|
753
|
+
zipUrl = remoteTypeUrls[name].zip;
|
|
754
|
+
apiTypeUrl = remoteTypeUrls[name].api;
|
|
755
|
+
}
|
|
756
|
+
if (!zipUrl && url) {
|
|
757
|
+
zipUrl = buildZipUrl(hostOptions, url);
|
|
758
|
+
}
|
|
759
|
+
if (!apiTypeUrl && zipUrl) {
|
|
760
|
+
apiTypeUrl = buildApiTypeUrl(zipUrl);
|
|
761
|
+
}
|
|
741
762
|
return {
|
|
742
|
-
name
|
|
763
|
+
name,
|
|
743
764
|
url,
|
|
744
765
|
zipUrl,
|
|
745
|
-
apiTypeUrl
|
|
766
|
+
apiTypeUrl,
|
|
746
767
|
alias: remoteAlias
|
|
747
768
|
};
|
|
748
769
|
}, "retrieveRemoteInfo");
|
|
@@ -818,6 +839,7 @@ var DTSManager = (_a = class {
|
|
|
818
839
|
}
|
|
819
840
|
extractRemoteTypes(options) {
|
|
820
841
|
return __async(this, null, function* () {
|
|
842
|
+
var _a2;
|
|
821
843
|
const { remoteOptions, tsConfig } = options;
|
|
822
844
|
if (!remoteOptions.extractRemoteTypes) {
|
|
823
845
|
return;
|
|
@@ -832,20 +854,29 @@ var DTSManager = (_a = class {
|
|
|
832
854
|
}
|
|
833
855
|
}
|
|
834
856
|
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
835
|
-
if (hasRemotes) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
857
|
+
if (hasRemotes && this.options.host) {
|
|
858
|
+
try {
|
|
859
|
+
const { hostOptions } = retrieveHostConfig(this.options.host);
|
|
860
|
+
const remoteTypesFolder = path2.resolve(hostOptions.context, hostOptions.typesFolder);
|
|
861
|
+
const targetDir = path2.join(mfTypesPath, "node_modules");
|
|
862
|
+
if (fs2.existsSync(remoteTypesFolder)) {
|
|
863
|
+
const targetFolder = path2.resolve(remoteOptions.context, targetDir);
|
|
864
|
+
yield fse.ensureDir(targetFolder);
|
|
865
|
+
yield fse.copy(remoteTypesFolder, targetFolder, {
|
|
866
|
+
overwrite: true
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
} catch (err) {
|
|
870
|
+
if (((_a2 = this.options.host) == null ? void 0 : _a2.abortOnError) === false) {
|
|
871
|
+
fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
|
|
872
|
+
} else {
|
|
873
|
+
throw err;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
846
876
|
}
|
|
847
877
|
});
|
|
848
878
|
}
|
|
879
|
+
// it must execute after consumeTypes
|
|
849
880
|
generateTypes() {
|
|
850
881
|
return __async(this, null, function* () {
|
|
851
882
|
var _a2;
|
|
@@ -858,6 +889,18 @@ var DTSManager = (_a = class {
|
|
|
858
889
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
859
890
|
return;
|
|
860
891
|
}
|
|
892
|
+
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
893
|
+
try {
|
|
894
|
+
const tsBuildInfoFile = path2.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
895
|
+
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
896
|
+
if (!fs2.existsSync(mfTypesPath)) {
|
|
897
|
+
fs2.rmSync(tsBuildInfoFile, {
|
|
898
|
+
force: true
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
} catch (e) {
|
|
902
|
+
}
|
|
903
|
+
}
|
|
861
904
|
yield this.extractRemoteTypes({
|
|
862
905
|
remoteOptions,
|
|
863
906
|
tsConfig,
|
|
@@ -887,7 +930,7 @@ var DTSManager = (_a = class {
|
|
|
887
930
|
} catch (error) {
|
|
888
931
|
if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
|
|
889
932
|
if (this.options.displayErrorInTerminal) {
|
|
890
|
-
logger.error(`Unable to compile federated types${error}`);
|
|
933
|
+
logger.error(`Unable to compile federated types ${error}`);
|
|
891
934
|
}
|
|
892
935
|
} else {
|
|
893
936
|
throw error;
|
|
@@ -901,6 +944,9 @@ var DTSManager = (_a = class {
|
|
|
901
944
|
if (!remoteInfo.url.includes(MANIFEST_EXT)) {
|
|
902
945
|
return remoteInfo;
|
|
903
946
|
}
|
|
947
|
+
if (remoteInfo.zipUrl) {
|
|
948
|
+
return remoteInfo;
|
|
949
|
+
}
|
|
904
950
|
const url = remoteInfo.url;
|
|
905
951
|
const res = yield axiosGet(url);
|
|
906
952
|
const manifestJson = res.data;
|
|
@@ -966,8 +1012,10 @@ var DTSManager = (_a = class {
|
|
|
966
1012
|
apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
|
|
967
1013
|
const filePath = path2.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
|
|
968
1014
|
fs2.writeFileSync(filePath, apiTypeFile);
|
|
1015
|
+
const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
|
|
969
1016
|
this.loadedRemoteAPIAlias.add(remoteInfo.alias);
|
|
970
1017
|
fileLog(`success`, "downloadAPITypes", "info");
|
|
1018
|
+
return existed;
|
|
971
1019
|
} catch (err) {
|
|
972
1020
|
fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
|
|
973
1021
|
}
|
|
@@ -1109,7 +1157,10 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1109
1157
|
// use remoteTarPath first
|
|
1110
1158
|
zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
|
|
1111
1159
|
}));
|
|
1112
|
-
yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1160
|
+
const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1161
|
+
if (addNew) {
|
|
1162
|
+
this.consumeAPITypes(hostOptions);
|
|
1163
|
+
}
|
|
1113
1164
|
fileLog(`consumeTypes end`, "updateTypes", "info");
|
|
1114
1165
|
}), "consumeTypes");
|
|
1115
1166
|
fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
|
|
@@ -1127,7 +1178,6 @@ hostName: ${hostName}`, "updateTypes", "info");
|
|
|
1127
1178
|
} else if (updatedRemoteInfo) {
|
|
1128
1179
|
const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
|
|
1129
1180
|
yield consumeTypes(this.updatedRemoteInfos[updatedRemoteInfo.name]);
|
|
1130
|
-
this.consumeAPITypes(hostOptions);
|
|
1131
1181
|
}), "consumeDynamicRemoteTypes");
|
|
1132
1182
|
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
|
|
1133
1183
|
const parsedRemoteInfo = retrieveRemoteInfo({
|
|
@@ -1245,10 +1295,13 @@ function cloneDeepOptions(options) {
|
|
|
1245
1295
|
"manifest",
|
|
1246
1296
|
"async"
|
|
1247
1297
|
];
|
|
1248
|
-
return cloneDeepWith(options, (
|
|
1298
|
+
return cloneDeepWith(options, (value, key) => {
|
|
1249
1299
|
if (typeof key === "string" && excludeKeys.includes(key)) {
|
|
1250
1300
|
return false;
|
|
1251
1301
|
}
|
|
1302
|
+
if (typeof value === "function") {
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1252
1305
|
});
|
|
1253
1306
|
}
|
|
1254
1307
|
__name(cloneDeepOptions, "cloneDeepOptions");
|
package/dist/esm/core.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
consumeTypes,
|
|
4
4
|
generateTypesInChildProcess,
|
|
5
5
|
rpc_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LHN7ASHT.js";
|
|
7
7
|
import {
|
|
8
8
|
DTSManager,
|
|
9
9
|
HOST_API_TYPES_FILE_NAME,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
retrieveTypesAssetsInfo,
|
|
20
20
|
retrieveTypesZipPath,
|
|
21
21
|
validateOptions
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZU4UW7EP.js";
|
|
23
23
|
import "./chunk-KCWHOFI6.js";
|
|
24
24
|
import "./chunk-4CSLH7II.js";
|
|
25
25
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rpc_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LHN7ASHT.js";
|
|
4
4
|
import {
|
|
5
5
|
ModuleFederationDevServer,
|
|
6
6
|
createKoaServer,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
retrieveMfTypesPath,
|
|
10
10
|
retrieveRemoteConfig,
|
|
11
11
|
retrieveTypesZipPath
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZU4UW7EP.js";
|
|
13
13
|
import {
|
|
14
14
|
fileLog,
|
|
15
15
|
getIPV4
|