@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/fork-dev-worker.js
CHANGED
|
@@ -114,158 +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 getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
189
|
-
const userAgent = process.env["npm_config_user_agent"];
|
|
190
|
-
if (userAgent == null) {
|
|
191
|
-
return "null";
|
|
192
|
-
}
|
|
193
|
-
const name = userAgent.split("/")[0];
|
|
194
|
-
return name;
|
|
195
|
-
}, "getPMFromUserAgent");
|
|
196
|
-
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
197
|
-
const pm = getPMFromUserAgent();
|
|
198
|
-
switch (pm) {
|
|
199
|
-
case "yarn":
|
|
200
|
-
return "yarn";
|
|
201
|
-
case "npm":
|
|
202
|
-
case "pnpm":
|
|
203
|
-
default:
|
|
204
|
-
return "npx";
|
|
205
|
-
}
|
|
206
|
-
}, "resolvePackageManagerExecutable");
|
|
207
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
208
|
-
var _a3, _b, _c, _d;
|
|
209
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const { compilerOptions } = tsConfig;
|
|
213
|
-
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);
|
|
214
|
-
try {
|
|
215
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
216
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
217
|
-
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
218
|
-
context: remoteOptions.context,
|
|
219
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
220
|
-
});
|
|
221
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
222
|
-
const pmExecutable = resolvePackageManagerExecutable();
|
|
223
|
-
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
224
|
-
try {
|
|
225
|
-
yield execPromise(cmd, {
|
|
226
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
227
|
-
});
|
|
228
|
-
} catch (err) {
|
|
229
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
230
|
-
try {
|
|
231
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
232
|
-
} catch (e) {
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
236
|
-
cmd
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
240
|
-
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
241
|
-
let relativeFileName = "";
|
|
242
|
-
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
243
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
244
|
-
} else {
|
|
245
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
246
|
-
}
|
|
247
|
-
return [
|
|
248
|
-
removeExt(relativeFileName),
|
|
249
|
-
exposed
|
|
250
|
-
];
|
|
251
|
-
}));
|
|
252
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
253
|
-
yield processTypesFile({
|
|
254
|
-
outDir: compilerOptions.outDir,
|
|
255
|
-
filePath: compilerOptions.outDir,
|
|
256
|
-
rootDir: compilerOptions.rootDir,
|
|
257
|
-
mfTypePath,
|
|
258
|
-
cb,
|
|
259
|
-
mapExposeToEntry
|
|
260
|
-
});
|
|
261
|
-
if (remoteOptions.extractThirdParty) {
|
|
262
|
-
yield thirdPartyExtractor.copyDts();
|
|
263
|
-
}
|
|
264
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
265
|
-
} catch (err) {
|
|
266
|
-
throw err;
|
|
267
|
-
}
|
|
268
|
-
}), "compileTs");
|
|
125
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
269
126
|
|
|
270
127
|
// src/server/message/Message.ts
|
|
271
128
|
var _Message = class _Message {
|
|
@@ -339,7 +196,7 @@ var FetchTypesAPI = _FetchTypesAPI;
|
|
|
339
196
|
|
|
340
197
|
// src/server/utils/index.ts
|
|
341
198
|
var import_net = __toESM(require("net"));
|
|
342
|
-
var
|
|
199
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
343
200
|
|
|
344
201
|
// src/server/utils/logTransform.ts
|
|
345
202
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -378,7 +235,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
378
235
|
var BrokerExitLog = _BrokerExitLog;
|
|
379
236
|
|
|
380
237
|
// src/server/utils/log.ts
|
|
381
|
-
var
|
|
238
|
+
var import_sdk = require("@module-federation/sdk");
|
|
382
239
|
var log4js = __toESM(require("log4js"));
|
|
383
240
|
|
|
384
241
|
// src/server/constant.ts
|
|
@@ -393,7 +250,7 @@ var UpdateMode;
|
|
|
393
250
|
})(UpdateMode || (UpdateMode = {}));
|
|
394
251
|
|
|
395
252
|
// src/server/utils/log.ts
|
|
396
|
-
var logger = (0,
|
|
253
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
397
254
|
function fileLog(msg, module2, level) {
|
|
398
255
|
var _a3, _b;
|
|
399
256
|
if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
|
|
@@ -468,7 +325,7 @@ var getIPV4 = /* @__PURE__ */ __name(() => {
|
|
|
468
325
|
// src/server/utils/index.ts
|
|
469
326
|
function getIdentifier(options) {
|
|
470
327
|
const { ip, name } = options;
|
|
471
|
-
return `mf ${
|
|
328
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
472
329
|
}
|
|
473
330
|
__name(getIdentifier, "getIdentifier");
|
|
474
331
|
function fib(n) {
|
|
@@ -1274,11 +1131,11 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1274
1131
|
var Broker = _Broker;
|
|
1275
1132
|
|
|
1276
1133
|
// src/server/broker/createBroker.ts
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
1134
|
+
var import_child_process = require("child_process");
|
|
1135
|
+
var import_path = __toESM(require("path"));
|
|
1279
1136
|
function createBroker() {
|
|
1280
|
-
const startBrokerPath =
|
|
1281
|
-
const sub = (0,
|
|
1137
|
+
const startBrokerPath = import_path.default.resolve(__dirname, "./start-broker.js");
|
|
1138
|
+
const sub = (0, import_child_process.fork)(startBrokerPath, [], {
|
|
1282
1139
|
detached: true,
|
|
1283
1140
|
stdio: "ignore",
|
|
1284
1141
|
env: process.env
|
|
@@ -1657,7 +1514,7 @@ __name(_ModuleFederationDevServer, "ModuleFederationDevServer");
|
|
|
1657
1514
|
var ModuleFederationDevServer = _ModuleFederationDevServer;
|
|
1658
1515
|
|
|
1659
1516
|
// src/server/createKoaServer.ts
|
|
1660
|
-
var
|
|
1517
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1661
1518
|
var import_koa = __toESM(require("koa"));
|
|
1662
1519
|
function createKoaServer(options) {
|
|
1663
1520
|
return __async(this, null, function* () {
|
|
@@ -1667,7 +1524,7 @@ function createKoaServer(options) {
|
|
|
1667
1524
|
app.use((ctx, next) => __async(this, null, function* () {
|
|
1668
1525
|
if (ctx.path === `/${DEFAULT_TAR_NAME}`) {
|
|
1669
1526
|
ctx.status = 200;
|
|
1670
|
-
ctx.body =
|
|
1527
|
+
ctx.body = import_fs_extra.default.createReadStream(typeTarPath);
|
|
1671
1528
|
ctx.response.type = "application/x-gzip";
|
|
1672
1529
|
} else {
|
|
1673
1530
|
yield next();
|
|
@@ -1682,6 +1539,154 @@ function createKoaServer(options) {
|
|
|
1682
1539
|
}
|
|
1683
1540
|
__name(createKoaServer, "createKoaServer");
|
|
1684
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
|
+
|
|
1685
1690
|
// src/core/lib/archiveHandler.ts
|
|
1686
1691
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path3.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1687
1692
|
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
@@ -2359,7 +2364,8 @@ var defaultOptions2 = {
|
|
|
2359
2364
|
abortOnError: true,
|
|
2360
2365
|
extractRemoteTypes: false,
|
|
2361
2366
|
extractThirdParty: false,
|
|
2362
|
-
outputDir: ""
|
|
2367
|
+
outputDir: "",
|
|
2368
|
+
deleteTsConfig: true
|
|
2363
2369
|
};
|
|
2364
2370
|
function getEffectiveRootDir(parsedCommandLine) {
|
|
2365
2371
|
const compilerOptions = parsedCommandLine.options;
|
|
@@ -2429,6 +2435,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
2429
2435
|
rawTsConfigJson.exclude = [];
|
|
2430
2436
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2431
2437
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
2438
|
+
if (rawTsConfigJson.compilerOptions.declarationDir) {
|
|
2439
|
+
delete rawTsConfigJson.compilerOptions.declarationDir;
|
|
2440
|
+
}
|
|
2432
2441
|
return rawTsConfigJson;
|
|
2433
2442
|
}, "readTsConfig");
|
|
2434
2443
|
var TS_EXTENSIONS = [
|