@module-federation/dts-plugin 0.2.5 → 0.2.7
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 +19 -0
- package/dist/{DtsWorker-7113d2b0.d.ts → DtsWorker-90454949.d.ts} +11 -3
- package/dist/core.d.mts +5 -5
- package/dist/core.d.ts +5 -5
- package/dist/core.js +167 -99
- package/dist/esm/{chunk-CRKFI32N.js → chunk-ZLQBXHXA.js} +161 -93
- package/dist/esm/core.js +1 -1
- package/dist/esm/fork-dev-worker.js +1 -1
- package/dist/esm/fork-generate-dts.js +1 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/start-broker.js +1 -1
- package/dist/fork-dev-worker.js +171 -103
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +164 -96
- package/dist/index.js +186 -119
- package/dist/package.json +6 -3
- package/dist/start-broker.js +11 -11
- package/package.json +9 -6
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
} from "./chunk-MQRIERJP.js";
|
|
27
27
|
|
|
28
28
|
// packages/dts-plugin/src/core/configurations/remotePlugin.ts
|
|
29
|
-
import { existsSync } from "fs";
|
|
30
|
-
import { dirname as dirname2, join as join3, resolve as resolve3, extname } from "path";
|
|
29
|
+
import { existsSync as existsSync2 } from "fs";
|
|
30
|
+
import { dirname as dirname2, join as join3, resolve as resolve3, extname as extname2 } from "path";
|
|
31
31
|
import { utils as utils2 } from "@module-federation/managers";
|
|
32
|
-
import
|
|
32
|
+
import typescript from "typescript";
|
|
33
33
|
|
|
34
34
|
// packages/dts-plugin/src/core/lib/utils.ts
|
|
35
35
|
import fs3 from "fs";
|
|
@@ -37,12 +37,12 @@ import path3 from "path";
|
|
|
37
37
|
import axios from "axios";
|
|
38
38
|
import http from "http";
|
|
39
39
|
import https from "https";
|
|
40
|
-
import
|
|
40
|
+
import ansiColors2 from "ansi-colors";
|
|
41
41
|
|
|
42
42
|
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
43
|
-
import
|
|
43
|
+
import ansiColors from "ansi-colors";
|
|
44
44
|
import path2 from "path";
|
|
45
|
-
import { rm as
|
|
45
|
+
import { rm as rm3 } from "fs/promises";
|
|
46
46
|
import fs2 from "fs";
|
|
47
47
|
import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
|
|
48
48
|
import cloneDeepWith from "lodash.clonedeepwith";
|
|
@@ -51,84 +51,116 @@ import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/
|
|
|
51
51
|
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
52
52
|
import AdmZip from "adm-zip";
|
|
53
53
|
import { resolve as resolve2, join as join2 } from "path";
|
|
54
|
-
import { rm } from "fs/promises";
|
|
54
|
+
import { rm as rm2 } from "fs/promises";
|
|
55
55
|
|
|
56
56
|
// packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
|
|
57
|
-
import
|
|
58
|
-
import {
|
|
59
|
-
import
|
|
57
|
+
import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
|
|
58
|
+
import { stat, readdir, writeFile, rm, readFile } from "fs/promises";
|
|
59
|
+
import { randomUUID } from "crypto";
|
|
60
|
+
import { dirname, join, normalize, relative, resolve, sep, extname, isAbsolute } from "path";
|
|
60
61
|
import { ThirdPartyExtractor } from "@module-federation/third-party-dts-extractor";
|
|
62
|
+
import { exec } from "child_process";
|
|
63
|
+
import util from "util";
|
|
64
|
+
import { TEMP_DIR } from "@module-federation/sdk";
|
|
61
65
|
var STARTS_WITH_SLASH = /^\//;
|
|
62
66
|
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
console.error(ansiColors.red(`TS Error ${diagnostic.code}':' ${typescript.flattenDiagnosticMessageText(diagnostic.messageText, typescript.sys.newLine)}`));
|
|
66
|
-
console.error(ansiColors.red(` at ${diagnostic.file.fileName}:${line + 1} typescript.sys.newLine`));
|
|
67
|
-
}, "reportCompileDiagnostic");
|
|
68
|
-
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
69
|
-
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
67
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
68
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
70
69
|
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => join(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
function writeTempTsConfig(tsConfig, context) {
|
|
71
|
+
const tempTsConfigJsonPath = resolve(context, "node_modules", TEMP_DIR, `tsconfig.${randomUUID()}.json`);
|
|
72
|
+
ensureDirSync(dirname(tempTsConfigJsonPath));
|
|
73
|
+
writeFileSync(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
74
|
+
return tempTsConfigJsonPath;
|
|
75
|
+
}
|
|
76
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
77
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
78
|
+
const ext = extname(f);
|
|
79
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
80
|
+
return f.replace(regexPattern, "");
|
|
81
|
+
}, "removeExt");
|
|
82
|
+
function getExposeKey(options) {
|
|
83
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
84
|
+
const relativeFilePath = removeExt(relative(outDir, filePath.replace(new RegExp(`\\.d.ts$`), "")));
|
|
85
|
+
return mapExposeToEntry[relativeFilePath];
|
|
86
|
+
}
|
|
87
|
+
__name(getExposeKey, "getExposeKey");
|
|
88
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
89
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
90
|
+
if (!existsSync(filePath)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const stats = yield stat(filePath);
|
|
94
|
+
if (stats.isDirectory()) {
|
|
95
|
+
const files = yield readdir(filePath);
|
|
96
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
97
|
+
filePath: join(filePath, file)
|
|
98
|
+
}))));
|
|
99
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
100
|
+
const exposeKey = getExposeKey({
|
|
101
|
+
filePath,
|
|
102
|
+
rootDir,
|
|
103
|
+
outDir,
|
|
104
|
+
mapExposeToEntry
|
|
105
|
+
});
|
|
106
|
+
if (exposeKey) {
|
|
107
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
108
|
+
const mfeTypeEntry = join(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
109
|
+
const mfeTypeEntryDirectory = dirname(mfeTypeEntry);
|
|
110
|
+
const relativePathToOutput = relative(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(sep).join("/");
|
|
111
|
+
yield writeFile(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
112
|
+
export { default } from './${relativePathToOutput}';`);
|
|
113
|
+
}
|
|
114
|
+
const content = yield readFile(filePath, "utf8");
|
|
115
|
+
cb(content);
|
|
116
|
+
}
|
|
117
|
+
}), "processTypesFile");
|
|
118
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
119
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const { compilerOptions } = tsConfig;
|
|
123
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
|
|
124
|
+
try {
|
|
125
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
126
|
+
const thirdPartyExtractor = new ThirdPartyExtractor(resolve(mfTypePath, "node_modules"), remoteOptions.context);
|
|
127
|
+
const execPromise = util.promisify(exec);
|
|
128
|
+
const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
|
|
129
|
+
try {
|
|
130
|
+
yield execPromise(cmd);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
throw new Error(`compile TS failed, the original command is '${cmd}'`);
|
|
133
|
+
}
|
|
134
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
135
|
+
const normalizedFileName = normalize(filename);
|
|
136
|
+
let relativeFileName = "";
|
|
137
|
+
if (isAbsolute(normalizedFileName)) {
|
|
138
|
+
relativeFileName = relative(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
139
|
+
} else {
|
|
140
|
+
relativeFileName = relative(tsConfig.compilerOptions.rootDir, resolve(remoteOptions.context, normalizedFileName));
|
|
92
141
|
}
|
|
142
|
+
return [
|
|
143
|
+
removeExt(relativeFileName),
|
|
144
|
+
exposed
|
|
145
|
+
];
|
|
146
|
+
}));
|
|
147
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
148
|
+
yield processTypesFile({
|
|
149
|
+
outDir: compilerOptions.outDir,
|
|
150
|
+
filePath: compilerOptions.outDir,
|
|
151
|
+
rootDir: compilerOptions.rootDir,
|
|
152
|
+
mfTypePath,
|
|
153
|
+
cb,
|
|
154
|
+
mapExposeToEntry
|
|
155
|
+
});
|
|
156
|
+
if (remoteOptions.extractThirdParty) {
|
|
157
|
+
yield thirdPartyExtractor.copyDts();
|
|
93
158
|
}
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}, "createHost");
|
|
98
|
-
var createVueTscProgram = /* @__PURE__ */ __name((programOptions) => {
|
|
99
|
-
const vueTypescript = __require("vue-tsc");
|
|
100
|
-
return vueTypescript.createProgram(programOptions);
|
|
101
|
-
}, "createVueTscProgram");
|
|
102
|
-
var createProgram = /* @__PURE__ */ __name((remoteOptions, programOptions) => {
|
|
103
|
-
switch (remoteOptions.compilerInstance) {
|
|
104
|
-
case "vue-tsc":
|
|
105
|
-
return createVueTscProgram(programOptions);
|
|
106
|
-
case "tsc":
|
|
107
|
-
default:
|
|
108
|
-
return typescript.createProgram(programOptions);
|
|
109
|
-
}
|
|
110
|
-
}, "createProgram");
|
|
111
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => {
|
|
112
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
113
|
-
const thirdPartyExtractor = new ThirdPartyExtractor(resolve(mfTypePath, "node_modules"), remoteOptions.context);
|
|
114
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
115
|
-
const tsHost = createHost(mapComponentsToExpose, tsConfig, remoteOptions, cb);
|
|
116
|
-
const filesToCompile = [
|
|
117
|
-
...Object.values(mapComponentsToExpose),
|
|
118
|
-
...remoteOptions.additionalFilesToCompile
|
|
119
|
-
];
|
|
120
|
-
const programOptions = {
|
|
121
|
-
rootNames: filesToCompile,
|
|
122
|
-
host: tsHost,
|
|
123
|
-
options: tsConfig
|
|
124
|
-
};
|
|
125
|
-
const tsProgram = createProgram(remoteOptions, programOptions);
|
|
126
|
-
const { diagnostics = [] } = tsProgram.emit();
|
|
127
|
-
diagnostics.forEach(reportCompileDiagnostic);
|
|
128
|
-
if (remoteOptions.extractThirdParty) {
|
|
129
|
-
thirdPartyExtractor.copyDts();
|
|
159
|
+
yield rm(tempTsConfigJsonPath);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
throw err;
|
|
130
162
|
}
|
|
131
|
-
}, "compileTs");
|
|
163
|
+
}), "compileTs");
|
|
132
164
|
|
|
133
165
|
// packages/dts-plugin/src/server/message/API/API.ts
|
|
134
166
|
var APIKind;
|
|
@@ -1435,7 +1467,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1435
1467
|
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1436
1468
|
try {
|
|
1437
1469
|
if (hostOptions.deleteTypesFolder) {
|
|
1438
|
-
yield
|
|
1470
|
+
yield rm2(destinationPath, {
|
|
1439
1471
|
recursive: true,
|
|
1440
1472
|
force: true
|
|
1441
1473
|
});
|
|
@@ -1620,7 +1652,7 @@ var DTSManager = (_a = class {
|
|
|
1620
1652
|
tsConfig,
|
|
1621
1653
|
mapComponentsToExpose
|
|
1622
1654
|
});
|
|
1623
|
-
compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1655
|
+
yield compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1624
1656
|
yield createTypesArchive(tsConfig, remoteOptions);
|
|
1625
1657
|
let apiTypesPath = "";
|
|
1626
1658
|
if (remoteOptions.generateAPITypes) {
|
|
@@ -1630,7 +1662,7 @@ var DTSManager = (_a = class {
|
|
|
1630
1662
|
}
|
|
1631
1663
|
try {
|
|
1632
1664
|
if (remoteOptions.deleteTypesFolder) {
|
|
1633
|
-
yield
|
|
1665
|
+
yield rm3(retrieveMfTypesPath(tsConfig, remoteOptions), {
|
|
1634
1666
|
recursive: true,
|
|
1635
1667
|
force: true
|
|
1636
1668
|
});
|
|
@@ -1640,10 +1672,10 @@ var DTSManager = (_a = class {
|
|
|
1640
1672
|
console.error(err);
|
|
1641
1673
|
}
|
|
1642
1674
|
}
|
|
1643
|
-
console.log(
|
|
1675
|
+
console.log(ansiColors.green("Federated types created correctly"));
|
|
1644
1676
|
} catch (error2) {
|
|
1645
1677
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1646
|
-
console.error(
|
|
1678
|
+
console.error(ansiColors.red(`Unable to compile federated types, ${error2}`));
|
|
1647
1679
|
} else {
|
|
1648
1680
|
throw error2;
|
|
1649
1681
|
}
|
|
@@ -1815,7 +1847,7 @@ var DTSManager = (_a = class {
|
|
|
1815
1847
|
})));
|
|
1816
1848
|
this.consumeAPITypes(hostOptions);
|
|
1817
1849
|
}
|
|
1818
|
-
console.log(
|
|
1850
|
+
console.log(ansiColors.green("Federated types extraction completed"));
|
|
1819
1851
|
} catch (err) {
|
|
1820
1852
|
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1821
1853
|
fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
|
|
@@ -1836,7 +1868,7 @@ var DTSManager = (_a = class {
|
|
|
1836
1868
|
if (!this.options.remote) {
|
|
1837
1869
|
return;
|
|
1838
1870
|
}
|
|
1839
|
-
this.generateTypes();
|
|
1871
|
+
yield this.generateTypes();
|
|
1840
1872
|
} else {
|
|
1841
1873
|
const { remoteAliasMap } = this;
|
|
1842
1874
|
if (!this.options.host) {
|
|
@@ -1928,7 +1960,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1928
1960
|
apiFileName: path3.basename(apiTypesPath)
|
|
1929
1961
|
};
|
|
1930
1962
|
} catch (err) {
|
|
1931
|
-
console.error(
|
|
1963
|
+
console.error(ansiColors2.red(`Unable to compile federated types, ${err}`));
|
|
1932
1964
|
return {
|
|
1933
1965
|
apiTypesPath: "",
|
|
1934
1966
|
zipTypesPath: "",
|
|
@@ -1994,20 +2026,56 @@ var defaultOptions2 = {
|
|
|
1994
2026
|
extractRemoteTypes: false,
|
|
1995
2027
|
extractThirdParty: false
|
|
1996
2028
|
};
|
|
1997
|
-
|
|
2029
|
+
function getEffectiveRootDir(parsedCommandLine) {
|
|
2030
|
+
const compilerOptions = parsedCommandLine.options;
|
|
2031
|
+
if (compilerOptions.rootDir) {
|
|
2032
|
+
return compilerOptions.rootDir;
|
|
2033
|
+
}
|
|
2034
|
+
const files = parsedCommandLine.fileNames;
|
|
2035
|
+
if (files.length > 0) {
|
|
2036
|
+
const commonRoot = files.map((file) => dirname2(file)).reduce((commonPath, fileDir) => {
|
|
2037
|
+
while (!fileDir.startsWith(commonPath)) {
|
|
2038
|
+
commonPath = dirname2(commonPath);
|
|
2039
|
+
}
|
|
2040
|
+
return commonPath;
|
|
2041
|
+
}, files[0]);
|
|
2042
|
+
return commonRoot;
|
|
2043
|
+
}
|
|
2044
|
+
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
2045
|
+
}
|
|
2046
|
+
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
2047
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
|
|
1998
2048
|
const resolvedTsConfigPath = resolve3(context, tsConfigPath);
|
|
1999
|
-
const readResult =
|
|
2049
|
+
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
2000
2050
|
if (readResult.error) {
|
|
2001
2051
|
throw new Error(readResult.error.messageText.toString());
|
|
2002
2052
|
}
|
|
2003
|
-
const
|
|
2053
|
+
const rawTsConfigJson = readResult.config;
|
|
2054
|
+
const configContent = typescript.parseJsonConfigFileContent(rawTsConfigJson, typescript.sys, dirname2(resolvedTsConfigPath));
|
|
2055
|
+
const rootDir = getEffectiveRootDir(configContent);
|
|
2004
2056
|
const outDir = resolve3(context, configContent.options.outDir || "dist", typesFolder, compiledTypesFolder);
|
|
2005
|
-
|
|
2057
|
+
const defaultCompilerOptions = {
|
|
2058
|
+
rootDir,
|
|
2006
2059
|
emitDeclarationOnly: true,
|
|
2007
2060
|
noEmit: false,
|
|
2008
2061
|
declaration: true,
|
|
2009
2062
|
outDir
|
|
2010
|
-
}
|
|
2063
|
+
};
|
|
2064
|
+
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
2065
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
2066
|
+
const filesToCompile = [
|
|
2067
|
+
...Object.values(mapComponentsToExpose),
|
|
2068
|
+
...additionalFilesToCompile
|
|
2069
|
+
];
|
|
2070
|
+
rawTsConfigJson.include = [];
|
|
2071
|
+
rawTsConfigJson.files = filesToCompile;
|
|
2072
|
+
rawTsConfigJson.exclude = [];
|
|
2073
|
+
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2074
|
+
const extendsPath = rawTsConfigJson.extends;
|
|
2075
|
+
if (extendsPath && extendsPath.startsWith(".")) {
|
|
2076
|
+
rawTsConfigJson.extends = resolve3(context, extendsPath);
|
|
2077
|
+
}
|
|
2078
|
+
return rawTsConfigJson;
|
|
2011
2079
|
}, "readTsConfig");
|
|
2012
2080
|
var TS_EXTENSIONS = [
|
|
2013
2081
|
"ts",
|
|
@@ -2016,12 +2084,12 @@ var TS_EXTENSIONS = [
|
|
|
2016
2084
|
"svelte"
|
|
2017
2085
|
];
|
|
2018
2086
|
var resolveWithExtension = /* @__PURE__ */ __name((exposedPath, context) => {
|
|
2019
|
-
if (
|
|
2087
|
+
if (extname2(exposedPath)) {
|
|
2020
2088
|
return resolve3(context, exposedPath);
|
|
2021
2089
|
}
|
|
2022
2090
|
for (const extension of TS_EXTENSIONS) {
|
|
2023
2091
|
const exposedPathWithExtension = resolve3(context, `${exposedPath}.${extension}`);
|
|
2024
|
-
if (
|
|
2092
|
+
if (existsSync2(exposedPathWithExtension)) {
|
|
2025
2093
|
return exposedPathWithExtension;
|
|
2026
2094
|
}
|
|
2027
2095
|
}
|
|
@@ -2045,7 +2113,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
2045
2113
|
validateOptions(options);
|
|
2046
2114
|
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
2047
2115
|
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
2048
|
-
const tsConfig = readTsConfig(remoteOptions);
|
|
2116
|
+
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
2049
2117
|
return {
|
|
2050
2118
|
tsConfig,
|
|
2051
2119
|
mapComponentsToExpose,
|
|
@@ -2231,7 +2299,7 @@ __name(wrapRpc, "wrapRpc");
|
|
|
2231
2299
|
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
2232
2300
|
import * as child_process from "child_process";
|
|
2233
2301
|
import * as process3 from "process";
|
|
2234
|
-
import { randomUUID } from "crypto";
|
|
2302
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
2235
2303
|
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
2236
2304
|
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
2237
2305
|
const options = {
|
|
@@ -2252,7 +2320,7 @@ function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
|
2252
2320
|
];
|
|
2253
2321
|
}
|
|
2254
2322
|
let childProcess, remoteMethod;
|
|
2255
|
-
const id =
|
|
2323
|
+
const id = randomUUID2();
|
|
2256
2324
|
const worker = {
|
|
2257
2325
|
connect(...args) {
|
|
2258
2326
|
if (childProcess && !childProcess.connected) {
|
package/dist/esm/core.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
retrieveTypesAssetsInfo,
|
|
8
8
|
rpc_exports,
|
|
9
9
|
validateOptions
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZLQBXHXA.js";
|
|
11
11
|
import {
|
|
12
12
|
WEB_CLIENT_OPTIONS_IDENTIFIER,
|
|
13
13
|
__async,
|
|
@@ -89,7 +89,7 @@ function createDevWorker(options) {
|
|
|
89
89
|
__name(createDevWorker, "createDevWorker");
|
|
90
90
|
|
|
91
91
|
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
92
|
-
import { normalizeOptions } from "@module-federation/sdk";
|
|
92
|
+
import { normalizeOptions, TEMP_DIR as BasicTempDir } from "@module-federation/sdk";
|
|
93
93
|
import path3 from "path";
|
|
94
94
|
|
|
95
95
|
// packages/dts-plugin/src/plugins/utils.ts
|
|
@@ -182,7 +182,7 @@ var _DevPlugin = class _DevPlugin {
|
|
|
182
182
|
this._options.runtimePlugins.push(path3.resolve(__dirname, "dynamic-remote-type-hints-plugin.js"));
|
|
183
183
|
}
|
|
184
184
|
if (!normalizedDev.disableLiveReload) {
|
|
185
|
-
const TEMP_DIR = path3.join(`${process.cwd()}/node_modules`,
|
|
185
|
+
const TEMP_DIR = path3.join(`${process.cwd()}/node_modules`, BasicTempDir);
|
|
186
186
|
const filepath = path3.join(TEMP_DIR, `live-reload.js`);
|
|
187
187
|
_DevPlugin.ensureLiveReloadEntry({
|
|
188
188
|
name
|
|
@@ -341,10 +341,9 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
341
341
|
yield generateTypesFn(finalOptions);
|
|
342
342
|
const config = finalOptions.remote.moduleFederationConfig;
|
|
343
343
|
let zipPrefix = "";
|
|
344
|
-
|
|
345
|
-
if (isManifestObject && config.manifest.filePath) {
|
|
344
|
+
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
346
345
|
zipPrefix = config.manifest.filePath;
|
|
347
|
-
} else if (
|
|
346
|
+
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
|
|
348
347
|
zipPrefix = path4.dirname(config.manifest.fileName);
|
|
349
348
|
} else if (config.filename) {
|
|
350
349
|
zipPrefix = path4.dirname(config.filename);
|