@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
package/dist/fork-dev-worker.js
CHANGED
|
@@ -114,138 +114,15 @@ var import_path3 = require("path");
|
|
|
114
114
|
var import_promises2 = require("fs/promises");
|
|
115
115
|
|
|
116
116
|
// src/core/lib/typeScriptCompiler.ts
|
|
117
|
-
var
|
|
117
|
+
var import_fs_extra2 = require("fs-extra");
|
|
118
118
|
var import_crypto = __toESM(require("crypto"));
|
|
119
119
|
var import_promises = require("fs/promises");
|
|
120
|
-
var
|
|
120
|
+
var import_path2 = require("path");
|
|
121
121
|
var import_error_codes = require("@module-federation/error-codes");
|
|
122
122
|
var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
|
|
123
|
-
var
|
|
123
|
+
var import_child_process2 = require("child_process");
|
|
124
124
|
var import_util = __toESM(require("util"));
|
|
125
|
-
var
|
|
126
|
-
var STARTS_WITH_SLASH = /^\//;
|
|
127
|
-
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
128
|
-
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
129
|
-
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
130
|
-
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
131
|
-
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
132
|
-
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
133
|
-
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
134
|
-
}, "createHash");
|
|
135
|
-
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
136
|
-
const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
137
|
-
(0, import_fs_extra.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
|
|
138
|
-
(0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
139
|
-
return tempTsConfigJsonPath;
|
|
140
|
-
}
|
|
141
|
-
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
142
|
-
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
143
|
-
const vueExt = ".vue";
|
|
144
|
-
const ext = (0, import_path.extname)(f);
|
|
145
|
-
if (ext === vueExt) {
|
|
146
|
-
return f;
|
|
147
|
-
}
|
|
148
|
-
const regexPattern = new RegExp(`\\${ext}$`);
|
|
149
|
-
return f.replace(regexPattern, "");
|
|
150
|
-
}, "removeExt");
|
|
151
|
-
function getExposeKey(options) {
|
|
152
|
-
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
153
|
-
const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
154
|
-
return mapExposeToEntry[relativeFilePath];
|
|
155
|
-
}
|
|
156
|
-
__name(getExposeKey, "getExposeKey");
|
|
157
|
-
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
158
|
-
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
159
|
-
if (!(0, import_fs_extra.existsSync)(filePath)) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const stats = yield (0, import_promises.stat)(filePath);
|
|
163
|
-
if (stats.isDirectory()) {
|
|
164
|
-
const files = yield (0, import_promises.readdir)(filePath);
|
|
165
|
-
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
166
|
-
filePath: (0, import_path.join)(filePath, file)
|
|
167
|
-
}))));
|
|
168
|
-
} else if (filePath.endsWith(".d.ts")) {
|
|
169
|
-
const exposeKey = getExposeKey({
|
|
170
|
-
filePath,
|
|
171
|
-
rootDir,
|
|
172
|
-
outDir,
|
|
173
|
-
mapExposeToEntry
|
|
174
|
-
});
|
|
175
|
-
if (exposeKey) {
|
|
176
|
-
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
177
|
-
const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
178
|
-
const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
|
|
179
|
-
const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
|
|
180
|
-
(0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
|
|
181
|
-
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
182
|
-
export { default } from './${relativePathToOutput}';`);
|
|
183
|
-
}
|
|
184
|
-
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
185
|
-
cb(content);
|
|
186
|
-
}
|
|
187
|
-
}), "processTypesFile");
|
|
188
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
189
|
-
var _a3, _b, _c, _d;
|
|
190
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const { compilerOptions } = tsConfig;
|
|
194
|
-
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);
|
|
195
|
-
try {
|
|
196
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
197
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
198
|
-
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
199
|
-
context: remoteOptions.context,
|
|
200
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
201
|
-
});
|
|
202
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
203
|
-
const cmd = `npx ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
204
|
-
try {
|
|
205
|
-
yield execPromise(cmd, {
|
|
206
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
207
|
-
});
|
|
208
|
-
} catch (err) {
|
|
209
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
210
|
-
try {
|
|
211
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
212
|
-
} catch (e) {
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
216
|
-
cmd
|
|
217
|
-
}));
|
|
218
|
-
}
|
|
219
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
220
|
-
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
221
|
-
let relativeFileName = "";
|
|
222
|
-
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
223
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
224
|
-
} else {
|
|
225
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
226
|
-
}
|
|
227
|
-
return [
|
|
228
|
-
removeExt(relativeFileName),
|
|
229
|
-
exposed
|
|
230
|
-
];
|
|
231
|
-
}));
|
|
232
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
233
|
-
yield processTypesFile({
|
|
234
|
-
outDir: compilerOptions.outDir,
|
|
235
|
-
filePath: compilerOptions.outDir,
|
|
236
|
-
rootDir: compilerOptions.rootDir,
|
|
237
|
-
mfTypePath,
|
|
238
|
-
cb,
|
|
239
|
-
mapExposeToEntry
|
|
240
|
-
});
|
|
241
|
-
if (remoteOptions.extractThirdParty) {
|
|
242
|
-
yield thirdPartyExtractor.copyDts();
|
|
243
|
-
}
|
|
244
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
245
|
-
} catch (err) {
|
|
246
|
-
throw err;
|
|
247
|
-
}
|
|
248
|
-
}), "compileTs");
|
|
125
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
249
126
|
|
|
250
127
|
// src/server/message/Message.ts
|
|
251
128
|
var _Message = class _Message {
|
|
@@ -319,7 +196,7 @@ var FetchTypesAPI = _FetchTypesAPI;
|
|
|
319
196
|
|
|
320
197
|
// src/server/utils/index.ts
|
|
321
198
|
var import_net = __toESM(require("net"));
|
|
322
|
-
var
|
|
199
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
323
200
|
|
|
324
201
|
// src/server/utils/logTransform.ts
|
|
325
202
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -358,7 +235,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
358
235
|
var BrokerExitLog = _BrokerExitLog;
|
|
359
236
|
|
|
360
237
|
// src/server/utils/log.ts
|
|
361
|
-
var
|
|
238
|
+
var import_sdk = require("@module-federation/sdk");
|
|
362
239
|
var log4js = __toESM(require("log4js"));
|
|
363
240
|
|
|
364
241
|
// src/server/constant.ts
|
|
@@ -373,7 +250,7 @@ var UpdateMode;
|
|
|
373
250
|
})(UpdateMode || (UpdateMode = {}));
|
|
374
251
|
|
|
375
252
|
// src/server/utils/log.ts
|
|
376
|
-
var logger = (0,
|
|
253
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
377
254
|
function fileLog(msg, module2, level) {
|
|
378
255
|
var _a3, _b;
|
|
379
256
|
if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
|
|
@@ -448,7 +325,7 @@ var getIPV4 = /* @__PURE__ */ __name(() => {
|
|
|
448
325
|
// src/server/utils/index.ts
|
|
449
326
|
function getIdentifier(options) {
|
|
450
327
|
const { ip, name } = options;
|
|
451
|
-
return `mf ${
|
|
328
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
452
329
|
}
|
|
453
330
|
__name(getIdentifier, "getIdentifier");
|
|
454
331
|
function fib(n) {
|
|
@@ -1254,11 +1131,11 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1254
1131
|
var Broker = _Broker;
|
|
1255
1132
|
|
|
1256
1133
|
// src/server/broker/createBroker.ts
|
|
1257
|
-
var
|
|
1258
|
-
var
|
|
1134
|
+
var import_child_process = require("child_process");
|
|
1135
|
+
var import_path = __toESM(require("path"));
|
|
1259
1136
|
function createBroker() {
|
|
1260
|
-
const startBrokerPath =
|
|
1261
|
-
const sub = (0,
|
|
1137
|
+
const startBrokerPath = import_path.default.resolve(__dirname, "./start-broker.js");
|
|
1138
|
+
const sub = (0, import_child_process.fork)(startBrokerPath, [], {
|
|
1262
1139
|
detached: true,
|
|
1263
1140
|
stdio: "ignore",
|
|
1264
1141
|
env: process.env
|
|
@@ -1637,7 +1514,7 @@ __name(_ModuleFederationDevServer, "ModuleFederationDevServer");
|
|
|
1637
1514
|
var ModuleFederationDevServer = _ModuleFederationDevServer;
|
|
1638
1515
|
|
|
1639
1516
|
// src/server/createKoaServer.ts
|
|
1640
|
-
var
|
|
1517
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1641
1518
|
var import_koa = __toESM(require("koa"));
|
|
1642
1519
|
function createKoaServer(options) {
|
|
1643
1520
|
return __async(this, null, function* () {
|
|
@@ -1647,7 +1524,7 @@ function createKoaServer(options) {
|
|
|
1647
1524
|
app.use((ctx, next) => __async(this, null, function* () {
|
|
1648
1525
|
if (ctx.path === `/${DEFAULT_TAR_NAME}`) {
|
|
1649
1526
|
ctx.status = 200;
|
|
1650
|
-
ctx.body =
|
|
1527
|
+
ctx.body = import_fs_extra.default.createReadStream(typeTarPath);
|
|
1651
1528
|
ctx.response.type = "application/x-gzip";
|
|
1652
1529
|
} else {
|
|
1653
1530
|
yield next();
|
|
@@ -1662,6 +1539,154 @@ function createKoaServer(options) {
|
|
|
1662
1539
|
}
|
|
1663
1540
|
__name(createKoaServer, "createKoaServer");
|
|
1664
1541
|
|
|
1542
|
+
// src/core/lib/typeScriptCompiler.ts
|
|
1543
|
+
var STARTS_WITH_SLASH = /^\//;
|
|
1544
|
+
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
1545
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
1546
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
1547
|
+
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
1548
|
+
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
1549
|
+
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
1550
|
+
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
1551
|
+
}, "createHash");
|
|
1552
|
+
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
1553
|
+
const tempTsConfigJsonPath = (0, import_path2.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk3.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
1554
|
+
(0, import_fs_extra2.ensureDirSync)((0, import_path2.dirname)(tempTsConfigJsonPath));
|
|
1555
|
+
(0, import_fs_extra2.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
1556
|
+
return tempTsConfigJsonPath;
|
|
1557
|
+
}
|
|
1558
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
1559
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
1560
|
+
const vueExt = ".vue";
|
|
1561
|
+
const ext = (0, import_path2.extname)(f);
|
|
1562
|
+
if (ext === vueExt) {
|
|
1563
|
+
return f;
|
|
1564
|
+
}
|
|
1565
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
1566
|
+
return f.replace(regexPattern, "");
|
|
1567
|
+
}, "removeExt");
|
|
1568
|
+
function getExposeKey(options) {
|
|
1569
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
1570
|
+
const relativeFilePath = (0, import_path2.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
1571
|
+
return mapExposeToEntry[relativeFilePath];
|
|
1572
|
+
}
|
|
1573
|
+
__name(getExposeKey, "getExposeKey");
|
|
1574
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
1575
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
1576
|
+
if (!(0, import_fs_extra2.existsSync)(filePath)) {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
const stats = yield (0, import_promises.stat)(filePath);
|
|
1580
|
+
if (stats.isDirectory()) {
|
|
1581
|
+
const files = yield (0, import_promises.readdir)(filePath);
|
|
1582
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
1583
|
+
filePath: (0, import_path2.join)(filePath, file)
|
|
1584
|
+
}))));
|
|
1585
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
1586
|
+
const exposeKey = getExposeKey({
|
|
1587
|
+
filePath,
|
|
1588
|
+
rootDir,
|
|
1589
|
+
outDir,
|
|
1590
|
+
mapExposeToEntry
|
|
1591
|
+
});
|
|
1592
|
+
if (exposeKey) {
|
|
1593
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
1594
|
+
const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
1595
|
+
const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
|
|
1596
|
+
const relativePathToOutput = (0, import_path2.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path2.sep).join("/");
|
|
1597
|
+
(0, import_fs_extra2.ensureDirSync)(mfeTypeEntryDirectory);
|
|
1598
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
1599
|
+
export { default } from './${relativePathToOutput}';`);
|
|
1600
|
+
}
|
|
1601
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
1602
|
+
cb(content);
|
|
1603
|
+
}
|
|
1604
|
+
}), "processTypesFile");
|
|
1605
|
+
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
1606
|
+
const userAgent = process.env["npm_config_user_agent"];
|
|
1607
|
+
if (userAgent == null) {
|
|
1608
|
+
return "null";
|
|
1609
|
+
}
|
|
1610
|
+
const name = userAgent.split("/")[0];
|
|
1611
|
+
return name;
|
|
1612
|
+
}, "getPMFromUserAgent");
|
|
1613
|
+
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
1614
|
+
const pm = getPMFromUserAgent();
|
|
1615
|
+
switch (pm) {
|
|
1616
|
+
case "yarn":
|
|
1617
|
+
return "yarn";
|
|
1618
|
+
case "npm":
|
|
1619
|
+
case "pnpm":
|
|
1620
|
+
default:
|
|
1621
|
+
return "npx";
|
|
1622
|
+
}
|
|
1623
|
+
}, "resolvePackageManagerExecutable");
|
|
1624
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
1625
|
+
var _a3, _b, _c, _d;
|
|
1626
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
const { compilerOptions } = tsConfig;
|
|
1630
|
+
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);
|
|
1631
|
+
logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
|
|
1632
|
+
try {
|
|
1633
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1634
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
1635
|
+
destDir: (0, import_path2.resolve)(mfTypePath, "node_modules"),
|
|
1636
|
+
context: remoteOptions.context,
|
|
1637
|
+
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
1638
|
+
});
|
|
1639
|
+
const execPromise = import_util.default.promisify(import_child_process2.exec);
|
|
1640
|
+
const pmExecutable = resolvePackageManagerExecutable();
|
|
1641
|
+
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
1642
|
+
try {
|
|
1643
|
+
yield execPromise(cmd, {
|
|
1644
|
+
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
1645
|
+
});
|
|
1646
|
+
} catch (err) {
|
|
1647
|
+
if (compilerOptions.tsBuildInfoFile) {
|
|
1648
|
+
try {
|
|
1649
|
+
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
1654
|
+
cmd
|
|
1655
|
+
}));
|
|
1656
|
+
}
|
|
1657
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
1658
|
+
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
1659
|
+
let relativeFileName = "";
|
|
1660
|
+
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
1661
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
1662
|
+
} else {
|
|
1663
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
1664
|
+
}
|
|
1665
|
+
return [
|
|
1666
|
+
removeExt(relativeFileName),
|
|
1667
|
+
exposed
|
|
1668
|
+
];
|
|
1669
|
+
}));
|
|
1670
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
1671
|
+
yield processTypesFile({
|
|
1672
|
+
outDir: compilerOptions.outDir,
|
|
1673
|
+
filePath: compilerOptions.outDir,
|
|
1674
|
+
rootDir: compilerOptions.rootDir,
|
|
1675
|
+
mfTypePath,
|
|
1676
|
+
cb,
|
|
1677
|
+
mapExposeToEntry
|
|
1678
|
+
});
|
|
1679
|
+
if (remoteOptions.extractThirdParty) {
|
|
1680
|
+
yield thirdPartyExtractor.copyDts();
|
|
1681
|
+
}
|
|
1682
|
+
if (remoteOptions.deleteTsConfig) {
|
|
1683
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
1684
|
+
}
|
|
1685
|
+
} catch (err) {
|
|
1686
|
+
throw err;
|
|
1687
|
+
}
|
|
1688
|
+
}), "compileTs");
|
|
1689
|
+
|
|
1665
1690
|
// src/core/lib/archiveHandler.ts
|
|
1666
1691
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path3.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1667
1692
|
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
@@ -2339,7 +2364,8 @@ var defaultOptions2 = {
|
|
|
2339
2364
|
abortOnError: true,
|
|
2340
2365
|
extractRemoteTypes: false,
|
|
2341
2366
|
extractThirdParty: false,
|
|
2342
|
-
outputDir: ""
|
|
2367
|
+
outputDir: "",
|
|
2368
|
+
deleteTsConfig: true
|
|
2343
2369
|
};
|
|
2344
2370
|
function getEffectiveRootDir(parsedCommandLine) {
|
|
2345
2371
|
const compilerOptions = parsedCommandLine.options;
|
|
@@ -2409,6 +2435,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
2409
2435
|
rawTsConfigJson.exclude = [];
|
|
2410
2436
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2411
2437
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
2438
|
+
if (rawTsConfigJson.compilerOptions.declarationDir) {
|
|
2439
|
+
delete rawTsConfigJson.compilerOptions.declarationDir;
|
|
2440
|
+
}
|
|
2412
2441
|
return rawTsConfigJson;
|
|
2413
2442
|
}, "readTsConfig");
|
|
2414
2443
|
var TS_EXTENSIONS = [
|