@module-federation/dts-plugin 0.15.0 → 0.17.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 +24 -0
- package/dist/core.js +27 -7
- package/dist/dynamic-remote-type-hints-plugin.d.mts +2 -2
- package/dist/dynamic-remote-type-hints-plugin.d.ts +2 -2
- package/dist/esm/{chunk-YVBDT2VM.js → chunk-7TWMRWVP.js} +1 -1
- package/dist/esm/{chunk-4LAJMII5.js → chunk-YD3XN4HU.js} +27 -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 +8 -7
- package/dist/fork-dev-worker.js +26 -6
- package/dist/fork-generate-dts.js +26 -6
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -12
- package/dist/package.json +1 -1
- package/package.json +6 -6
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1d691ef: fix(dts-plugin): add expose file imported files to tsconfig files
|
|
8
|
+
- @module-federation/sdk@0.17.0
|
|
9
|
+
- @module-federation/managers@0.17.0
|
|
10
|
+
- @module-federation/third-party-dts-extractor@0.17.0
|
|
11
|
+
- @module-federation/error-codes@0.17.0
|
|
12
|
+
|
|
13
|
+
## 0.16.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 1485fcf: added flag to fetch types from remote when building in production.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [1485fcf]
|
|
22
|
+
- @module-federation/sdk@0.16.0
|
|
23
|
+
- @module-federation/managers@0.16.0
|
|
24
|
+
- @module-federation/third-party-dts-extractor@0.16.0
|
|
25
|
+
- @module-federation/error-codes@0.16.0
|
|
26
|
+
|
|
3
27
|
## 0.15.0
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/core.js
CHANGED
|
@@ -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,
|
|
@@ -1895,6 +1900,12 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
1895
1900
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
1896
1901
|
}
|
|
1897
1902
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
1903
|
+
var getDependentFiles = /* @__PURE__ */ __name((rootFiles, configContent, rootDir) => {
|
|
1904
|
+
const program = import_typescript.default.createProgram(rootFiles, configContent.options);
|
|
1905
|
+
const sourceFiles = program.getSourceFiles();
|
|
1906
|
+
const dependentFiles = sourceFiles.map((file) => file.fileName).filter((file) => !file.endsWith(".d.ts") && file.startsWith(rootDir));
|
|
1907
|
+
return dependentFiles.length ? dependentFiles : rootFiles;
|
|
1908
|
+
}, "getDependentFiles");
|
|
1898
1909
|
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
1899
1910
|
const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
|
|
1900
1911
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
@@ -1920,13 +1931,22 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1920
1931
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
1921
1932
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
1922
1933
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
1923
|
-
const
|
|
1934
|
+
const excludeExtensions = [
|
|
1935
|
+
".mdx",
|
|
1936
|
+
".md"
|
|
1937
|
+
];
|
|
1938
|
+
const rootFiles = [
|
|
1924
1939
|
...Object.values(mapComponentsToExpose),
|
|
1925
|
-
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
1926
1940
|
...additionalFilesToCompile
|
|
1941
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
1942
|
+
const filesToCompile = [
|
|
1943
|
+
...getDependentFiles(rootFiles, configContent, rootDir),
|
|
1944
|
+
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder))
|
|
1927
1945
|
];
|
|
1928
1946
|
rawTsConfigJson.include = [];
|
|
1929
|
-
rawTsConfigJson.files =
|
|
1947
|
+
rawTsConfigJson.files = [
|
|
1948
|
+
...new Set(filesToCompile)
|
|
1949
|
+
];
|
|
1930
1950
|
rawTsConfigJson.exclude = [];
|
|
1931
1951
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
1932
1952
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
|
|
2
2
|
|
|
3
|
-
declare function dynamicRemoteTypeHintsPlugin():
|
|
3
|
+
declare function dynamicRemoteTypeHintsPlugin(): ModuleFederationRuntimePlugin;
|
|
4
4
|
|
|
5
5
|
export { dynamicRemoteTypeHintsPlugin as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
|
|
2
2
|
|
|
3
|
-
declare function dynamicRemoteTypeHintsPlugin():
|
|
3
|
+
declare function dynamicRemoteTypeHintsPlugin(): ModuleFederationRuntimePlugin;
|
|
4
4
|
|
|
5
5
|
export { dynamicRemoteTypeHintsPlugin as default };
|
|
@@ -629,6 +629,12 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
629
629
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
630
630
|
}
|
|
631
631
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
632
|
+
var getDependentFiles = /* @__PURE__ */ __name((rootFiles, configContent, rootDir) => {
|
|
633
|
+
const program = typescript.createProgram(rootFiles, configContent.options);
|
|
634
|
+
const sourceFiles = program.getSourceFiles();
|
|
635
|
+
const dependentFiles = sourceFiles.map((file) => file.fileName).filter((file) => !file.endsWith(".d.ts") && file.startsWith(rootDir));
|
|
636
|
+
return dependentFiles.length ? dependentFiles : rootFiles;
|
|
637
|
+
}, "getDependentFiles");
|
|
632
638
|
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
633
639
|
const resolvedTsConfigPath = resolve2(context, tsConfigPath);
|
|
634
640
|
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
@@ -654,13 +660,22 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
654
660
|
const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
|
|
655
661
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
656
662
|
const outDirWithoutTypesFolder = resolve2(context, outputDir || configContent.options.outDir || "dist");
|
|
657
|
-
const
|
|
663
|
+
const excludeExtensions = [
|
|
664
|
+
".mdx",
|
|
665
|
+
".md"
|
|
666
|
+
];
|
|
667
|
+
const rootFiles = [
|
|
658
668
|
...Object.values(mapComponentsToExpose),
|
|
659
|
-
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
660
669
|
...additionalFilesToCompile
|
|
670
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
671
|
+
const filesToCompile = [
|
|
672
|
+
...getDependentFiles(rootFiles, configContent, rootDir),
|
|
673
|
+
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder))
|
|
661
674
|
];
|
|
662
675
|
rawTsConfigJson.include = [];
|
|
663
|
-
rawTsConfigJson.files =
|
|
676
|
+
rawTsConfigJson.files = [
|
|
677
|
+
...new Set(filesToCompile)
|
|
678
|
+
];
|
|
664
679
|
rawTsConfigJson.exclude = [];
|
|
665
680
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
666
681
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
@@ -735,7 +750,8 @@ var defaultOptions2 = {
|
|
|
735
750
|
consumeAPITypes: false,
|
|
736
751
|
runtimePkgs: [],
|
|
737
752
|
remoteTypeUrls: {},
|
|
738
|
-
timeout: 6e4
|
|
753
|
+
timeout: 6e4,
|
|
754
|
+
typesOnBuild: false
|
|
739
755
|
};
|
|
740
756
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
741
757
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -915,7 +931,7 @@ var DTSManager = (_a = class {
|
|
|
915
931
|
// it must execute after consumeTypes
|
|
916
932
|
generateTypes() {
|
|
917
933
|
return __async(this, null, function* () {
|
|
918
|
-
var _a2;
|
|
934
|
+
var _a2, _b;
|
|
919
935
|
try {
|
|
920
936
|
const { options } = this;
|
|
921
937
|
if (!options.remote) {
|
|
@@ -925,6 +941,10 @@ var DTSManager = (_a = class {
|
|
|
925
941
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
926
942
|
return;
|
|
927
943
|
}
|
|
944
|
+
if (!((_a2 = tsConfig.files) == null ? void 0 : _a2.length)) {
|
|
945
|
+
logger.info("No type files to compile, skip");
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
928
948
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
929
949
|
try {
|
|
930
950
|
const tsBuildInfoFile = path2.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -964,7 +984,7 @@ var DTSManager = (_a = class {
|
|
|
964
984
|
}
|
|
965
985
|
logger.success("Federated types created correctly");
|
|
966
986
|
} catch (error) {
|
|
967
|
-
if (((
|
|
987
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
968
988
|
if (this.options.displayErrorInTerminal) {
|
|
969
989
|
logger.error(error);
|
|
970
990
|
}
|
|
@@ -1269,7 +1289,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1269
1289
|
let zipPrefix = "";
|
|
1270
1290
|
try {
|
|
1271
1291
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1272
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1292
|
+
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1273
1293
|
return {
|
|
1274
1294
|
zipPrefix,
|
|
1275
1295
|
apiTypesPath,
|
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-7TWMRWVP.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-YD3XN4HU.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-7TWMRWVP.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-YD3XN4HU.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-7TWMRWVP.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-YD3XN4HU.js";
|
|
13
13
|
import {
|
|
14
14
|
getIPV4,
|
|
15
15
|
logger
|
|
@@ -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) => {
|
package/dist/fork-dev-worker.js
CHANGED
|
@@ -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
|
}
|
|
@@ -2349,6 +2354,12 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
2349
2354
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
2350
2355
|
}
|
|
2351
2356
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
2357
|
+
var getDependentFiles = /* @__PURE__ */ __name((rootFiles, configContent, rootDir) => {
|
|
2358
|
+
const program = import_typescript.default.createProgram(rootFiles, configContent.options);
|
|
2359
|
+
const sourceFiles = program.getSourceFiles();
|
|
2360
|
+
const dependentFiles = sourceFiles.map((file) => file.fileName).filter((file) => !file.endsWith(".d.ts") && file.startsWith(rootDir));
|
|
2361
|
+
return dependentFiles.length ? dependentFiles : rootFiles;
|
|
2362
|
+
}, "getDependentFiles");
|
|
2352
2363
|
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
2353
2364
|
const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
|
|
2354
2365
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
@@ -2374,13 +2385,22 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
2374
2385
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
2375
2386
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
2376
2387
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
2377
|
-
const
|
|
2388
|
+
const excludeExtensions = [
|
|
2389
|
+
".mdx",
|
|
2390
|
+
".md"
|
|
2391
|
+
];
|
|
2392
|
+
const rootFiles = [
|
|
2378
2393
|
...Object.values(mapComponentsToExpose),
|
|
2379
|
-
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
2380
2394
|
...additionalFilesToCompile
|
|
2395
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
2396
|
+
const filesToCompile = [
|
|
2397
|
+
...getDependentFiles(rootFiles, configContent, rootDir),
|
|
2398
|
+
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder))
|
|
2381
2399
|
];
|
|
2382
2400
|
rawTsConfigJson.include = [];
|
|
2383
|
-
rawTsConfigJson.files =
|
|
2401
|
+
rawTsConfigJson.files = [
|
|
2402
|
+
...new Set(filesToCompile)
|
|
2403
|
+
];
|
|
2384
2404
|
rawTsConfigJson.exclude = [];
|
|
2385
2405
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2386
2406
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
@@ -202,6 +202,12 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
202
202
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
203
203
|
}
|
|
204
204
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
205
|
+
var getDependentFiles = /* @__PURE__ */ __name((rootFiles, configContent, rootDir) => {
|
|
206
|
+
const program = import_typescript.default.createProgram(rootFiles, configContent.options);
|
|
207
|
+
const sourceFiles = program.getSourceFiles();
|
|
208
|
+
const dependentFiles = sourceFiles.map((file) => file.fileName).filter((file) => !file.endsWith(".d.ts") && file.startsWith(rootDir));
|
|
209
|
+
return dependentFiles.length ? dependentFiles : rootFiles;
|
|
210
|
+
}, "getDependentFiles");
|
|
205
211
|
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
206
212
|
const resolvedTsConfigPath = (0, import_path.resolve)(context, tsConfigPath);
|
|
207
213
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
@@ -227,13 +233,22 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
227
233
|
const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
|
|
228
234
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
229
235
|
const outDirWithoutTypesFolder = (0, import_path.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
230
|
-
const
|
|
236
|
+
const excludeExtensions = [
|
|
237
|
+
".mdx",
|
|
238
|
+
".md"
|
|
239
|
+
];
|
|
240
|
+
const rootFiles = [
|
|
231
241
|
...Object.values(mapComponentsToExpose),
|
|
232
|
-
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
233
242
|
...additionalFilesToCompile
|
|
243
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
244
|
+
const filesToCompile = [
|
|
245
|
+
...getDependentFiles(rootFiles, configContent, rootDir),
|
|
246
|
+
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder))
|
|
234
247
|
];
|
|
235
248
|
rawTsConfigJson.include = [];
|
|
236
|
-
rawTsConfigJson.files =
|
|
249
|
+
rawTsConfigJson.files = [
|
|
250
|
+
...new Set(filesToCompile)
|
|
251
|
+
];
|
|
237
252
|
rawTsConfigJson.exclude = [];
|
|
238
253
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
239
254
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
@@ -1385,7 +1400,8 @@ var defaultOptions2 = {
|
|
|
1385
1400
|
consumeAPITypes: false,
|
|
1386
1401
|
runtimePkgs: [],
|
|
1387
1402
|
remoteTypeUrls: {},
|
|
1388
|
-
timeout: 6e4
|
|
1403
|
+
timeout: 6e4,
|
|
1404
|
+
typesOnBuild: false
|
|
1389
1405
|
};
|
|
1390
1406
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1391
1407
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1565,7 +1581,7 @@ var DTSManager = (_a = class {
|
|
|
1565
1581
|
// it must execute after consumeTypes
|
|
1566
1582
|
generateTypes() {
|
|
1567
1583
|
return __async(this, null, function* () {
|
|
1568
|
-
var _a2;
|
|
1584
|
+
var _a2, _b;
|
|
1569
1585
|
try {
|
|
1570
1586
|
const { options } = this;
|
|
1571
1587
|
if (!options.remote) {
|
|
@@ -1575,6 +1591,10 @@ var DTSManager = (_a = class {
|
|
|
1575
1591
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1576
1592
|
return;
|
|
1577
1593
|
}
|
|
1594
|
+
if (!((_a2 = tsConfig.files) == null ? void 0 : _a2.length)) {
|
|
1595
|
+
logger.info("No type files to compile, skip");
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1578
1598
|
if (tsConfig.compilerOptions.tsBuildInfoFile) {
|
|
1579
1599
|
try {
|
|
1580
1600
|
const tsBuildInfoFile = import_path4.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
|
|
@@ -1614,7 +1634,7 @@ var DTSManager = (_a = class {
|
|
|
1614
1634
|
}
|
|
1615
1635
|
logger.success("Federated types created correctly");
|
|
1616
1636
|
} catch (error2) {
|
|
1617
|
-
if (((
|
|
1637
|
+
if (((_b = this.options.remote) == null ? void 0 : _b.abortOnError) === false) {
|
|
1618
1638
|
if (this.options.displayErrorInTerminal) {
|
|
1619
1639
|
logger.error(error2);
|
|
1620
1640
|
}
|
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
|
@@ -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,
|
|
@@ -1924,6 +1929,12 @@ function getEffectiveRootDir(parsedCommandLine) {
|
|
|
1924
1929
|
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
1925
1930
|
}
|
|
1926
1931
|
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
1932
|
+
var getDependentFiles = /* @__PURE__ */ __name((rootFiles, configContent, rootDir) => {
|
|
1933
|
+
const program = import_typescript.default.createProgram(rootFiles, configContent.options);
|
|
1934
|
+
const sourceFiles = program.getSourceFiles();
|
|
1935
|
+
const dependentFiles = sourceFiles.map((file) => file.fileName).filter((file) => !file.endsWith(".d.ts") && file.startsWith(rootDir));
|
|
1936
|
+
return dependentFiles.length ? dependentFiles : rootFiles;
|
|
1937
|
+
}, "getDependentFiles");
|
|
1927
1938
|
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
|
|
1928
1939
|
const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
|
|
1929
1940
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
@@ -1949,13 +1960,22 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1949
1960
|
const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
|
|
1950
1961
|
rawTsConfigJson.compilerOptions = restCompilerOptions;
|
|
1951
1962
|
const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
|
|
1952
|
-
const
|
|
1963
|
+
const excludeExtensions = [
|
|
1964
|
+
".mdx",
|
|
1965
|
+
".md"
|
|
1966
|
+
];
|
|
1967
|
+
const rootFiles = [
|
|
1953
1968
|
...Object.values(mapComponentsToExpose),
|
|
1954
|
-
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
|
|
1955
1969
|
...additionalFilesToCompile
|
|
1970
|
+
].filter((filename) => !excludeExtensions.some((ext) => filename.endsWith(ext)));
|
|
1971
|
+
const filesToCompile = [
|
|
1972
|
+
...getDependentFiles(rootFiles, configContent, rootDir),
|
|
1973
|
+
...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder))
|
|
1956
1974
|
];
|
|
1957
1975
|
rawTsConfigJson.include = [];
|
|
1958
|
-
rawTsConfigJson.files =
|
|
1976
|
+
rawTsConfigJson.files = [
|
|
1977
|
+
...new Set(filesToCompile)
|
|
1978
|
+
];
|
|
1959
1979
|
rawTsConfigJson.exclude = [];
|
|
1960
1980
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
1961
1981
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
@@ -2600,7 +2620,8 @@ var import_sdk8 = require("@module-federation/sdk");
|
|
|
2600
2620
|
var import_sdk9 = require("@module-federation/sdk");
|
|
2601
2621
|
var DEFAULT_CONSUME_TYPES = {
|
|
2602
2622
|
abortOnError: false,
|
|
2603
|
-
consumeAPITypes: true
|
|
2623
|
+
consumeAPITypes: true,
|
|
2624
|
+
typesOnBuild: false
|
|
2604
2625
|
};
|
|
2605
2626
|
var normalizeConsumeTypesOptions = /* @__PURE__ */ __name(({ context, dtsOptions, pluginOptions }) => {
|
|
2606
2627
|
const normalizedConsumeTypes = (0, import_sdk9.normalizeOptions)(true, DEFAULT_CONSUME_TYPES, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
@@ -2645,10 +2666,6 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2645
2666
|
}
|
|
2646
2667
|
apply(compiler) {
|
|
2647
2668
|
const { dtsOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
2648
|
-
if (isPrd()) {
|
|
2649
|
-
fetchRemoteTypeUrlsResolve(void 0);
|
|
2650
|
-
return;
|
|
2651
|
-
}
|
|
2652
2669
|
const dtsManagerOptions = normalizeConsumeTypesOptions({
|
|
2653
2670
|
context: compiler.context,
|
|
2654
2671
|
dtsOptions,
|
|
@@ -2658,6 +2675,10 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2658
2675
|
fetchRemoteTypeUrlsResolve(void 0);
|
|
2659
2676
|
return;
|
|
2660
2677
|
}
|
|
2678
|
+
if (isPrd() && !dtsManagerOptions.host.typesOnBuild) {
|
|
2679
|
+
fetchRemoteTypeUrlsResolve(void 0);
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2661
2682
|
import_sdk8.logger.debug("start fetching remote types...");
|
|
2662
2683
|
const promise = consumeTypesAPI(dtsManagerOptions, fetchRemoteTypeUrlsResolve);
|
|
2663
2684
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
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.17.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.17.0",
|
|
64
|
+
"@module-federation/managers": "0.17.0",
|
|
65
|
+
"@module-federation/third-party-dts-extractor": "0.17.0",
|
|
66
|
+
"@module-federation/error-codes": "0.17.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.17.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"typescript": "^4.9.0 || ^5.0.0",
|