@module-federation/dts-plugin 0.2.6 → 0.2.7
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 +10 -0
- package/dist/{DtsWorker-7113d2b0.d.ts → DtsWorker-90454949.d.ts} +11 -3
- package/dist/core.d.mts +5 -5
- package/dist/core.d.ts +5 -5
- package/dist/core.js +167 -99
- package/dist/esm/{chunk-CRKFI32N.js → chunk-ZLQBXHXA.js} +161 -93
- package/dist/esm/core.js +1 -1
- package/dist/esm/fork-dev-worker.js +1 -1
- package/dist/esm/fork-generate-dts.js +1 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/start-broker.js +1 -1
- package/dist/fork-dev-worker.js +171 -103
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +164 -96
- package/dist/index.js +186 -119
- package/dist/package.json +6 -3
- package/dist/start-broker.js +11 -11
- package/package.json +9 -6
|
@@ -147,7 +147,7 @@ __name(exposeRpc, "exposeRpc");
|
|
|
147
147
|
var import_axios = __toESM(require("axios"));
|
|
148
148
|
var import_http2 = __toESM(require("http"));
|
|
149
149
|
var import_https = __toESM(require("https"));
|
|
150
|
-
var
|
|
150
|
+
var import_ansi_colors2 = __toESM(require("ansi-colors"));
|
|
151
151
|
|
|
152
152
|
// packages/dts-plugin/src/core/configurations/remotePlugin.ts
|
|
153
153
|
var import_fs = require("fs");
|
|
@@ -170,20 +170,56 @@ var defaultOptions = {
|
|
|
170
170
|
extractRemoteTypes: false,
|
|
171
171
|
extractThirdParty: false
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
function getEffectiveRootDir(parsedCommandLine) {
|
|
174
|
+
const compilerOptions = parsedCommandLine.options;
|
|
175
|
+
if (compilerOptions.rootDir) {
|
|
176
|
+
return compilerOptions.rootDir;
|
|
177
|
+
}
|
|
178
|
+
const files = parsedCommandLine.fileNames;
|
|
179
|
+
if (files.length > 0) {
|
|
180
|
+
const commonRoot = files.map((file) => (0, import_path.dirname)(file)).reduce((commonPath, fileDir) => {
|
|
181
|
+
while (!fileDir.startsWith(commonPath)) {
|
|
182
|
+
commonPath = (0, import_path.dirname)(commonPath);
|
|
183
|
+
}
|
|
184
|
+
return commonPath;
|
|
185
|
+
}, files[0]);
|
|
186
|
+
return commonRoot;
|
|
187
|
+
}
|
|
188
|
+
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
189
|
+
}
|
|
190
|
+
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
191
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
|
|
174
192
|
const resolvedTsConfigPath = (0, import_path.resolve)(context, tsConfigPath);
|
|
175
193
|
const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
|
|
176
194
|
if (readResult.error) {
|
|
177
195
|
throw new Error(readResult.error.messageText.toString());
|
|
178
196
|
}
|
|
179
|
-
const
|
|
197
|
+
const rawTsConfigJson = readResult.config;
|
|
198
|
+
const configContent = import_typescript.default.parseJsonConfigFileContent(rawTsConfigJson, import_typescript.default.sys, (0, import_path.dirname)(resolvedTsConfigPath));
|
|
199
|
+
const rootDir = getEffectiveRootDir(configContent);
|
|
180
200
|
const outDir = (0, import_path.resolve)(context, configContent.options.outDir || "dist", typesFolder, compiledTypesFolder);
|
|
181
|
-
|
|
201
|
+
const defaultCompilerOptions = {
|
|
202
|
+
rootDir,
|
|
182
203
|
emitDeclarationOnly: true,
|
|
183
204
|
noEmit: false,
|
|
184
205
|
declaration: true,
|
|
185
206
|
outDir
|
|
186
|
-
}
|
|
207
|
+
};
|
|
208
|
+
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
209
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
210
|
+
const filesToCompile = [
|
|
211
|
+
...Object.values(mapComponentsToExpose),
|
|
212
|
+
...additionalFilesToCompile
|
|
213
|
+
];
|
|
214
|
+
rawTsConfigJson.include = [];
|
|
215
|
+
rawTsConfigJson.files = filesToCompile;
|
|
216
|
+
rawTsConfigJson.exclude = [];
|
|
217
|
+
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
218
|
+
const extendsPath = rawTsConfigJson.extends;
|
|
219
|
+
if (extendsPath && extendsPath.startsWith(".")) {
|
|
220
|
+
rawTsConfigJson.extends = (0, import_path.resolve)(context, extendsPath);
|
|
221
|
+
}
|
|
222
|
+
return rawTsConfigJson;
|
|
187
223
|
}, "readTsConfig");
|
|
188
224
|
var TS_EXTENSIONS = [
|
|
189
225
|
"ts",
|
|
@@ -221,7 +257,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
221
257
|
validateOptions(options);
|
|
222
258
|
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions), options);
|
|
223
259
|
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
224
|
-
const tsConfig = readTsConfig(remoteOptions);
|
|
260
|
+
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
225
261
|
return {
|
|
226
262
|
tsConfig,
|
|
227
263
|
mapComponentsToExpose,
|
|
@@ -230,95 +266,127 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
|
230
266
|
}, "retrieveRemoteConfig");
|
|
231
267
|
|
|
232
268
|
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
233
|
-
var
|
|
269
|
+
var import_ansi_colors = __toESM(require("ansi-colors"));
|
|
234
270
|
var import_path4 = __toESM(require("path"));
|
|
235
|
-
var
|
|
271
|
+
var import_promises3 = require("fs/promises");
|
|
236
272
|
var import_fs2 = __toESM(require("fs"));
|
|
237
|
-
var
|
|
273
|
+
var import_sdk5 = require("@module-federation/sdk");
|
|
238
274
|
var import_lodash2 = __toESM(require("lodash.clonedeepwith"));
|
|
239
275
|
var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
|
|
240
276
|
|
|
241
277
|
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
242
278
|
var import_adm_zip = __toESM(require("adm-zip"));
|
|
243
279
|
var import_path3 = require("path");
|
|
244
|
-
var
|
|
280
|
+
var import_promises2 = require("fs/promises");
|
|
245
281
|
|
|
246
282
|
// packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
|
|
247
|
-
var
|
|
283
|
+
var import_fs_extra = require("fs-extra");
|
|
284
|
+
var import_promises = require("fs/promises");
|
|
285
|
+
var import_crypto = require("crypto");
|
|
248
286
|
var import_path2 = require("path");
|
|
249
|
-
var import_typescript2 = __toESM(require("typescript"));
|
|
250
287
|
var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
|
|
288
|
+
var import_child_process = require("child_process");
|
|
289
|
+
var import_util = __toESM(require("util"));
|
|
290
|
+
var import_sdk = require("@module-federation/sdk");
|
|
251
291
|
var STARTS_WITH_SLASH = /^\//;
|
|
252
292
|
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
console.error(import_ansi_colors.default.red(`TS Error ${diagnostic.code}':' ${import_typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, import_typescript2.default.sys.newLine)}`));
|
|
256
|
-
console.error(import_ansi_colors.default.red(` at ${diagnostic.file.fileName}:${line + 1} typescript.sys.newLine`));
|
|
257
|
-
}, "reportCompileDiagnostic");
|
|
258
|
-
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
259
|
-
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
293
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
294
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
260
295
|
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
296
|
+
function writeTempTsConfig(tsConfig, context) {
|
|
297
|
+
const tempTsConfigJsonPath = (0, import_path2.resolve)(context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${(0, import_crypto.randomUUID)()}.json`);
|
|
298
|
+
(0, import_fs_extra.ensureDirSync)((0, import_path2.dirname)(tempTsConfigJsonPath));
|
|
299
|
+
(0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
300
|
+
return tempTsConfigJsonPath;
|
|
301
|
+
}
|
|
302
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
303
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
304
|
+
const ext = (0, import_path2.extname)(f);
|
|
305
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
306
|
+
return f.replace(regexPattern, "");
|
|
307
|
+
}, "removeExt");
|
|
308
|
+
function getExposeKey(options) {
|
|
309
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
310
|
+
const relativeFilePath = removeExt((0, import_path2.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), "")));
|
|
311
|
+
return mapExposeToEntry[relativeFilePath];
|
|
312
|
+
}
|
|
313
|
+
__name(getExposeKey, "getExposeKey");
|
|
314
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
315
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
316
|
+
if (!(0, import_fs_extra.existsSync)(filePath)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const stats = yield (0, import_promises.stat)(filePath);
|
|
320
|
+
if (stats.isDirectory()) {
|
|
321
|
+
const files = yield (0, import_promises.readdir)(filePath);
|
|
322
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
323
|
+
filePath: (0, import_path2.join)(filePath, file)
|
|
324
|
+
}))));
|
|
325
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
326
|
+
const exposeKey = getExposeKey({
|
|
327
|
+
filePath,
|
|
328
|
+
rootDir,
|
|
329
|
+
outDir,
|
|
330
|
+
mapExposeToEntry
|
|
331
|
+
});
|
|
332
|
+
if (exposeKey) {
|
|
333
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
334
|
+
const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
335
|
+
const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
|
|
336
|
+
const relativePathToOutput = (0, import_path2.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path2.sep).join("/");
|
|
337
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
338
|
+
export { default } from './${relativePathToOutput}';`);
|
|
339
|
+
}
|
|
340
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
341
|
+
cb(content);
|
|
342
|
+
}
|
|
343
|
+
}), "processTypesFile");
|
|
344
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
345
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const { compilerOptions } = tsConfig;
|
|
349
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
|
|
350
|
+
try {
|
|
351
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
352
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
|
|
353
|
+
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
354
|
+
const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
|
|
355
|
+
try {
|
|
356
|
+
yield execPromise(cmd);
|
|
357
|
+
} catch (err) {
|
|
358
|
+
throw new Error(`compile TS failed, the original command is '${cmd}'`);
|
|
359
|
+
}
|
|
360
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
361
|
+
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
362
|
+
let relativeFileName = "";
|
|
363
|
+
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
364
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
365
|
+
} else {
|
|
366
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
282
367
|
}
|
|
368
|
+
return [
|
|
369
|
+
removeExt(relativeFileName),
|
|
370
|
+
exposed
|
|
371
|
+
];
|
|
372
|
+
}));
|
|
373
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
374
|
+
yield processTypesFile({
|
|
375
|
+
outDir: compilerOptions.outDir,
|
|
376
|
+
filePath: compilerOptions.outDir,
|
|
377
|
+
rootDir: compilerOptions.rootDir,
|
|
378
|
+
mfTypePath,
|
|
379
|
+
cb,
|
|
380
|
+
mapExposeToEntry
|
|
381
|
+
});
|
|
382
|
+
if (remoteOptions.extractThirdParty) {
|
|
383
|
+
yield thirdPartyExtractor.copyDts();
|
|
283
384
|
}
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
}, "createHost");
|
|
288
|
-
var createVueTscProgram = /* @__PURE__ */ __name((programOptions) => {
|
|
289
|
-
const vueTypescript = require("vue-tsc");
|
|
290
|
-
return vueTypescript.createProgram(programOptions);
|
|
291
|
-
}, "createVueTscProgram");
|
|
292
|
-
var createProgram = /* @__PURE__ */ __name((remoteOptions, programOptions) => {
|
|
293
|
-
switch (remoteOptions.compilerInstance) {
|
|
294
|
-
case "vue-tsc":
|
|
295
|
-
return createVueTscProgram(programOptions);
|
|
296
|
-
case "tsc":
|
|
297
|
-
default:
|
|
298
|
-
return import_typescript2.default.createProgram(programOptions);
|
|
299
|
-
}
|
|
300
|
-
}, "createProgram");
|
|
301
|
-
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => {
|
|
302
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
303
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
|
|
304
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
305
|
-
const tsHost = createHost(mapComponentsToExpose, tsConfig, remoteOptions, cb);
|
|
306
|
-
const filesToCompile = [
|
|
307
|
-
...Object.values(mapComponentsToExpose),
|
|
308
|
-
...remoteOptions.additionalFilesToCompile
|
|
309
|
-
];
|
|
310
|
-
const programOptions = {
|
|
311
|
-
rootNames: filesToCompile,
|
|
312
|
-
host: tsHost,
|
|
313
|
-
options: tsConfig
|
|
314
|
-
};
|
|
315
|
-
const tsProgram = createProgram(remoteOptions, programOptions);
|
|
316
|
-
const { diagnostics = [] } = tsProgram.emit();
|
|
317
|
-
diagnostics.forEach(reportCompileDiagnostic);
|
|
318
|
-
if (remoteOptions.extractThirdParty) {
|
|
319
|
-
thirdPartyExtractor.copyDts();
|
|
385
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
386
|
+
} catch (err) {
|
|
387
|
+
throw err;
|
|
320
388
|
}
|
|
321
|
-
}, "compileTs");
|
|
389
|
+
}), "compileTs");
|
|
322
390
|
|
|
323
391
|
// packages/dts-plugin/src/server/message/Message.ts
|
|
324
392
|
var _Message = class _Message {
|
|
@@ -391,7 +459,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
391
459
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
392
460
|
|
|
393
461
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
394
|
-
var
|
|
462
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
395
463
|
|
|
396
464
|
// packages/dts-plugin/src/server/utils/logTransform.ts
|
|
397
465
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -430,7 +498,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
430
498
|
var BrokerExitLog = _BrokerExitLog;
|
|
431
499
|
|
|
432
500
|
// packages/dts-plugin/src/server/utils/log.ts
|
|
433
|
-
var
|
|
501
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
434
502
|
var log4js = __toESM(require("log4js"));
|
|
435
503
|
var import_chalk2 = __toESM(require("chalk"));
|
|
436
504
|
|
|
@@ -485,7 +553,7 @@ __name(error, "error");
|
|
|
485
553
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
486
554
|
function getIdentifier(options) {
|
|
487
555
|
const { ip, name } = options;
|
|
488
|
-
return `mf ${
|
|
556
|
+
return `mf ${import_sdk3.SEPARATOR}${name}${ip ? `${import_sdk3.SEPARATOR}${ip}` : ""}`;
|
|
489
557
|
}
|
|
490
558
|
__name(getIdentifier, "getIdentifier");
|
|
491
559
|
|
|
@@ -583,7 +651,7 @@ var Publisher = _Publisher;
|
|
|
583
651
|
var import_isomorphic_ws2 = __toESM(require("isomorphic-ws"));
|
|
584
652
|
|
|
585
653
|
// packages/dts-plugin/src/core/configurations/hostPlugin.ts
|
|
586
|
-
var
|
|
654
|
+
var import_sdk4 = require("@module-federation/sdk");
|
|
587
655
|
var import_managers2 = require("@module-federation/managers");
|
|
588
656
|
var defaultOptions2 = {
|
|
589
657
|
typesFolder: "@mf-types",
|
|
@@ -610,10 +678,10 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
610
678
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
611
679
|
const { hostOptions, remoteAlias, remote } = options;
|
|
612
680
|
let decodedRemote = remote;
|
|
613
|
-
if (decodedRemote.startsWith(
|
|
614
|
-
decodedRemote = (0,
|
|
681
|
+
if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
|
|
682
|
+
decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
|
|
615
683
|
}
|
|
616
|
-
const parsedInfo = (0,
|
|
684
|
+
const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
|
|
617
685
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
618
686
|
const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
|
|
619
687
|
return {
|
|
@@ -750,7 +818,7 @@ __name(wrapRpc, "wrapRpc");
|
|
|
750
818
|
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
751
819
|
var child_process = __toESM(require("child_process"));
|
|
752
820
|
var process3 = __toESM(require("process"));
|
|
753
|
-
var
|
|
821
|
+
var import_crypto2 = require("crypto");
|
|
754
822
|
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
755
823
|
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
756
824
|
const options = {
|
|
@@ -771,7 +839,7 @@ function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
|
771
839
|
];
|
|
772
840
|
}
|
|
773
841
|
let childProcess, remoteMethod;
|
|
774
|
-
const id = (0,
|
|
842
|
+
const id = (0, import_crypto2.randomUUID)();
|
|
775
843
|
const worker = {
|
|
776
844
|
connect(...args) {
|
|
777
845
|
if (childProcess && !childProcess.connected) {
|
|
@@ -1436,7 +1504,7 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1436
1504
|
var Broker = _Broker;
|
|
1437
1505
|
|
|
1438
1506
|
// packages/dts-plugin/src/server/createKoaServer.ts
|
|
1439
|
-
var
|
|
1507
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
1440
1508
|
var import_koa = __toESM(require("koa"));
|
|
1441
1509
|
|
|
1442
1510
|
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
@@ -1467,7 +1535,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1467
1535
|
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1468
1536
|
try {
|
|
1469
1537
|
if (hostOptions.deleteTypesFolder) {
|
|
1470
|
-
yield (0,
|
|
1538
|
+
yield (0, import_promises2.rm)(destinationPath, {
|
|
1471
1539
|
recursive: true,
|
|
1472
1540
|
force: true
|
|
1473
1541
|
});
|
|
@@ -1582,7 +1650,7 @@ var DTSManager = (_a2 = class {
|
|
|
1582
1650
|
tsConfig,
|
|
1583
1651
|
mapComponentsToExpose
|
|
1584
1652
|
});
|
|
1585
|
-
compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1653
|
+
yield compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1586
1654
|
yield createTypesArchive(tsConfig, remoteOptions);
|
|
1587
1655
|
let apiTypesPath = "";
|
|
1588
1656
|
if (remoteOptions.generateAPITypes) {
|
|
@@ -1592,7 +1660,7 @@ var DTSManager = (_a2 = class {
|
|
|
1592
1660
|
}
|
|
1593
1661
|
try {
|
|
1594
1662
|
if (remoteOptions.deleteTypesFolder) {
|
|
1595
|
-
yield (0,
|
|
1663
|
+
yield (0, import_promises3.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
|
|
1596
1664
|
recursive: true,
|
|
1597
1665
|
force: true
|
|
1598
1666
|
});
|
|
@@ -1602,10 +1670,10 @@ var DTSManager = (_a2 = class {
|
|
|
1602
1670
|
console.error(err);
|
|
1603
1671
|
}
|
|
1604
1672
|
}
|
|
1605
|
-
console.log(
|
|
1673
|
+
console.log(import_ansi_colors.default.green("Federated types created correctly"));
|
|
1606
1674
|
} catch (error2) {
|
|
1607
1675
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1608
|
-
console.error(
|
|
1676
|
+
console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${error2}`));
|
|
1609
1677
|
} else {
|
|
1610
1678
|
throw error2;
|
|
1611
1679
|
}
|
|
@@ -1615,7 +1683,7 @@ var DTSManager = (_a2 = class {
|
|
|
1615
1683
|
requestRemoteManifest(remoteInfo) {
|
|
1616
1684
|
return __async(this, null, function* () {
|
|
1617
1685
|
try {
|
|
1618
|
-
if (!remoteInfo.url.includes(
|
|
1686
|
+
if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
|
|
1619
1687
|
return remoteInfo;
|
|
1620
1688
|
}
|
|
1621
1689
|
const url = remoteInfo.url;
|
|
@@ -1642,7 +1710,7 @@ var DTSManager = (_a2 = class {
|
|
|
1642
1710
|
}
|
|
1643
1711
|
}
|
|
1644
1712
|
if (publicPath === "auto") {
|
|
1645
|
-
publicPath = (0,
|
|
1713
|
+
publicPath = (0, import_sdk5.inferAutoPublicPath)(remoteInfo.url);
|
|
1646
1714
|
}
|
|
1647
1715
|
remoteInfo.zipUrl = new URL(import_path4.default.join(addProtocol(publicPath), manifestJson.metaData.types.zip)).href;
|
|
1648
1716
|
if (!manifestJson.metaData.types.api) {
|
|
@@ -1777,7 +1845,7 @@ var DTSManager = (_a2 = class {
|
|
|
1777
1845
|
})));
|
|
1778
1846
|
this.consumeAPITypes(hostOptions);
|
|
1779
1847
|
}
|
|
1780
|
-
console.log(
|
|
1848
|
+
console.log(import_ansi_colors.default.green("Federated types extraction completed"));
|
|
1781
1849
|
} catch (err) {
|
|
1782
1850
|
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1783
1851
|
fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
|
|
@@ -1798,7 +1866,7 @@ var DTSManager = (_a2 = class {
|
|
|
1798
1866
|
if (!this.options.remote) {
|
|
1799
1867
|
return;
|
|
1800
1868
|
}
|
|
1801
|
-
this.generateTypes();
|
|
1869
|
+
yield this.generateTypes();
|
|
1802
1870
|
} else {
|
|
1803
1871
|
const { remoteAliasMap } = this;
|
|
1804
1872
|
if (!this.options.host) {
|