@module-federation/dts-plugin 0.2.6 → 0.2.8
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 +172 -100
- package/dist/esm/{chunk-CRKFI32N.js → chunk-2RCHPGBO.js} +166 -94
- 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 +176 -104
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +169 -97
- package/dist/index.js +191 -120
- 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,120 @@ 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
|
+
ensureDirSync(mfeTypeEntryDirectory);
|
|
112
|
+
yield writeFile(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
113
|
+
export { default } from './${relativePathToOutput}';`);
|
|
114
|
+
}
|
|
115
|
+
const content = yield readFile(filePath, "utf8");
|
|
116
|
+
cb(content);
|
|
117
|
+
}
|
|
118
|
+
}), "processTypesFile");
|
|
119
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
120
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const { compilerOptions } = tsConfig;
|
|
124
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
|
|
125
|
+
try {
|
|
126
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
127
|
+
const thirdPartyExtractor = new ThirdPartyExtractor(resolve(mfTypePath, "node_modules"), remoteOptions.context);
|
|
128
|
+
const execPromise = util.promisify(exec);
|
|
129
|
+
const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
|
|
130
|
+
try {
|
|
131
|
+
yield execPromise(cmd);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
throw new Error(`compile TS failed, the original command is '${cmd}'`);
|
|
134
|
+
}
|
|
135
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
136
|
+
const normalizedFileName = normalize(filename);
|
|
137
|
+
let relativeFileName = "";
|
|
138
|
+
if (isAbsolute(normalizedFileName)) {
|
|
139
|
+
relativeFileName = relative(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
140
|
+
} else {
|
|
141
|
+
relativeFileName = relative(tsConfig.compilerOptions.rootDir, resolve(remoteOptions.context, normalizedFileName));
|
|
92
142
|
}
|
|
143
|
+
return [
|
|
144
|
+
removeExt(relativeFileName),
|
|
145
|
+
exposed
|
|
146
|
+
];
|
|
147
|
+
}));
|
|
148
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
149
|
+
yield processTypesFile({
|
|
150
|
+
outDir: compilerOptions.outDir,
|
|
151
|
+
filePath: compilerOptions.outDir,
|
|
152
|
+
rootDir: compilerOptions.rootDir,
|
|
153
|
+
mfTypePath,
|
|
154
|
+
cb,
|
|
155
|
+
mapExposeToEntry
|
|
156
|
+
});
|
|
157
|
+
if (remoteOptions.extractThirdParty) {
|
|
158
|
+
yield thirdPartyExtractor.copyDts();
|
|
93
159
|
}
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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();
|
|
160
|
+
yield rm(tempTsConfigJsonPath);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
if (isDebugMode()) {
|
|
163
|
+
console.log("tsconfig: ", JSON.stringify(tsConfig, null, 2));
|
|
164
|
+
}
|
|
165
|
+
throw err;
|
|
130
166
|
}
|
|
131
|
-
}, "compileTs");
|
|
167
|
+
}), "compileTs");
|
|
132
168
|
|
|
133
169
|
// packages/dts-plugin/src/server/message/API/API.ts
|
|
134
170
|
var APIKind;
|
|
@@ -1435,7 +1471,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1435
1471
|
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1436
1472
|
try {
|
|
1437
1473
|
if (hostOptions.deleteTypesFolder) {
|
|
1438
|
-
yield
|
|
1474
|
+
yield rm2(destinationPath, {
|
|
1439
1475
|
recursive: true,
|
|
1440
1476
|
force: true
|
|
1441
1477
|
});
|
|
@@ -1615,12 +1651,12 @@ var DTSManager = (_a = class {
|
|
|
1615
1651
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1616
1652
|
return;
|
|
1617
1653
|
}
|
|
1618
|
-
this.extractRemoteTypes({
|
|
1654
|
+
yield this.extractRemoteTypes({
|
|
1619
1655
|
remoteOptions,
|
|
1620
1656
|
tsConfig,
|
|
1621
1657
|
mapComponentsToExpose
|
|
1622
1658
|
});
|
|
1623
|
-
compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1659
|
+
yield compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1624
1660
|
yield createTypesArchive(tsConfig, remoteOptions);
|
|
1625
1661
|
let apiTypesPath = "";
|
|
1626
1662
|
if (remoteOptions.generateAPITypes) {
|
|
@@ -1630,7 +1666,7 @@ var DTSManager = (_a = class {
|
|
|
1630
1666
|
}
|
|
1631
1667
|
try {
|
|
1632
1668
|
if (remoteOptions.deleteTypesFolder) {
|
|
1633
|
-
yield
|
|
1669
|
+
yield rm3(retrieveMfTypesPath(tsConfig, remoteOptions), {
|
|
1634
1670
|
recursive: true,
|
|
1635
1671
|
force: true
|
|
1636
1672
|
});
|
|
@@ -1640,10 +1676,10 @@ var DTSManager = (_a = class {
|
|
|
1640
1676
|
console.error(err);
|
|
1641
1677
|
}
|
|
1642
1678
|
}
|
|
1643
|
-
console.log(
|
|
1679
|
+
console.log(ansiColors.green("Federated types created correctly"));
|
|
1644
1680
|
} catch (error2) {
|
|
1645
1681
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1646
|
-
console.error(
|
|
1682
|
+
console.error(ansiColors.red(`Unable to compile federated types, ${error2}`));
|
|
1647
1683
|
} else {
|
|
1648
1684
|
throw error2;
|
|
1649
1685
|
}
|
|
@@ -1815,7 +1851,7 @@ var DTSManager = (_a = class {
|
|
|
1815
1851
|
})));
|
|
1816
1852
|
this.consumeAPITypes(hostOptions);
|
|
1817
1853
|
}
|
|
1818
|
-
console.log(
|
|
1854
|
+
console.log(ansiColors.green("Federated types extraction completed"));
|
|
1819
1855
|
} catch (err) {
|
|
1820
1856
|
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1821
1857
|
fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
|
|
@@ -1836,7 +1872,7 @@ var DTSManager = (_a = class {
|
|
|
1836
1872
|
if (!this.options.remote) {
|
|
1837
1873
|
return;
|
|
1838
1874
|
}
|
|
1839
|
-
this.generateTypes();
|
|
1875
|
+
yield this.generateTypes();
|
|
1840
1876
|
} else {
|
|
1841
1877
|
const { remoteAliasMap } = this;
|
|
1842
1878
|
if (!this.options.host) {
|
|
@@ -1928,7 +1964,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1928
1964
|
apiFileName: path3.basename(apiTypesPath)
|
|
1929
1965
|
};
|
|
1930
1966
|
} catch (err) {
|
|
1931
|
-
console.error(
|
|
1967
|
+
console.error(ansiColors2.red(`Unable to compile federated types, ${err}`));
|
|
1932
1968
|
return {
|
|
1933
1969
|
apiTypesPath: "",
|
|
1934
1970
|
zipTypesPath: "",
|
|
@@ -1994,20 +2030,56 @@ var defaultOptions2 = {
|
|
|
1994
2030
|
extractRemoteTypes: false,
|
|
1995
2031
|
extractThirdParty: false
|
|
1996
2032
|
};
|
|
1997
|
-
|
|
2033
|
+
function getEffectiveRootDir(parsedCommandLine) {
|
|
2034
|
+
const compilerOptions = parsedCommandLine.options;
|
|
2035
|
+
if (compilerOptions.rootDir) {
|
|
2036
|
+
return compilerOptions.rootDir;
|
|
2037
|
+
}
|
|
2038
|
+
const files = parsedCommandLine.fileNames;
|
|
2039
|
+
if (files.length > 0) {
|
|
2040
|
+
const commonRoot = files.map((file) => dirname2(file)).reduce((commonPath, fileDir) => {
|
|
2041
|
+
while (!fileDir.startsWith(commonPath)) {
|
|
2042
|
+
commonPath = dirname2(commonPath);
|
|
2043
|
+
}
|
|
2044
|
+
return commonPath;
|
|
2045
|
+
}, files[0]);
|
|
2046
|
+
return commonRoot;
|
|
2047
|
+
}
|
|
2048
|
+
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
2049
|
+
}
|
|
2050
|
+
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
2051
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
|
|
1998
2052
|
const resolvedTsConfigPath = resolve3(context, tsConfigPath);
|
|
1999
|
-
const readResult =
|
|
2053
|
+
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
2000
2054
|
if (readResult.error) {
|
|
2001
2055
|
throw new Error(readResult.error.messageText.toString());
|
|
2002
2056
|
}
|
|
2003
|
-
const
|
|
2057
|
+
const rawTsConfigJson = readResult.config;
|
|
2058
|
+
const configContent = typescript.parseJsonConfigFileContent(rawTsConfigJson, typescript.sys, dirname2(resolvedTsConfigPath));
|
|
2059
|
+
const rootDir = getEffectiveRootDir(configContent);
|
|
2004
2060
|
const outDir = resolve3(context, configContent.options.outDir || "dist", typesFolder, compiledTypesFolder);
|
|
2005
|
-
|
|
2061
|
+
const defaultCompilerOptions = {
|
|
2062
|
+
rootDir,
|
|
2006
2063
|
emitDeclarationOnly: true,
|
|
2007
2064
|
noEmit: false,
|
|
2008
2065
|
declaration: true,
|
|
2009
2066
|
outDir
|
|
2010
|
-
}
|
|
2067
|
+
};
|
|
2068
|
+
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
2069
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
2070
|
+
const filesToCompile = [
|
|
2071
|
+
...Object.values(mapComponentsToExpose),
|
|
2072
|
+
...additionalFilesToCompile
|
|
2073
|
+
];
|
|
2074
|
+
rawTsConfigJson.include = [];
|
|
2075
|
+
rawTsConfigJson.files = filesToCompile;
|
|
2076
|
+
rawTsConfigJson.exclude = [];
|
|
2077
|
+
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2078
|
+
const extendsPath = rawTsConfigJson.extends;
|
|
2079
|
+
if (extendsPath && extendsPath.startsWith(".")) {
|
|
2080
|
+
rawTsConfigJson.extends = resolve3(context, extendsPath);
|
|
2081
|
+
}
|
|
2082
|
+
return rawTsConfigJson;
|
|
2011
2083
|
}, "readTsConfig");
|
|
2012
2084
|
var TS_EXTENSIONS = [
|
|
2013
2085
|
"ts",
|
|
@@ -2016,12 +2088,12 @@ var TS_EXTENSIONS = [
|
|
|
2016
2088
|
"svelte"
|
|
2017
2089
|
];
|
|
2018
2090
|
var resolveWithExtension = /* @__PURE__ */ __name((exposedPath, context) => {
|
|
2019
|
-
if (
|
|
2091
|
+
if (extname2(exposedPath)) {
|
|
2020
2092
|
return resolve3(context, exposedPath);
|
|
2021
2093
|
}
|
|
2022
2094
|
for (const extension of TS_EXTENSIONS) {
|
|
2023
2095
|
const exposedPathWithExtension = resolve3(context, `${exposedPath}.${extension}`);
|
|
2024
|
-
if (
|
|
2096
|
+
if (existsSync2(exposedPathWithExtension)) {
|
|
2025
2097
|
return exposedPathWithExtension;
|
|
2026
2098
|
}
|
|
2027
2099
|
}
|
|
@@ -2045,7 +2117,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
2045
2117
|
validateOptions(options);
|
|
2046
2118
|
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
2047
2119
|
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
2048
|
-
const tsConfig = readTsConfig(remoteOptions);
|
|
2120
|
+
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
2049
2121
|
return {
|
|
2050
2122
|
tsConfig,
|
|
2051
2123
|
mapComponentsToExpose,
|
|
@@ -2231,7 +2303,7 @@ __name(wrapRpc, "wrapRpc");
|
|
|
2231
2303
|
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
2232
2304
|
import * as child_process from "child_process";
|
|
2233
2305
|
import * as process3 from "process";
|
|
2234
|
-
import { randomUUID } from "crypto";
|
|
2306
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
2235
2307
|
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
2236
2308
|
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
2237
2309
|
const options = {
|
|
@@ -2252,7 +2324,7 @@ function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
|
2252
2324
|
];
|
|
2253
2325
|
}
|
|
2254
2326
|
let childProcess, remoteMethod;
|
|
2255
|
-
const id =
|
|
2327
|
+
const id = randomUUID2();
|
|
2256
2328
|
const worker = {
|
|
2257
2329
|
connect(...args) {
|
|
2258
2330
|
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-2RCHPGBO.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);
|