@module-federation/dts-plugin 0.14.3 → 0.16.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 +25 -0
- package/dist/core.js +16 -7
- package/dist/esm/{chunk-N3QR25YA.js → chunk-4XXQY6FQ.js} +1 -1
- package/dist/esm/{chunk-FTPSFGB4.js → chunk-NLANHIXS.js} +16 -7
- 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 +29 -11
- package/dist/fork-dev-worker.js +15 -6
- package/dist/fork-generate-dts.js +15 -6
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -16
- package/dist/package.json +1 -1
- package/package.json +6 -6
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1485fcf: added flag to fetch types from remote when building in production.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [1485fcf]
|
|
12
|
+
- @module-federation/sdk@0.16.0
|
|
13
|
+
- @module-federation/managers@0.16.0
|
|
14
|
+
- @module-federation/third-party-dts-extractor@0.16.0
|
|
15
|
+
- @module-federation/error-codes@0.16.0
|
|
16
|
+
|
|
17
|
+
## 0.15.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- c343589: fix(dts-plugin): only inject ipv4 str in dev mode
|
|
22
|
+
- b5e1640: chore(dts-plugin): check types archive url and optimize the error msg
|
|
23
|
+
- @module-federation/sdk@0.15.0
|
|
24
|
+
- @module-federation/managers@0.15.0
|
|
25
|
+
- @module-federation/third-party-dts-extractor@0.15.0
|
|
26
|
+
- @module-federation/error-codes@0.15.0
|
|
27
|
+
|
|
3
28
|
## 0.14.3
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/core.js
CHANGED
|
@@ -1165,7 +1165,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1165
1165
|
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1166
1166
|
while (retries++ < hostOptions.maxRetries) {
|
|
1167
1167
|
try {
|
|
1168
|
-
const url = fileToDownload;
|
|
1168
|
+
const url = new URL(fileToDownload).href;
|
|
1169
1169
|
const response = yield axiosGet(url, {
|
|
1170
1170
|
responseType: "arraybuffer",
|
|
1171
1171
|
timeout: hostOptions.timeout
|
|
@@ -1193,7 +1193,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1193
1193
|
} catch (error2) {
|
|
1194
1194
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1195
1195
|
if (retries >= hostOptions.maxRetries) {
|
|
1196
|
-
logger.error(`Failed to download ${fileToDownload}
|
|
1196
|
+
logger.error(`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`);
|
|
1197
1197
|
if (hostOptions.abortOnError !== false) {
|
|
1198
1198
|
throw error2;
|
|
1199
1199
|
}
|
|
@@ -1218,7 +1218,8 @@ var defaultOptions = {
|
|
|
1218
1218
|
consumeAPITypes: false,
|
|
1219
1219
|
runtimePkgs: [],
|
|
1220
1220
|
remoteTypeUrls: {},
|
|
1221
|
-
timeout: 6e4
|
|
1221
|
+
timeout: 6e4,
|
|
1222
|
+
typesOnBuild: false
|
|
1222
1223
|
};
|
|
1223
1224
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1224
1225
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1398,7 +1399,7 @@ var DTSManager = (_a = class {
|
|
|
1398
1399
|
// it must execute after consumeTypes
|
|
1399
1400
|
generateTypes() {
|
|
1400
1401
|
return __async(this, null, function* () {
|
|
1401
|
-
var _a3;
|
|
1402
|
+
var _a3, _b;
|
|
1402
1403
|
try {
|
|
1403
1404
|
const { options } = this;
|
|
1404
1405
|
if (!options.remote) {
|
|
@@ -1408,6 +1409,10 @@ var DTSManager = (_a = class {
|
|
|
1408
1409
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1409
1410
|
return;
|
|
1410
1411
|
}
|
|
1412
|
+
if (!((_a3 = tsConfig.files) == null ? void 0 : _a3.length)) {
|
|
1413
|
+
logger.info("No type files to compile, skip");
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1411
1416
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1412
1417
|
try {
|
|
1413
1418
|
const tsBuildInfoFile = import_path3.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -1447,7 +1452,7 @@ var DTSManager = (_a = class {
|
|
|
1447
1452
|
}
|
|
1448
1453
|
logger.success("Federated types created correctly");
|
|
1449
1454
|
} catch (error2) {
|
|
1450
|
-
if (((
|
|
1455
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
1451
1456
|
if (this.options.displayErrorInTerminal) {
|
|
1452
1457
|
logger.error(error2);
|
|
1453
1458
|
}
|
|
@@ -1752,7 +1757,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1752
1757
|
let zipPrefix = "";
|
|
1753
1758
|
try {
|
|
1754
1759
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1755
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1760
|
+
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1756
1761
|
return {
|
|
1757
1762
|
zipPrefix,
|
|
1758
1763
|
apiTypesPath,
|
|
@@ -1920,11 +1925,15 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1920
1925
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
1921
1926
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
1922
1927
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
1928
|
+
const excludeExtensions = [
|
|
1929
|
+
".mdx",
|
|
1930
|
+
".md"
|
|
1931
|
+
];
|
|
1923
1932
|
const filesToCompile = [
|
|
1924
1933
|
...Object.values(mapComponentsToExpose),
|
|
1925
1934
|
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
1926
1935
|
...additionalFilesToCompile
|
|
1927
|
-
];
|
|
1936
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
1928
1937
|
rawTsConfigJson.include = [];
|
|
1929
1938
|
rawTsConfigJson.files = filesToCompile;
|
|
1930
1939
|
rawTsConfigJson.exclude = [];
|
|
@@ -654,11 +654,15 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
654
654
|
const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
|
|
655
655
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
656
656
|
const outDirWithoutTypesFolder = resolve2(context, outputDir || configContent.options.outDir || "dist");
|
|
657
|
+
const excludeExtensions = [
|
|
658
|
+
".mdx",
|
|
659
|
+
".md"
|
|
660
|
+
];
|
|
657
661
|
const filesToCompile = [
|
|
658
662
|
...Object.values(mapComponentsToExpose),
|
|
659
663
|
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
660
664
|
...additionalFilesToCompile
|
|
661
|
-
];
|
|
665
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
662
666
|
rawTsConfigJson.include = [];
|
|
663
667
|
rawTsConfigJson.files = filesToCompile;
|
|
664
668
|
rawTsConfigJson.exclude = [];
|
|
@@ -735,7 +739,8 @@ var defaultOptions2 = {
|
|
|
735
739
|
consumeAPITypes: false,
|
|
736
740
|
runtimePkgs: [],
|
|
737
741
|
remoteTypeUrls: {},
|
|
738
|
-
timeout: 6e4
|
|
742
|
+
timeout: 6e4,
|
|
743
|
+
typesOnBuild: false
|
|
739
744
|
};
|
|
740
745
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
741
746
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -915,7 +920,7 @@ var DTSManager = (_a = class {
|
|
|
915
920
|
// it must execute after consumeTypes
|
|
916
921
|
generateTypes() {
|
|
917
922
|
return __async(this, null, function* () {
|
|
918
|
-
var _a2;
|
|
923
|
+
var _a2, _b;
|
|
919
924
|
try {
|
|
920
925
|
const { options } = this;
|
|
921
926
|
if (!options.remote) {
|
|
@@ -925,6 +930,10 @@ var DTSManager = (_a = class {
|
|
|
925
930
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
926
931
|
return;
|
|
927
932
|
}
|
|
933
|
+
if (!((_a2 = tsConfig.files) == null ? void 0 : _a2.length)) {
|
|
934
|
+
logger.info("No type files to compile, skip");
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
928
937
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
929
938
|
try {
|
|
930
939
|
const tsBuildInfoFile = path2.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -964,7 +973,7 @@ var DTSManager = (_a = class {
|
|
|
964
973
|
}
|
|
965
974
|
logger.success("Federated types created correctly");
|
|
966
975
|
} catch (error) {
|
|
967
|
-
if (((
|
|
976
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
968
977
|
if (this.options.displayErrorInTerminal) {
|
|
969
978
|
logger.error(error);
|
|
970
979
|
}
|
|
@@ -1269,7 +1278,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1269
1278
|
let zipPrefix = "";
|
|
1270
1279
|
try {
|
|
1271
1280
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1272
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1281
|
+
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1273
1282
|
return {
|
|
1274
1283
|
zipPrefix,
|
|
1275
1284
|
apiTypesPath,
|
|
@@ -1399,7 +1408,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1399
1408
|
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1400
1409
|
while (retries++ < hostOptions.maxRetries) {
|
|
1401
1410
|
try {
|
|
1402
|
-
const url = fileToDownload;
|
|
1411
|
+
const url = new URL(fileToDownload).href;
|
|
1403
1412
|
const response = yield axiosGet(url, {
|
|
1404
1413
|
responseType: "arraybuffer",
|
|
1405
1414
|
timeout: hostOptions.timeout
|
|
@@ -1427,7 +1436,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1427
1436
|
} catch (error) {
|
|
1428
1437
|
fileLog(`Error during types archive download: ${(error == null ? void 0 : error.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1429
1438
|
if (retries >= hostOptions.maxRetries) {
|
|
1430
|
-
logger.error(`Failed to download ${fileToDownload}
|
|
1439
|
+
logger.error(`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`);
|
|
1431
1440
|
if (hostOptions.abortOnError !== false) {
|
|
1432
1441
|
throw error;
|
|
1433
1442
|
}
|
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-4XXQY6FQ.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-NLANHIXS.js";
|
|
23
23
|
import "./chunk-WWV5RWOP.js";
|
|
24
24
|
import "./chunk-647HGGGS.js";
|
|
25
25
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rpc_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4XXQY6FQ.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-NLANHIXS.js";
|
|
13
13
|
import {
|
|
14
14
|
fileLog,
|
|
15
15
|
getIPV4
|
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-4XXQY6FQ.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-NLANHIXS.js";
|
|
13
13
|
import {
|
|
14
14
|
getIPV4,
|
|
15
15
|
logger
|
|
@@ -178,9 +178,6 @@ var _DevPlugin = class _DevPlugin {
|
|
|
178
178
|
apply(compiler) {
|
|
179
179
|
var _a;
|
|
180
180
|
const { _options: { name, dev, dts } } = this;
|
|
181
|
-
new compiler.webpack.DefinePlugin({
|
|
182
|
-
FEDERATION_IPV4: JSON.stringify(getIPV4())
|
|
183
|
-
}).apply(compiler);
|
|
184
181
|
const normalizedDev = normalizeOptions(true, {
|
|
185
182
|
disableLiveReload: true,
|
|
186
183
|
disableHotTypesReload: false,
|
|
@@ -189,6 +186,9 @@ var _DevPlugin = class _DevPlugin {
|
|
|
189
186
|
if (!isDev() || normalizedDev === false) {
|
|
190
187
|
return;
|
|
191
188
|
}
|
|
189
|
+
new compiler.webpack.DefinePlugin({
|
|
190
|
+
FEDERATION_IPV4: JSON.stringify(getIPV4())
|
|
191
|
+
}).apply(compiler);
|
|
192
192
|
if (normalizedDev.disableHotTypesReload && normalizedDev.disableLiveReload && normalizedDev.disableDynamicRemoteTypeHints) {
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
@@ -285,7 +285,8 @@ import { logger as logger2 } from "@module-federation/sdk";
|
|
|
285
285
|
import { normalizeOptions as normalizeOptions2 } from "@module-federation/sdk";
|
|
286
286
|
var DEFAULT_CONSUME_TYPES = {
|
|
287
287
|
abortOnError: false,
|
|
288
|
-
consumeAPITypes: true
|
|
288
|
+
consumeAPITypes: true,
|
|
289
|
+
typesOnBuild: false
|
|
289
290
|
};
|
|
290
291
|
var normalizeConsumeTypesOptions = /* @__PURE__ */ __name(({ context, dtsOptions, pluginOptions }) => {
|
|
291
292
|
const normalizedConsumeTypes = normalizeOptions2(true, DEFAULT_CONSUME_TYPES, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
@@ -330,10 +331,6 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
330
331
|
}
|
|
331
332
|
apply(compiler) {
|
|
332
333
|
const { dtsOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
333
|
-
if (isPrd()) {
|
|
334
|
-
fetchRemoteTypeUrlsResolve(void 0);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
334
|
const dtsManagerOptions = normalizeConsumeTypesOptions({
|
|
338
335
|
context: compiler.context,
|
|
339
336
|
dtsOptions,
|
|
@@ -343,6 +340,10 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
343
340
|
fetchRemoteTypeUrlsResolve(void 0);
|
|
344
341
|
return;
|
|
345
342
|
}
|
|
343
|
+
if (isPrd() && !dtsManagerOptions.host.typesOnBuild) {
|
|
344
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
346
347
|
logger2.debug("start fetching remote types...");
|
|
347
348
|
const promise = consumeTypesAPI(dtsManagerOptions, fetchRemoteTypeUrlsResolve);
|
|
348
349
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
@@ -572,6 +573,16 @@ var normalizeDtsOptions = /* @__PURE__ */ __name((options, context, defaultOptio
|
|
|
572
573
|
displayErrorInTerminal: true
|
|
573
574
|
}, "mfOptions.dts")(options.dts);
|
|
574
575
|
}, "normalizeDtsOptions");
|
|
576
|
+
var excludeDts = /* @__PURE__ */ __name((filepath) => {
|
|
577
|
+
if (typeof filepath !== "string") {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
const [_p, query] = filepath.split("?");
|
|
581
|
+
if (query && query.startsWith("exclude-mf-dts")) {
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
return false;
|
|
585
|
+
}, "excludeDts");
|
|
575
586
|
var _DtsPlugin = class _DtsPlugin {
|
|
576
587
|
constructor(options) {
|
|
577
588
|
__publicField(this, "options");
|
|
@@ -585,8 +596,15 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
585
596
|
const cleanedExposes = {};
|
|
586
597
|
Object.entries(options.exposes).forEach(([key, value]) => {
|
|
587
598
|
if (typeof value === "string") {
|
|
588
|
-
|
|
599
|
+
const [filepath, _query] = value.split("?");
|
|
600
|
+
if (excludeDts(value)) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
cleanedExposes[key] = filepath;
|
|
589
604
|
} else {
|
|
605
|
+
if (typeof value === "object" && Array.isArray(value.import) && value.import.some((v) => excludeDts(v))) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
590
608
|
cleanedExposes[key] = value;
|
|
591
609
|
}
|
|
592
610
|
});
|
package/dist/fork-dev-worker.js
CHANGED
|
@@ -1685,7 +1685,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1685
1685
|
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1686
1686
|
while (retries++ < hostOptions.maxRetries) {
|
|
1687
1687
|
try {
|
|
1688
|
-
const url = fileToDownload;
|
|
1688
|
+
const url = new URL(fileToDownload).href;
|
|
1689
1689
|
const response = yield axiosGet(url, {
|
|
1690
1690
|
responseType: "arraybuffer",
|
|
1691
1691
|
timeout: hostOptions.timeout
|
|
@@ -1713,7 +1713,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1713
1713
|
} catch (error2) {
|
|
1714
1714
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1715
1715
|
if (retries >= hostOptions.maxRetries) {
|
|
1716
|
-
logger.error(`Failed to download ${fileToDownload}
|
|
1716
|
+
logger.error(`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`);
|
|
1717
1717
|
if (hostOptions.abortOnError !== false) {
|
|
1718
1718
|
throw error2;
|
|
1719
1719
|
}
|
|
@@ -1738,7 +1738,8 @@ var defaultOptions = {
|
|
|
1738
1738
|
consumeAPITypes: false,
|
|
1739
1739
|
runtimePkgs: [],
|
|
1740
1740
|
remoteTypeUrls: {},
|
|
1741
|
-
timeout: 6e4
|
|
1741
|
+
timeout: 6e4,
|
|
1742
|
+
typesOnBuild: false
|
|
1742
1743
|
};
|
|
1743
1744
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1744
1745
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1918,7 +1919,7 @@ var DTSManager = (_a = class {
|
|
|
1918
1919
|
// it must execute after consumeTypes
|
|
1919
1920
|
generateTypes() {
|
|
1920
1921
|
return __async(this, null, function* () {
|
|
1921
|
-
var _a3;
|
|
1922
|
+
var _a3, _b;
|
|
1922
1923
|
try {
|
|
1923
1924
|
const { options } = this;
|
|
1924
1925
|
if (!options.remote) {
|
|
@@ -1928,6 +1929,10 @@ var DTSManager = (_a = class {
|
|
|
1928
1929
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1929
1930
|
return;
|
|
1930
1931
|
}
|
|
1932
|
+
if (!((_a3 = tsConfig.files) == null ? void 0 : _a3.length)) {
|
|
1933
|
+
logger.info("No type files to compile, skip");
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1931
1936
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1932
1937
|
try {
|
|
1933
1938
|
const tsBuildInfoFile = import_path4.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -1967,7 +1972,7 @@ var DTSManager = (_a = class {
|
|
|
1967
1972
|
}
|
|
1968
1973
|
logger.success("Federated types created correctly");
|
|
1969
1974
|
} catch (error2) {
|
|
1970
|
-
if (((
|
|
1975
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
1971
1976
|
if (this.options.displayErrorInTerminal) {
|
|
1972
1977
|
logger.error(error2);
|
|
1973
1978
|
}
|
|
@@ -2374,11 +2379,15 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
2374
2379
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
2375
2380
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
2376
2381
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
2382
|
+
const excludeExtensions = [
|
|
2383
|
+
".mdx",
|
|
2384
|
+
".md"
|
|
2385
|
+
];
|
|
2377
2386
|
const filesToCompile = [
|
|
2378
2387
|
...Object.values(mapComponentsToExpose),
|
|
2379
2388
|
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
2380
2389
|
...additionalFilesToCompile
|
|
2381
|
-
];
|
|
2390
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
2382
2391
|
rawTsConfigJson.include = [];
|
|
2383
2392
|
rawTsConfigJson.files = filesToCompile;
|
|
2384
2393
|
rawTsConfigJson.exclude = [];
|
|
@@ -227,11 +227,15 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
227
227
|
const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
|
|
228
228
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
229
229
|
const outDirWithoutTypesFolder = (0, import_path.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
230
|
+
const excludeExtensions = [
|
|
231
|
+
".mdx",
|
|
232
|
+
".md"
|
|
233
|
+
];
|
|
230
234
|
const filesToCompile = [
|
|
231
235
|
...Object.values(mapComponentsToExpose),
|
|
232
236
|
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
233
237
|
...additionalFilesToCompile
|
|
234
|
-
];
|
|
238
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
235
239
|
rawTsConfigJson.include = [];
|
|
236
240
|
rawTsConfigJson.files = filesToCompile;
|
|
237
241
|
rawTsConfigJson.exclude = [];
|
|
@@ -1332,7 +1336,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1332
1336
|
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1333
1337
|
while (retries++ < hostOptions.maxRetries) {
|
|
1334
1338
|
try {
|
|
1335
|
-
const url = fileToDownload;
|
|
1339
|
+
const url = new URL(fileToDownload).href;
|
|
1336
1340
|
const response = yield axiosGet(url, {
|
|
1337
1341
|
responseType: "arraybuffer",
|
|
1338
1342
|
timeout: hostOptions.timeout
|
|
@@ -1360,7 +1364,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1360
1364
|
} catch (error2) {
|
|
1361
1365
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1362
1366
|
if (retries >= hostOptions.maxRetries) {
|
|
1363
|
-
logger.error(`Failed to download ${fileToDownload}
|
|
1367
|
+
logger.error(`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`);
|
|
1364
1368
|
if (hostOptions.abortOnError !== false) {
|
|
1365
1369
|
throw error2;
|
|
1366
1370
|
}
|
|
@@ -1385,7 +1389,8 @@ var defaultOptions2 = {
|
|
|
1385
1389
|
consumeAPITypes: false,
|
|
1386
1390
|
runtimePkgs: [],
|
|
1387
1391
|
remoteTypeUrls: {},
|
|
1388
|
-
timeout: 6e4
|
|
1392
|
+
timeout: 6e4,
|
|
1393
|
+
typesOnBuild: false
|
|
1389
1394
|
};
|
|
1390
1395
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1391
1396
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1565,7 +1570,7 @@ var DTSManager = (_a = class {
|
|
|
1565
1570
|
// it must execute after consumeTypes
|
|
1566
1571
|
generateTypes() {
|
|
1567
1572
|
return __async(this, null, function* () {
|
|
1568
|
-
var _a2;
|
|
1573
|
+
var _a2, _b;
|
|
1569
1574
|
try {
|
|
1570
1575
|
const { options } = this;
|
|
1571
1576
|
if (!options.remote) {
|
|
@@ -1575,6 +1580,10 @@ var DTSManager = (_a = class {
|
|
|
1575
1580
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1576
1581
|
return;
|
|
1577
1582
|
}
|
|
1583
|
+
if (!((_a2 = tsConfig.files) == null ? void 0 : _a2.length)) {
|
|
1584
|
+
logger.info("No type files to compile, skip");
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1578
1587
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1579
1588
|
try {
|
|
1580
1589
|
const tsBuildInfoFile = import_path4.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -1614,7 +1623,7 @@ var DTSManager = (_a = class {
|
|
|
1614
1623
|
}
|
|
1615
1624
|
logger.success("Federated types created correctly");
|
|
1616
1625
|
} catch (error2) {
|
|
1617
|
-
if (((
|
|
1626
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
1618
1627
|
if (this.options.displayErrorInTerminal) {
|
|
1619
1628
|
logger.error(error2);
|
|
1620
1629
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,7 @@ declare const normalizeConsumeTypesOptions: ({ context, dtsOptions, pluginOption
|
|
|
32
32
|
runtimePkgs?: string[];
|
|
33
33
|
remoteTypeUrls?: (() => Promise<moduleFederationPlugin.RemoteTypeUrls>) | moduleFederationPlugin.RemoteTypeUrls;
|
|
34
34
|
timeout?: number;
|
|
35
|
+
typesOnBuild?: boolean;
|
|
35
36
|
implementation: string;
|
|
36
37
|
context: string;
|
|
37
38
|
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ declare const normalizeConsumeTypesOptions: ({ context, dtsOptions, pluginOption
|
|
|
32
32
|
runtimePkgs?: string[];
|
|
33
33
|
remoteTypeUrls?: (() => Promise<moduleFederationPlugin.RemoteTypeUrls>) | moduleFederationPlugin.RemoteTypeUrls;
|
|
34
34
|
timeout?: number;
|
|
35
|
+
typesOnBuild?: boolean;
|
|
35
36
|
implementation: string;
|
|
36
37
|
context: string;
|
|
37
38
|
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
package/dist/index.js
CHANGED
|
@@ -1194,7 +1194,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1194
1194
|
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1195
1195
|
while (retries++ < hostOptions.maxRetries) {
|
|
1196
1196
|
try {
|
|
1197
|
-
const url = fileToDownload;
|
|
1197
|
+
const url = new URL(fileToDownload).href;
|
|
1198
1198
|
const response = yield axiosGet(url, {
|
|
1199
1199
|
responseType: "arraybuffer",
|
|
1200
1200
|
timeout: hostOptions.timeout
|
|
@@ -1222,7 +1222,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1222
1222
|
} catch (error2) {
|
|
1223
1223
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1224
1224
|
if (retries >= hostOptions.maxRetries) {
|
|
1225
|
-
logger.error(`Failed to download ${fileToDownload}
|
|
1225
|
+
logger.error(`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`);
|
|
1226
1226
|
if (hostOptions.abortOnError !== false) {
|
|
1227
1227
|
throw error2;
|
|
1228
1228
|
}
|
|
@@ -1247,7 +1247,8 @@ var defaultOptions = {
|
|
|
1247
1247
|
consumeAPITypes: false,
|
|
1248
1248
|
runtimePkgs: [],
|
|
1249
1249
|
remoteTypeUrls: {},
|
|
1250
|
-
timeout: 6e4
|
|
1250
|
+
timeout: 6e4,
|
|
1251
|
+
typesOnBuild: false
|
|
1251
1252
|
};
|
|
1252
1253
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1253
1254
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1427,7 +1428,7 @@ var DTSManager = (_a = class {
|
|
|
1427
1428
|
// it must execute after consumeTypes
|
|
1428
1429
|
generateTypes() {
|
|
1429
1430
|
return __async(this, null, function* () {
|
|
1430
|
-
var _a3;
|
|
1431
|
+
var _a3, _b;
|
|
1431
1432
|
try {
|
|
1432
1433
|
const { options } = this;
|
|
1433
1434
|
if (!options.remote) {
|
|
@@ -1437,6 +1438,10 @@ var DTSManager = (_a = class {
|
|
|
1437
1438
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1438
1439
|
return;
|
|
1439
1440
|
}
|
|
1441
|
+
if (!((_a3 = tsConfig.files) == null ? void 0 : _a3.length)) {
|
|
1442
|
+
logger.info("No type files to compile, skip");
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1440
1445
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1441
1446
|
try {
|
|
1442
1447
|
const tsBuildInfoFile = import_path3.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -1476,7 +1481,7 @@ var DTSManager = (_a = class {
|
|
|
1476
1481
|
}
|
|
1477
1482
|
logger.success("Federated types created correctly");
|
|
1478
1483
|
} catch (error2) {
|
|
1479
|
-
if (((
|
|
1484
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
1480
1485
|
if (this.options.displayErrorInTerminal) {
|
|
1481
1486
|
logger.error(error2);
|
|
1482
1487
|
}
|
|
@@ -1781,7 +1786,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1781
1786
|
let zipPrefix = "";
|
|
1782
1787
|
try {
|
|
1783
1788
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1784
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1789
|
+
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1785
1790
|
return {
|
|
1786
1791
|
zipPrefix,
|
|
1787
1792
|
apiTypesPath,
|
|
@@ -1949,11 +1954,15 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1949
1954
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
1950
1955
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
1951
1956
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
1957
|
+
const excludeExtensions = [
|
|
1958
|
+
".mdx",
|
|
1959
|
+
".md"
|
|
1960
|
+
];
|
|
1952
1961
|
const filesToCompile = [
|
|
1953
1962
|
...Object.values(mapComponentsToExpose),
|
|
1954
1963
|
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
1955
1964
|
...additionalFilesToCompile
|
|
1956
|
-
];
|
|
1965
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
1957
1966
|
rawTsConfigJson.include = [];
|
|
1958
1967
|
rawTsConfigJson.files = filesToCompile;
|
|
1959
1968
|
rawTsConfigJson.exclude = [];
|
|
@@ -2493,9 +2502,6 @@ var _DevPlugin = class _DevPlugin {
|
|
|
2493
2502
|
apply(compiler) {
|
|
2494
2503
|
var _a3;
|
|
2495
2504
|
const { _options: { name, dev, dts } } = this;
|
|
2496
|
-
new compiler.webpack.DefinePlugin({
|
|
2497
|
-
FEDERATION_IPV4: JSON.stringify(getIPV4())
|
|
2498
|
-
}).apply(compiler);
|
|
2499
2505
|
const normalizedDev = (0, import_sdk7.normalizeOptions)(true, {
|
|
2500
2506
|
disableLiveReload: true,
|
|
2501
2507
|
disableHotTypesReload: false,
|
|
@@ -2504,6 +2510,9 @@ var _DevPlugin = class _DevPlugin {
|
|
|
2504
2510
|
if (!isDev() || normalizedDev === false) {
|
|
2505
2511
|
return;
|
|
2506
2512
|
}
|
|
2513
|
+
new compiler.webpack.DefinePlugin({
|
|
2514
|
+
FEDERATION_IPV4: JSON.stringify(getIPV4())
|
|
2515
|
+
}).apply(compiler);
|
|
2507
2516
|
if (normalizedDev.disableHotTypesReload && normalizedDev.disableLiveReload && normalizedDev.disableDynamicRemoteTypeHints) {
|
|
2508
2517
|
return;
|
|
2509
2518
|
}
|
|
@@ -2600,7 +2609,8 @@ var import_sdk8 = require("@module-federation/sdk");
|
|
|
2600
2609
|
var import_sdk9 = require("@module-federation/sdk");
|
|
2601
2610
|
var DEFAULT_CONSUME_TYPES = {
|
|
2602
2611
|
abortOnError: false,
|
|
2603
|
-
consumeAPITypes: true
|
|
2612
|
+
consumeAPITypes: true,
|
|
2613
|
+
typesOnBuild: false
|
|
2604
2614
|
};
|
|
2605
2615
|
var normalizeConsumeTypesOptions = /* @__PURE__ */ __name(({ context, dtsOptions, pluginOptions }) => {
|
|
2606
2616
|
const normalizedConsumeTypes = (0, import_sdk9.normalizeOptions)(true, DEFAULT_CONSUME_TYPES, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
@@ -2645,10 +2655,6 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2645
2655
|
}
|
|
2646
2656
|
apply(compiler) {
|
|
2647
2657
|
const { dtsOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
2648
|
-
if (isPrd()) {
|
|
2649
|
-
fetchRemoteTypeUrlsResolve(void 0);
|
|
2650
|
-
return;
|
|
2651
|
-
}
|
|
2652
2658
|
const dtsManagerOptions = normalizeConsumeTypesOptions({
|
|
2653
2659
|
context: compiler.context,
|
|
2654
2660
|
dtsOptions,
|
|
@@ -2658,6 +2664,10 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2658
2664
|
fetchRemoteTypeUrlsResolve(void 0);
|
|
2659
2665
|
return;
|
|
2660
2666
|
}
|
|
2667
|
+
if (isPrd() && !dtsManagerOptions.host.typesOnBuild) {
|
|
2668
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2661
2671
|
import_sdk8.logger.debug("start fetching remote types...");
|
|
2662
2672
|
const promise = consumeTypesAPI(dtsManagerOptions, fetchRemoteTypeUrlsResolve);
|
|
2663
2673
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
@@ -2887,6 +2897,16 @@ var normalizeDtsOptions = /* @__PURE__ */ __name((options, context, defaultOptio
|
|
|
2887
2897
|
displayErrorInTerminal: true
|
|
2888
2898
|
}, "mfOptions.dts")(options.dts);
|
|
2889
2899
|
}, "normalizeDtsOptions");
|
|
2900
|
+
var excludeDts = /* @__PURE__ */ __name((filepath) => {
|
|
2901
|
+
if (typeof filepath !== "string") {
|
|
2902
|
+
return false;
|
|
2903
|
+
}
|
|
2904
|
+
const [_p, query] = filepath.split("?");
|
|
2905
|
+
if (query && query.startsWith("exclude-mf-dts")) {
|
|
2906
|
+
return true;
|
|
2907
|
+
}
|
|
2908
|
+
return false;
|
|
2909
|
+
}, "excludeDts");
|
|
2890
2910
|
var _DtsPlugin = class _DtsPlugin {
|
|
2891
2911
|
constructor(options) {
|
|
2892
2912
|
__publicField(this, "options");
|
|
@@ -2900,8 +2920,15 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
2900
2920
|
const cleanedExposes = {};
|
|
2901
2921
|
Object.entries(options.exposes).forEach(([key, value]) => {
|
|
2902
2922
|
if (typeof value === "string") {
|
|
2903
|
-
|
|
2923
|
+
const [filepath, _query] = value.split("?");
|
|
2924
|
+
if (excludeDts(value)) {
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2927
|
+
cleanedExposes[key] = filepath;
|
|
2904
2928
|
} else {
|
|
2929
|
+
if (typeof value === "object" && Array.isArray(value.import) && value.import.some((v) => excludeDts(v))) {
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2905
2932
|
cleanedExposes[key] = value;
|
|
2906
2933
|
}
|
|
2907
2934
|
});
|
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.
|
|
3
|
+
"version": "0.16.0",
|
|
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.
|
|
64
|
-
"@module-federation/managers": "0.
|
|
65
|
-
"@module-federation/third-party-dts-extractor": "0.
|
|
66
|
-
"@module-federation/error-codes": "0.
|
|
63
|
+
"@module-federation/sdk": "0.16.0",
|
|
64
|
+
"@module-federation/managers": "0.16.0",
|
|
65
|
+
"@module-federation/third-party-dts-extractor": "0.16.0",
|
|
66
|
+
"@module-federation/error-codes": "0.16.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/ws": "8.5.12",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@vue/tsconfig": "^0.7.0",
|
|
74
74
|
"vue-tsc": "^2.2.10",
|
|
75
75
|
"rimraf": "~6.0.1",
|
|
76
|
-
"@module-federation/runtime": "0.
|
|
76
|
+
"@module-federation/runtime": "0.16.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"typescript": "^4.9.0 || ^5.0.0",
|