@module-federation/dts-plugin 0.21.3 → 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 +24 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +160 -143
- package/dist/esm/{chunk-2GDMDG2O.js → chunk-N7GTIQUA.js} +1 -1
- package/dist/esm/{chunk-ETMHGGQH.js → chunk-RWXNVNFM.js} +164 -149
- 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 -138
- package/dist/fork-generate-dts.js +160 -131
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +166 -160
- 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,130 +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 compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
390
|
-
var _a2, _b, _c, _d;
|
|
391
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
const { compilerOptions } = tsConfig;
|
|
395
|
-
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);
|
|
396
|
-
try {
|
|
397
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
398
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
399
|
-
destDir: (0, import_path2.resolve)(mfTypePath, "node_modules"),
|
|
400
|
-
context: remoteOptions.context,
|
|
401
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
402
|
-
});
|
|
403
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
404
|
-
const cmd = `npx ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
405
|
-
try {
|
|
406
|
-
yield execPromise(cmd, {
|
|
407
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
408
|
-
});
|
|
409
|
-
} catch (err) {
|
|
410
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
411
|
-
try {
|
|
412
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
413
|
-
} catch (e) {
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
417
|
-
cmd
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
421
|
-
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
422
|
-
let relativeFileName = "";
|
|
423
|
-
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
424
|
-
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
425
|
-
} else {
|
|
426
|
-
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
427
|
-
}
|
|
428
|
-
return [
|
|
429
|
-
removeExt(relativeFileName),
|
|
430
|
-
exposed
|
|
431
|
-
];
|
|
432
|
-
}));
|
|
433
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
434
|
-
yield processTypesFile({
|
|
435
|
-
outDir: compilerOptions.outDir,
|
|
436
|
-
filePath: compilerOptions.outDir,
|
|
437
|
-
rootDir: compilerOptions.rootDir,
|
|
438
|
-
mfTypePath,
|
|
439
|
-
cb,
|
|
440
|
-
mapExposeToEntry
|
|
441
|
-
});
|
|
442
|
-
if (remoteOptions.extractThirdParty) {
|
|
443
|
-
yield thirdPartyExtractor.copyDts();
|
|
444
|
-
}
|
|
445
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
446
|
-
} catch (err) {
|
|
447
|
-
throw err;
|
|
448
|
-
}
|
|
449
|
-
}), "compileTs");
|
|
330
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
450
331
|
|
|
451
332
|
// src/server/message/Message.ts
|
|
452
333
|
var _Message = class _Message {
|
|
@@ -519,7 +400,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
519
400
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
520
401
|
|
|
521
402
|
// src/server/utils/index.ts
|
|
522
|
-
var
|
|
403
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
523
404
|
|
|
524
405
|
// src/server/utils/logTransform.ts
|
|
525
406
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -558,7 +439,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
558
439
|
var BrokerExitLog = _BrokerExitLog;
|
|
559
440
|
|
|
560
441
|
// src/server/utils/log.ts
|
|
561
|
-
var
|
|
442
|
+
var import_sdk = require("@module-federation/sdk");
|
|
562
443
|
var log4js = __toESM(require("log4js"));
|
|
563
444
|
|
|
564
445
|
// src/server/constant.ts
|
|
@@ -572,7 +453,7 @@ var UpdateMode;
|
|
|
572
453
|
})(UpdateMode || (UpdateMode = {}));
|
|
573
454
|
|
|
574
455
|
// src/server/utils/log.ts
|
|
575
|
-
var logger = (0,
|
|
456
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
576
457
|
function fileLog(msg, module2, level) {
|
|
577
458
|
var _a2, _b;
|
|
578
459
|
if (!((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2["FEDERATION_DEBUG"])) {
|
|
@@ -619,7 +500,7 @@ __name(error, "error");
|
|
|
619
500
|
// src/server/utils/index.ts
|
|
620
501
|
function getIdentifier(options) {
|
|
621
502
|
const { ip, name } = options;
|
|
622
|
-
return `mf ${
|
|
503
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
623
504
|
}
|
|
624
505
|
__name(getIdentifier, "getIdentifier");
|
|
625
506
|
|
|
@@ -1321,9 +1202,157 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1321
1202
|
var Broker = _Broker;
|
|
1322
1203
|
|
|
1323
1204
|
// src/server/createKoaServer.ts
|
|
1324
|
-
var
|
|
1205
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1325
1206
|
var import_koa = __toESM(require("koa"));
|
|
1326
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
|
+
|
|
1327
1356
|
// src/core/lib/archiveHandler.ts
|
|
1328
1357
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path3.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1329
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
|
|