@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
|
@@ -182,7 +182,8 @@ var defaultOptions = {
|
|
|
182
182
|
abortOnError: true,
|
|
183
183
|
extractRemoteTypes: false,
|
|
184
184
|
extractThirdParty: false,
|
|
185
|
-
outputDir: ""
|
|
185
|
+
outputDir: "",
|
|
186
|
+
deleteTsConfig: true
|
|
186
187
|
};
|
|
187
188
|
function getEffectiveRootDir(parsedCommandLine) {
|
|
188
189
|
const compilerOptions = parsedCommandLine.options;
|
|
@@ -252,6 +253,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
252
253
|
rawTsConfigJson.exclude = [];
|
|
253
254
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
254
255
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
256
|
+
if (rawTsConfigJson.compilerOptions.declarationDir) {
|
|
257
|
+
delete rawTsConfigJson.compilerOptions.declarationDir;
|
|
258
|
+
}
|
|
255
259
|
return rawTsConfigJson;
|
|
256
260
|
}, "readTsConfig");
|
|
257
261
|
var TS_EXTENSIONS = [
|
|
@@ -315,7 +319,7 @@ var import_path3 = require("path");
|
|
|
315
319
|
var import_promises2 = require("fs/promises");
|
|
316
320
|
|
|
317
321
|
// src/core/lib/typeScriptCompiler.ts
|
|
318
|
-
var
|
|
322
|
+
var import_fs_extra2 = require("fs-extra");
|
|
319
323
|
var import_crypto = __toESM(require("crypto"));
|
|
320
324
|
var import_promises = require("fs/promises");
|
|
321
325
|
var import_path2 = require("path");
|
|
@@ -323,150 +327,7 @@ var import_error_codes = require("@module-federation/error-codes");
|
|
|
323
327
|
var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
|
|
324
328
|
var import_child_process = require("child_process");
|
|
325
329
|
var import_util = __toESM(require("util"));
|
|
326
|
-
var
|
|
327
|
-
var STARTS_WITH_SLASH = /^\//;
|
|
328
|
-
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
329
|
-
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
330
|
-
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
331
|
-
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
332
|
-
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
333
|
-
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
334
|
-
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
335
|
-
}, "createHash");
|
|
336
|
-
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
337
|
-
const tempTsConfigJsonPath = (0, import_path2.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
338
|
-
(0, import_fs_extra.ensureDirSync)((0, import_path2.dirname)(tempTsConfigJsonPath));
|
|
339
|
-
(0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
340
|
-
return tempTsConfigJsonPath;
|
|
341
|
-
}
|
|
342
|
-
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
343
|
-
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
344
|
-
const vueExt = ".vue";
|
|
345
|
-
const ext = (0, import_path2.extname)(f);
|
|
346
|
-
if (ext === vueExt) {
|
|
347
|
-
return f;
|
|
348
|
-
}
|
|
349
|
-
const regexPattern = new RegExp(`\\${ext}$`);
|
|
350
|
-
return f.replace(regexPattern, "");
|
|
351
|
-
}, "removeExt");
|
|
352
|
-
function getExposeKey(options) {
|
|
353
|
-
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
354
|
-
const relativeFilePath = (0, import_path2.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
355
|
-
return mapExposeToEntry[relativeFilePath];
|
|
356
|
-
}
|
|
357
|
-
__name(getExposeKey, "getExposeKey");
|
|
358
|
-
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
359
|
-
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
360
|
-
if (!(0, import_fs_extra.existsSync)(filePath)) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const stats = yield (0, import_promises.stat)(filePath);
|
|
364
|
-
if (stats.isDirectory()) {
|
|
365
|
-
const files = yield (0, import_promises.readdir)(filePath);
|
|
366
|
-
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
367
|
-
filePath: (0, import_path2.join)(filePath, file)
|
|
368
|
-
}))));
|
|
369
|
-
} else if (filePath.endsWith(".d.ts")) {
|
|
370
|
-
const exposeKey = getExposeKey({
|
|
371
|
-
filePath,
|
|
372
|
-
rootDir,
|
|
373
|
-
outDir,
|
|
374
|
-
mapExposeToEntry
|
|
375
|
-
});
|
|
376
|
-
if (exposeKey) {
|
|
377
|
-
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
378
|
-
const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
379
|
-
const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
|
|
380
|
-
const relativePathToOutput = (0, import_path2.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path2.sep).join("/");
|
|
381
|
-
(0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
|
|
382
|
-
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
383
|
-
export { default } from './${relativePathToOutput}';`);
|
|
384
|
-
}
|
|
385
|
-
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
386
|
-
cb(content);
|
|
387
|
-
}
|
|
388
|
-
}), "processTypesFile");
|
|
389
|
-
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
390
|
-
const userAgent = process.env["npm_config_user_agent"];
|
|
391
|
-
if (userAgent == null) {
|
|
392
|
-
return "null";
|
|
393
|
-
}
|
|
394
|
-
const name = userAgent.split("/")[0];
|
|
395
|
-
return name;
|
|
396
|
-
}, "getPMFromUserAgent");
|
|
397
|
-
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
398
|
-
const pm = getPMFromUserAgent();
|
|
399
|
-
switch (pm) {
|
|
400
|
-
case "yarn":
|
|
401
|
-
return "yarn";
|
|
402
|
-
case "npm":
|
|
403
|
-
case "pnpm":
|
|
404
|
-
default:
|
|
405
|
-
return "npx";
|
|
406
|
-
}
|
|
407
|
-
}, "resolvePackageManagerExecutable");
|
|
408
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
409
|
-
var _a2, _b, _c, _d;
|
|
410
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
const { compilerOptions } = tsConfig;
|
|
414
|
-
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
|
|
415
|
-
try {
|
|
416
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
417
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
418
|
-
destDir: (0, import_path2.resolve)(mfTypePath, "node_modules"),
|
|
419
|
-
context: remoteOptions.context,
|
|
420
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
421
|
-
});
|
|
422
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
423
|
-
const pmExecutable = resolvePackageManagerExecutable();
|
|
424
|
-
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
425
|
-
try {
|
|
426
|
-
yield execPromise(cmd, {
|
|
427
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
428
|
-
});
|
|
429
|
-
} catch (err) {
|
|
430
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
431
|
-
try {
|
|
432
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
433
|
-
} catch (e) {
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
437
|
-
cmd
|
|
438
|
-
}));
|
|
439
|
-
}
|
|
440
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
441
|
-
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
442
|
-
let relativeFileName = "";
|
|
443
|
-
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
444
|
-
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
445
|
-
} else {
|
|
446
|
-
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
447
|
-
}
|
|
448
|
-
return [
|
|
449
|
-
removeExt(relativeFileName),
|
|
450
|
-
exposed
|
|
451
|
-
];
|
|
452
|
-
}));
|
|
453
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
454
|
-
yield processTypesFile({
|
|
455
|
-
outDir: compilerOptions.outDir,
|
|
456
|
-
filePath: compilerOptions.outDir,
|
|
457
|
-
rootDir: compilerOptions.rootDir,
|
|
458
|
-
mfTypePath,
|
|
459
|
-
cb,
|
|
460
|
-
mapExposeToEntry
|
|
461
|
-
});
|
|
462
|
-
if (remoteOptions.extractThirdParty) {
|
|
463
|
-
yield thirdPartyExtractor.copyDts();
|
|
464
|
-
}
|
|
465
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
466
|
-
} catch (err) {
|
|
467
|
-
throw err;
|
|
468
|
-
}
|
|
469
|
-
}), "compileTs");
|
|
330
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
470
331
|
|
|
471
332
|
// src/server/message/Message.ts
|
|
472
333
|
var _Message = class _Message {
|
|
@@ -539,7 +400,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
539
400
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
540
401
|
|
|
541
402
|
// src/server/utils/index.ts
|
|
542
|
-
var
|
|
403
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
543
404
|
|
|
544
405
|
// src/server/utils/logTransform.ts
|
|
545
406
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -578,7 +439,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
578
439
|
var BrokerExitLog = _BrokerExitLog;
|
|
579
440
|
|
|
580
441
|
// src/server/utils/log.ts
|
|
581
|
-
var
|
|
442
|
+
var import_sdk = require("@module-federation/sdk");
|
|
582
443
|
var log4js = __toESM(require("log4js"));
|
|
583
444
|
|
|
584
445
|
// src/server/constant.ts
|
|
@@ -592,7 +453,7 @@ var UpdateMode;
|
|
|
592
453
|
})(UpdateMode || (UpdateMode = {}));
|
|
593
454
|
|
|
594
455
|
// src/server/utils/log.ts
|
|
595
|
-
var logger = (0,
|
|
456
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
596
457
|
function fileLog(msg, module2, level) {
|
|
597
458
|
var _a2, _b;
|
|
598
459
|
if (!((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2["FEDERATION_DEBUG"])) {
|
|
@@ -639,7 +500,7 @@ __name(error, "error");
|
|
|
639
500
|
// src/server/utils/index.ts
|
|
640
501
|
function getIdentifier(options) {
|
|
641
502
|
const { ip, name } = options;
|
|
642
|
-
return `mf ${
|
|
503
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
643
504
|
}
|
|
644
505
|
__name(getIdentifier, "getIdentifier");
|
|
645
506
|
|
|
@@ -1341,9 +1202,157 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1341
1202
|
var Broker = _Broker;
|
|
1342
1203
|
|
|
1343
1204
|
// src/server/createKoaServer.ts
|
|
1344
|
-
var
|
|
1205
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1345
1206
|
var import_koa = __toESM(require("koa"));
|
|
1346
1207
|
|
|
1208
|
+
// src/core/lib/typeScriptCompiler.ts
|
|
1209
|
+
var STARTS_WITH_SLASH = /^\//;
|
|
1210
|
+
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
1211
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
1212
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
1213
|
+
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
1214
|
+
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
1215
|
+
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
1216
|
+
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
1217
|
+
}, "createHash");
|
|
1218
|
+
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
1219
|
+
const tempTsConfigJsonPath = (0, import_path2.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk3.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
1220
|
+
(0, import_fs_extra2.ensureDirSync)((0, import_path2.dirname)(tempTsConfigJsonPath));
|
|
1221
|
+
(0, import_fs_extra2.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
1222
|
+
return tempTsConfigJsonPath;
|
|
1223
|
+
}
|
|
1224
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
1225
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
1226
|
+
const vueExt = ".vue";
|
|
1227
|
+
const ext = (0, import_path2.extname)(f);
|
|
1228
|
+
if (ext === vueExt) {
|
|
1229
|
+
return f;
|
|
1230
|
+
}
|
|
1231
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
1232
|
+
return f.replace(regexPattern, "");
|
|
1233
|
+
}, "removeExt");
|
|
1234
|
+
function getExposeKey(options) {
|
|
1235
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
1236
|
+
const relativeFilePath = (0, import_path2.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
1237
|
+
return mapExposeToEntry[relativeFilePath];
|
|
1238
|
+
}
|
|
1239
|
+
__name(getExposeKey, "getExposeKey");
|
|
1240
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
1241
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
1242
|
+
if (!(0, import_fs_extra2.existsSync)(filePath)) {
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
const stats = yield (0, import_promises.stat)(filePath);
|
|
1246
|
+
if (stats.isDirectory()) {
|
|
1247
|
+
const files = yield (0, import_promises.readdir)(filePath);
|
|
1248
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
1249
|
+
filePath: (0, import_path2.join)(filePath, file)
|
|
1250
|
+
}))));
|
|
1251
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
1252
|
+
const exposeKey = getExposeKey({
|
|
1253
|
+
filePath,
|
|
1254
|
+
rootDir,
|
|
1255
|
+
outDir,
|
|
1256
|
+
mapExposeToEntry
|
|
1257
|
+
});
|
|
1258
|
+
if (exposeKey) {
|
|
1259
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
1260
|
+
const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
1261
|
+
const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
|
|
1262
|
+
const relativePathToOutput = (0, import_path2.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path2.sep).join("/");
|
|
1263
|
+
(0, import_fs_extra2.ensureDirSync)(mfeTypeEntryDirectory);
|
|
1264
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
1265
|
+
export { default } from './${relativePathToOutput}';`);
|
|
1266
|
+
}
|
|
1267
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
1268
|
+
cb(content);
|
|
1269
|
+
}
|
|
1270
|
+
}), "processTypesFile");
|
|
1271
|
+
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
1272
|
+
const userAgent = process.env["npm_config_user_agent"];
|
|
1273
|
+
if (userAgent == null) {
|
|
1274
|
+
return "null";
|
|
1275
|
+
}
|
|
1276
|
+
const name = userAgent.split("/")[0];
|
|
1277
|
+
return name;
|
|
1278
|
+
}, "getPMFromUserAgent");
|
|
1279
|
+
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
1280
|
+
const pm = getPMFromUserAgent();
|
|
1281
|
+
switch (pm) {
|
|
1282
|
+
case "yarn":
|
|
1283
|
+
return "yarn";
|
|
1284
|
+
case "npm":
|
|
1285
|
+
case "pnpm":
|
|
1286
|
+
default:
|
|
1287
|
+
return "npx";
|
|
1288
|
+
}
|
|
1289
|
+
}, "resolvePackageManagerExecutable");
|
|
1290
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
1291
|
+
var _a2, _b, _c, _d;
|
|
1292
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
const { compilerOptions } = tsConfig;
|
|
1296
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
|
|
1297
|
+
logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
|
|
1298
|
+
try {
|
|
1299
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1300
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
1301
|
+
destDir: (0, import_path2.resolve)(mfTypePath, "node_modules"),
|
|
1302
|
+
context: remoteOptions.context,
|
|
1303
|
+
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
1304
|
+
});
|
|
1305
|
+
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
1306
|
+
const pmExecutable = resolvePackageManagerExecutable();
|
|
1307
|
+
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
1308
|
+
try {
|
|
1309
|
+
yield execPromise(cmd, {
|
|
1310
|
+
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
1311
|
+
});
|
|
1312
|
+
} catch (err) {
|
|
1313
|
+
if (compilerOptions.tsBuildInfoFile) {
|
|
1314
|
+
try {
|
|
1315
|
+
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
1316
|
+
} catch (e) {
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
1320
|
+
cmd
|
|
1321
|
+
}));
|
|
1322
|
+
}
|
|
1323
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
1324
|
+
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
1325
|
+
let relativeFileName = "";
|
|
1326
|
+
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
1327
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
1328
|
+
} else {
|
|
1329
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
1330
|
+
}
|
|
1331
|
+
return [
|
|
1332
|
+
removeExt(relativeFileName),
|
|
1333
|
+
exposed
|
|
1334
|
+
];
|
|
1335
|
+
}));
|
|
1336
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
1337
|
+
yield processTypesFile({
|
|
1338
|
+
outDir: compilerOptions.outDir,
|
|
1339
|
+
filePath: compilerOptions.outDir,
|
|
1340
|
+
rootDir: compilerOptions.rootDir,
|
|
1341
|
+
mfTypePath,
|
|
1342
|
+
cb,
|
|
1343
|
+
mapExposeToEntry
|
|
1344
|
+
});
|
|
1345
|
+
if (remoteOptions.extractThirdParty) {
|
|
1346
|
+
yield thirdPartyExtractor.copyDts();
|
|
1347
|
+
}
|
|
1348
|
+
if (remoteOptions.deleteTsConfig) {
|
|
1349
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
1350
|
+
}
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
throw err;
|
|
1353
|
+
}
|
|
1354
|
+
}), "compileTs");
|
|
1355
|
+
|
|
1347
1356
|
// src/core/lib/archiveHandler.ts
|
|
1348
1357
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path3.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1349
1358
|
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import { WebpackPluginInstance, Compiler } from 'webpack';
|
|
3
3
|
import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { i as isTSProject } from './utils-
|
|
4
|
+
export { i as isTSProject } from './utils-DxGrqb9N.js';
|
|
5
5
|
import './DTSManager-b15Gfat3.js';
|
|
6
6
|
import 'typescript';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import { WebpackPluginInstance, Compiler } from 'webpack';
|
|
3
3
|
import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { i as isTSProject } from './utils-
|
|
4
|
+
export { i as isTSProject } from './utils-DxGrqb9N.js';
|
|
5
5
|
import './DTSManager-b15Gfat3.js';
|
|
6
6
|
import 'typescript';
|
|
7
7
|
|