@module-federation/dts-plugin 0.21.4 → 0.21.5
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 +13 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +160 -163
- package/dist/esm/{chunk-OEN3DGLA.js → chunk-N7GTIQUA.js} +1 -1
- package/dist/esm/{chunk-JGZ276AJ.js → chunk-RWXNVNFM.js} +164 -169
- 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 -19
- package/dist/fork-dev-worker.js +167 -158
- package/dist/fork-generate-dts.js +160 -151
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +166 -180
- package/dist/package.json +1 -1
- package/dist/{utils-BjKKtOcx.d.ts → utils-DxGrqb9N.d.ts} +0 -1
- package/package.json +6 -6
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.21.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f8ff0d8: fix(dts-plugin): api type file should not related with manifest config
|
|
8
|
+
- 9dfcbb3: fix(dts-plugin): delete compilerOptions.declarationDir
|
|
9
|
+
- 2fc4050: feat(dts-plugin): add dts.generateTypes.deleteTsConfig field
|
|
10
|
+
- Updated dependencies [94d8868]
|
|
11
|
+
- @module-federation/sdk@0.21.5
|
|
12
|
+
- @module-federation/managers@0.21.5
|
|
13
|
+
- @module-federation/third-party-dts-extractor@0.21.5
|
|
14
|
+
- @module-federation/error-codes@0.21.5
|
|
15
|
+
|
|
3
16
|
## 0.21.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/core.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
|
|
2
2
|
export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-
|
|
4
|
+
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-DxGrqb9N.js';
|
|
5
5
|
import { R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-BrHsGz8C.js';
|
|
6
6
|
export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
|
|
7
7
|
import { ChildProcess } from 'child_process';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
|
|
2
2
|
export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-
|
|
4
|
+
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-DxGrqb9N.js';
|
|
5
5
|
import { R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-BrHsGz8C.js';
|
|
6
6
|
export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
|
|
7
7
|
import { ChildProcess } from 'child_process';
|
package/dist/core.js
CHANGED
|
@@ -133,7 +133,7 @@ var import_path2 = require("path");
|
|
|
133
133
|
var import_promises2 = require("fs/promises");
|
|
134
134
|
|
|
135
135
|
// src/core/lib/typeScriptCompiler.ts
|
|
136
|
-
var
|
|
136
|
+
var import_fs_extra2 = require("fs-extra");
|
|
137
137
|
var import_crypto = __toESM(require("crypto"));
|
|
138
138
|
var import_promises = require("fs/promises");
|
|
139
139
|
var import_path = require("path");
|
|
@@ -141,150 +141,7 @@ var import_error_codes = require("@module-federation/error-codes");
|
|
|
141
141
|
var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
|
|
142
142
|
var import_child_process = require("child_process");
|
|
143
143
|
var import_util = __toESM(require("util"));
|
|
144
|
-
var
|
|
145
|
-
var STARTS_WITH_SLASH = /^\//;
|
|
146
|
-
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
147
|
-
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
148
|
-
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
149
|
-
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
150
|
-
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
151
|
-
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
152
|
-
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
153
|
-
}, "createHash");
|
|
154
|
-
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
155
|
-
const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
156
|
-
(0, import_fs_extra.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
|
|
157
|
-
(0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
158
|
-
return tempTsConfigJsonPath;
|
|
159
|
-
}
|
|
160
|
-
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
161
|
-
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
162
|
-
const vueExt = ".vue";
|
|
163
|
-
const ext = (0, import_path.extname)(f);
|
|
164
|
-
if (ext === vueExt) {
|
|
165
|
-
return f;
|
|
166
|
-
}
|
|
167
|
-
const regexPattern = new RegExp(`\\${ext}$`);
|
|
168
|
-
return f.replace(regexPattern, "");
|
|
169
|
-
}, "removeExt");
|
|
170
|
-
function getExposeKey(options) {
|
|
171
|
-
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
172
|
-
const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
173
|
-
return mapExposeToEntry[relativeFilePath];
|
|
174
|
-
}
|
|
175
|
-
__name(getExposeKey, "getExposeKey");
|
|
176
|
-
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
177
|
-
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
178
|
-
if (!(0, import_fs_extra.existsSync)(filePath)) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const stats = yield (0, import_promises.stat)(filePath);
|
|
182
|
-
if (stats.isDirectory()) {
|
|
183
|
-
const files = yield (0, import_promises.readdir)(filePath);
|
|
184
|
-
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
185
|
-
filePath: (0, import_path.join)(filePath, file)
|
|
186
|
-
}))));
|
|
187
|
-
} else if (filePath.endsWith(".d.ts")) {
|
|
188
|
-
const exposeKey = getExposeKey({
|
|
189
|
-
filePath,
|
|
190
|
-
rootDir,
|
|
191
|
-
outDir,
|
|
192
|
-
mapExposeToEntry
|
|
193
|
-
});
|
|
194
|
-
if (exposeKey) {
|
|
195
|
-
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
196
|
-
const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
197
|
-
const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
|
|
198
|
-
const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
|
|
199
|
-
(0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
|
|
200
|
-
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
201
|
-
export { default } from './${relativePathToOutput}';`);
|
|
202
|
-
}
|
|
203
|
-
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
204
|
-
cb(content);
|
|
205
|
-
}
|
|
206
|
-
}), "processTypesFile");
|
|
207
|
-
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
208
|
-
const userAgent = process.env["npm_config_user_agent"];
|
|
209
|
-
if (userAgent == null) {
|
|
210
|
-
return "null";
|
|
211
|
-
}
|
|
212
|
-
const name = userAgent.split("/")[0];
|
|
213
|
-
return name;
|
|
214
|
-
}, "getPMFromUserAgent");
|
|
215
|
-
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
216
|
-
const pm = getPMFromUserAgent();
|
|
217
|
-
switch (pm) {
|
|
218
|
-
case "yarn":
|
|
219
|
-
return "yarn";
|
|
220
|
-
case "npm":
|
|
221
|
-
case "pnpm":
|
|
222
|
-
default:
|
|
223
|
-
return "npx";
|
|
224
|
-
}
|
|
225
|
-
}, "resolvePackageManagerExecutable");
|
|
226
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
227
|
-
var _a3, _b, _c, _d;
|
|
228
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const { compilerOptions } = tsConfig;
|
|
232
|
-
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
|
|
233
|
-
try {
|
|
234
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
235
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
236
|
-
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
237
|
-
context: remoteOptions.context,
|
|
238
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
239
|
-
});
|
|
240
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
241
|
-
const pmExecutable = resolvePackageManagerExecutable();
|
|
242
|
-
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
243
|
-
try {
|
|
244
|
-
yield execPromise(cmd, {
|
|
245
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
246
|
-
});
|
|
247
|
-
} catch (err) {
|
|
248
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
249
|
-
try {
|
|
250
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
251
|
-
} catch (e) {
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
255
|
-
cmd
|
|
256
|
-
}));
|
|
257
|
-
}
|
|
258
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
259
|
-
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
260
|
-
let relativeFileName = "";
|
|
261
|
-
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
262
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
263
|
-
} else {
|
|
264
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
265
|
-
}
|
|
266
|
-
return [
|
|
267
|
-
removeExt(relativeFileName),
|
|
268
|
-
exposed
|
|
269
|
-
];
|
|
270
|
-
}));
|
|
271
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
272
|
-
yield processTypesFile({
|
|
273
|
-
outDir: compilerOptions.outDir,
|
|
274
|
-
filePath: compilerOptions.outDir,
|
|
275
|
-
rootDir: compilerOptions.rootDir,
|
|
276
|
-
mfTypePath,
|
|
277
|
-
cb,
|
|
278
|
-
mapExposeToEntry
|
|
279
|
-
});
|
|
280
|
-
if (remoteOptions.extractThirdParty) {
|
|
281
|
-
yield thirdPartyExtractor.copyDts();
|
|
282
|
-
}
|
|
283
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
284
|
-
} catch (err) {
|
|
285
|
-
throw err;
|
|
286
|
-
}
|
|
287
|
-
}), "compileTs");
|
|
144
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
288
145
|
|
|
289
146
|
// src/server/message/Message.ts
|
|
290
147
|
var _Message = class _Message {
|
|
@@ -357,7 +214,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
357
214
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
358
215
|
|
|
359
216
|
// src/server/utils/index.ts
|
|
360
|
-
var
|
|
217
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
361
218
|
|
|
362
219
|
// src/server/utils/logTransform.ts
|
|
363
220
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -396,7 +253,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
396
253
|
var BrokerExitLog = _BrokerExitLog;
|
|
397
254
|
|
|
398
255
|
// src/server/utils/log.ts
|
|
399
|
-
var
|
|
256
|
+
var import_sdk = require("@module-federation/sdk");
|
|
400
257
|
var log4js = __toESM(require("log4js"));
|
|
401
258
|
|
|
402
259
|
// src/server/constant.ts
|
|
@@ -410,7 +267,7 @@ var UpdateMode;
|
|
|
410
267
|
})(UpdateMode || (UpdateMode = {}));
|
|
411
268
|
|
|
412
269
|
// src/server/utils/log.ts
|
|
413
|
-
var logger = (0,
|
|
270
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
414
271
|
function fileLog(msg, module2, level) {
|
|
415
272
|
var _a3, _b;
|
|
416
273
|
if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
|
|
@@ -457,7 +314,7 @@ __name(error, "error");
|
|
|
457
314
|
// src/server/utils/index.ts
|
|
458
315
|
function getIdentifier(options) {
|
|
459
316
|
const { ip, name } = options;
|
|
460
|
-
return `mf ${
|
|
317
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
461
318
|
}
|
|
462
319
|
__name(getIdentifier, "getIdentifier");
|
|
463
320
|
|
|
@@ -1159,9 +1016,157 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1159
1016
|
var Broker = _Broker;
|
|
1160
1017
|
|
|
1161
1018
|
// src/server/createKoaServer.ts
|
|
1162
|
-
var
|
|
1019
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1163
1020
|
var import_koa = __toESM(require("koa"));
|
|
1164
1021
|
|
|
1022
|
+
// src/core/lib/typeScriptCompiler.ts
|
|
1023
|
+
var STARTS_WITH_SLASH = /^\//;
|
|
1024
|
+
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
1025
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
1026
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
1027
|
+
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
1028
|
+
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
1029
|
+
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
1030
|
+
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
1031
|
+
}, "createHash");
|
|
1032
|
+
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
1033
|
+
const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk3.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
1034
|
+
(0, import_fs_extra2.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
|
|
1035
|
+
(0, import_fs_extra2.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
1036
|
+
return tempTsConfigJsonPath;
|
|
1037
|
+
}
|
|
1038
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
1039
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
1040
|
+
const vueExt = ".vue";
|
|
1041
|
+
const ext = (0, import_path.extname)(f);
|
|
1042
|
+
if (ext === vueExt) {
|
|
1043
|
+
return f;
|
|
1044
|
+
}
|
|
1045
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
1046
|
+
return f.replace(regexPattern, "");
|
|
1047
|
+
}, "removeExt");
|
|
1048
|
+
function getExposeKey(options) {
|
|
1049
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
1050
|
+
const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
1051
|
+
return mapExposeToEntry[relativeFilePath];
|
|
1052
|
+
}
|
|
1053
|
+
__name(getExposeKey, "getExposeKey");
|
|
1054
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
1055
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
1056
|
+
if (!(0, import_fs_extra2.existsSync)(filePath)) {
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
const stats = yield (0, import_promises.stat)(filePath);
|
|
1060
|
+
if (stats.isDirectory()) {
|
|
1061
|
+
const files = yield (0, import_promises.readdir)(filePath);
|
|
1062
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
1063
|
+
filePath: (0, import_path.join)(filePath, file)
|
|
1064
|
+
}))));
|
|
1065
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
1066
|
+
const exposeKey = getExposeKey({
|
|
1067
|
+
filePath,
|
|
1068
|
+
rootDir,
|
|
1069
|
+
outDir,
|
|
1070
|
+
mapExposeToEntry
|
|
1071
|
+
});
|
|
1072
|
+
if (exposeKey) {
|
|
1073
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
1074
|
+
const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
1075
|
+
const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
|
|
1076
|
+
const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
|
|
1077
|
+
(0, import_fs_extra2.ensureDirSync)(mfeTypeEntryDirectory);
|
|
1078
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
1079
|
+
export { default } from './${relativePathToOutput}';`);
|
|
1080
|
+
}
|
|
1081
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
1082
|
+
cb(content);
|
|
1083
|
+
}
|
|
1084
|
+
}), "processTypesFile");
|
|
1085
|
+
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
1086
|
+
const userAgent = process.env["npm_config_user_agent"];
|
|
1087
|
+
if (userAgent == null) {
|
|
1088
|
+
return "null";
|
|
1089
|
+
}
|
|
1090
|
+
const name = userAgent.split("/")[0];
|
|
1091
|
+
return name;
|
|
1092
|
+
}, "getPMFromUserAgent");
|
|
1093
|
+
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
1094
|
+
const pm = getPMFromUserAgent();
|
|
1095
|
+
switch (pm) {
|
|
1096
|
+
case "yarn":
|
|
1097
|
+
return "yarn";
|
|
1098
|
+
case "npm":
|
|
1099
|
+
case "pnpm":
|
|
1100
|
+
default:
|
|
1101
|
+
return "npx";
|
|
1102
|
+
}
|
|
1103
|
+
}, "resolvePackageManagerExecutable");
|
|
1104
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
1105
|
+
var _a3, _b, _c, _d;
|
|
1106
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
const { compilerOptions } = tsConfig;
|
|
1110
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
|
|
1111
|
+
logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
|
|
1112
|
+
try {
|
|
1113
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1114
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
1115
|
+
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
1116
|
+
context: remoteOptions.context,
|
|
1117
|
+
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
1118
|
+
});
|
|
1119
|
+
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
1120
|
+
const pmExecutable = resolvePackageManagerExecutable();
|
|
1121
|
+
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
1122
|
+
try {
|
|
1123
|
+
yield execPromise(cmd, {
|
|
1124
|
+
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
1125
|
+
});
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
if (compilerOptions.tsBuildInfoFile) {
|
|
1128
|
+
try {
|
|
1129
|
+
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
1130
|
+
} catch (e) {
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
1134
|
+
cmd
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
1138
|
+
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
1139
|
+
let relativeFileName = "";
|
|
1140
|
+
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
1141
|
+
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
1142
|
+
} else {
|
|
1143
|
+
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
1144
|
+
}
|
|
1145
|
+
return [
|
|
1146
|
+
removeExt(relativeFileName),
|
|
1147
|
+
exposed
|
|
1148
|
+
];
|
|
1149
|
+
}));
|
|
1150
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
1151
|
+
yield processTypesFile({
|
|
1152
|
+
outDir: compilerOptions.outDir,
|
|
1153
|
+
filePath: compilerOptions.outDir,
|
|
1154
|
+
rootDir: compilerOptions.rootDir,
|
|
1155
|
+
mfTypePath,
|
|
1156
|
+
cb,
|
|
1157
|
+
mapExposeToEntry
|
|
1158
|
+
});
|
|
1159
|
+
if (remoteOptions.extractThirdParty) {
|
|
1160
|
+
yield thirdPartyExtractor.copyDts();
|
|
1161
|
+
}
|
|
1162
|
+
if (remoteOptions.deleteTsConfig) {
|
|
1163
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
1164
|
+
}
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
throw err;
|
|
1167
|
+
}
|
|
1168
|
+
}), "compileTs");
|
|
1169
|
+
|
|
1165
1170
|
// src/core/lib/archiveHandler.ts
|
|
1166
1171
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path2.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1167
1172
|
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
@@ -1775,15 +1780,12 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
|
|
|
1775
1780
|
}
|
|
1776
1781
|
}, "validateOptions");
|
|
1777
1782
|
function retrieveTypesAssetsInfo(options) {
|
|
1778
|
-
const { moduleFederationConfig } = options;
|
|
1779
1783
|
let apiTypesPath = "";
|
|
1780
1784
|
let zipTypesPath = "";
|
|
1781
|
-
let zipPrefix = "";
|
|
1782
1785
|
try {
|
|
1783
1786
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1784
1787
|
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1785
1788
|
return {
|
|
1786
|
-
zipPrefix,
|
|
1787
1789
|
apiTypesPath,
|
|
1788
1790
|
zipTypesPath,
|
|
1789
1791
|
zipName: "",
|
|
@@ -1795,15 +1797,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1795
1797
|
if (remoteOptions.generateAPITypes) {
|
|
1796
1798
|
apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
|
|
1797
1799
|
}
|
|
1798
|
-
if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.filePath) {
|
|
1799
|
-
zipPrefix = moduleFederationConfig.manifest.filePath;
|
|
1800
|
-
} else if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.fileName) {
|
|
1801
|
-
zipPrefix = import_path4.default.dirname(moduleFederationConfig.manifest.fileName);
|
|
1802
|
-
} else if (moduleFederationConfig.filename) {
|
|
1803
|
-
zipPrefix = import_path4.default.dirname(moduleFederationConfig.filename);
|
|
1804
|
-
}
|
|
1805
1800
|
return {
|
|
1806
|
-
zipPrefix,
|
|
1807
1801
|
apiTypesPath,
|
|
1808
1802
|
zipTypesPath,
|
|
1809
1803
|
zipName: import_path4.default.basename(zipTypesPath),
|
|
@@ -1812,7 +1806,6 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1812
1806
|
} catch (err) {
|
|
1813
1807
|
console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${err}`));
|
|
1814
1808
|
return {
|
|
1815
|
-
zipPrefix,
|
|
1816
1809
|
apiTypesPath: "",
|
|
1817
1810
|
zipTypesPath: "",
|
|
1818
1811
|
zipName: "",
|
|
@@ -1905,7 +1898,8 @@ var defaultOptions2 = {
|
|
|
1905
1898
|
abortOnError: true,
|
|
1906
1899
|
extractRemoteTypes: false,
|
|
1907
1900
|
extractThirdParty: false,
|
|
1908
|
-
outputDir: ""
|
|
1901
|
+
outputDir: "",
|
|
1902
|
+
deleteTsConfig: true
|
|
1909
1903
|
};
|
|
1910
1904
|
function getEffectiveRootDir(parsedCommandLine) {
|
|
1911
1905
|
const compilerOptions = parsedCommandLine.options;
|
|
@@ -1975,6 +1969,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1975
1969
|
rawTsConfigJson.exclude = [];
|
|
1976
1970
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
1977
1971
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
1972
|
+
if (rawTsConfigJson.compilerOptions.declarationDir) {
|
|
1973
|
+
delete rawTsConfigJson.compilerOptions.declarationDir;
|
|
1974
|
+
}
|
|
1978
1975
|
return rawTsConfigJson;
|
|
1979
1976
|
}, "readTsConfig");
|
|
1980
1977
|
var TS_EXTENSIONS = [
|