@module-federation/dts-plugin 0.2.6 → 0.2.8
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 +19 -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 +172 -100
- package/dist/esm/{chunk-CRKFI32N.js → chunk-2RCHPGBO.js} +166 -94
- 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 +176 -104
- package/dist/fork-generate-dts.d.mts +1 -1
- package/dist/fork-generate-dts.d.ts +1 -1
- package/dist/fork-generate-dts.js +169 -97
- package/dist/index.js +191 -120
- 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,131 @@ 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
|
+
(0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
|
|
338
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
339
|
+
export { default } from './${relativePathToOutput}';`);
|
|
340
|
+
}
|
|
341
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
342
|
+
cb(content);
|
|
343
|
+
}
|
|
344
|
+
}), "processTypesFile");
|
|
345
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
346
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const { compilerOptions } = tsConfig;
|
|
350
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
|
|
351
|
+
try {
|
|
352
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
353
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
|
|
354
|
+
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
355
|
+
const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
|
|
356
|
+
try {
|
|
357
|
+
yield execPromise(cmd);
|
|
358
|
+
} catch (err) {
|
|
359
|
+
throw new Error(`compile TS failed, the original command is '${cmd}'`);
|
|
360
|
+
}
|
|
361
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
362
|
+
const normalizedFileName = (0, import_path2.normalize)(filename);
|
|
363
|
+
let relativeFileName = "";
|
|
364
|
+
if ((0, import_path2.isAbsolute)(normalizedFileName)) {
|
|
365
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
366
|
+
} else {
|
|
367
|
+
relativeFileName = (0, import_path2.relative)(tsConfig.compilerOptions.rootDir, (0, import_path2.resolve)(remoteOptions.context, normalizedFileName));
|
|
282
368
|
}
|
|
369
|
+
return [
|
|
370
|
+
removeExt(relativeFileName),
|
|
371
|
+
exposed
|
|
372
|
+
];
|
|
373
|
+
}));
|
|
374
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
375
|
+
yield processTypesFile({
|
|
376
|
+
outDir: compilerOptions.outDir,
|
|
377
|
+
filePath: compilerOptions.outDir,
|
|
378
|
+
rootDir: compilerOptions.rootDir,
|
|
379
|
+
mfTypePath,
|
|
380
|
+
cb,
|
|
381
|
+
mapExposeToEntry
|
|
382
|
+
});
|
|
383
|
+
if (remoteOptions.extractThirdParty) {
|
|
384
|
+
yield thirdPartyExtractor.copyDts();
|
|
283
385
|
}
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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();
|
|
386
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
387
|
+
} catch (err) {
|
|
388
|
+
if (isDebugMode()) {
|
|
389
|
+
console.log("tsconfig: ", JSON.stringify(tsConfig, null, 2));
|
|
390
|
+
}
|
|
391
|
+
throw err;
|
|
320
392
|
}
|
|
321
|
-
}, "compileTs");
|
|
393
|
+
}), "compileTs");
|
|
322
394
|
|
|
323
395
|
// packages/dts-plugin/src/server/message/Message.ts
|
|
324
396
|
var _Message = class _Message {
|
|
@@ -391,7 +463,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
391
463
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
392
464
|
|
|
393
465
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
394
|
-
var
|
|
466
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
395
467
|
|
|
396
468
|
// packages/dts-plugin/src/server/utils/logTransform.ts
|
|
397
469
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -430,7 +502,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
430
502
|
var BrokerExitLog = _BrokerExitLog;
|
|
431
503
|
|
|
432
504
|
// packages/dts-plugin/src/server/utils/log.ts
|
|
433
|
-
var
|
|
505
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
434
506
|
var log4js = __toESM(require("log4js"));
|
|
435
507
|
var import_chalk2 = __toESM(require("chalk"));
|
|
436
508
|
|
|
@@ -485,7 +557,7 @@ __name(error, "error");
|
|
|
485
557
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
486
558
|
function getIdentifier(options) {
|
|
487
559
|
const { ip, name } = options;
|
|
488
|
-
return `mf ${
|
|
560
|
+
return `mf ${import_sdk3.SEPARATOR}${name}${ip ? `${import_sdk3.SEPARATOR}${ip}` : ""}`;
|
|
489
561
|
}
|
|
490
562
|
__name(getIdentifier, "getIdentifier");
|
|
491
563
|
|
|
@@ -583,7 +655,7 @@ var Publisher = _Publisher;
|
|
|
583
655
|
var import_isomorphic_ws2 = __toESM(require("isomorphic-ws"));
|
|
584
656
|
|
|
585
657
|
// packages/dts-plugin/src/core/configurations/hostPlugin.ts
|
|
586
|
-
var
|
|
658
|
+
var import_sdk4 = require("@module-federation/sdk");
|
|
587
659
|
var import_managers2 = require("@module-federation/managers");
|
|
588
660
|
var defaultOptions2 = {
|
|
589
661
|
typesFolder: "@mf-types",
|
|
@@ -610,10 +682,10 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
|
|
|
610
682
|
var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
611
683
|
const { hostOptions, remoteAlias, remote } = options;
|
|
612
684
|
let decodedRemote = remote;
|
|
613
|
-
if (decodedRemote.startsWith(
|
|
614
|
-
decodedRemote = (0,
|
|
685
|
+
if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
|
|
686
|
+
decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
|
|
615
687
|
}
|
|
616
|
-
const parsedInfo = (0,
|
|
688
|
+
const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
|
|
617
689
|
const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
|
|
618
690
|
const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
|
|
619
691
|
return {
|
|
@@ -750,7 +822,7 @@ __name(wrapRpc, "wrapRpc");
|
|
|
750
822
|
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
751
823
|
var child_process = __toESM(require("child_process"));
|
|
752
824
|
var process3 = __toESM(require("process"));
|
|
753
|
-
var
|
|
825
|
+
var import_crypto2 = require("crypto");
|
|
754
826
|
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
755
827
|
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
756
828
|
const options = {
|
|
@@ -771,7 +843,7 @@ function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
|
771
843
|
];
|
|
772
844
|
}
|
|
773
845
|
let childProcess, remoteMethod;
|
|
774
|
-
const id = (0,
|
|
846
|
+
const id = (0, import_crypto2.randomUUID)();
|
|
775
847
|
const worker = {
|
|
776
848
|
connect(...args) {
|
|
777
849
|
if (childProcess && !childProcess.connected) {
|
|
@@ -1436,7 +1508,7 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1436
1508
|
var Broker = _Broker;
|
|
1437
1509
|
|
|
1438
1510
|
// packages/dts-plugin/src/server/createKoaServer.ts
|
|
1439
|
-
var
|
|
1511
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
1440
1512
|
var import_koa = __toESM(require("koa"));
|
|
1441
1513
|
|
|
1442
1514
|
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
@@ -1467,7 +1539,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1467
1539
|
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1468
1540
|
try {
|
|
1469
1541
|
if (hostOptions.deleteTypesFolder) {
|
|
1470
|
-
yield (0,
|
|
1542
|
+
yield (0, import_promises2.rm)(destinationPath, {
|
|
1471
1543
|
recursive: true,
|
|
1472
1544
|
force: true
|
|
1473
1545
|
});
|
|
@@ -1577,12 +1649,12 @@ var DTSManager = (_a2 = class {
|
|
|
1577
1649
|
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1578
1650
|
return;
|
|
1579
1651
|
}
|
|
1580
|
-
this.extractRemoteTypes({
|
|
1652
|
+
yield this.extractRemoteTypes({
|
|
1581
1653
|
remoteOptions,
|
|
1582
1654
|
tsConfig,
|
|
1583
1655
|
mapComponentsToExpose
|
|
1584
1656
|
});
|
|
1585
|
-
compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1657
|
+
yield compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
|
|
1586
1658
|
yield createTypesArchive(tsConfig, remoteOptions);
|
|
1587
1659
|
let apiTypesPath = "";
|
|
1588
1660
|
if (remoteOptions.generateAPITypes) {
|
|
@@ -1592,7 +1664,7 @@ var DTSManager = (_a2 = class {
|
|
|
1592
1664
|
}
|
|
1593
1665
|
try {
|
|
1594
1666
|
if (remoteOptions.deleteTypesFolder) {
|
|
1595
|
-
yield (0,
|
|
1667
|
+
yield (0, import_promises3.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
|
|
1596
1668
|
recursive: true,
|
|
1597
1669
|
force: true
|
|
1598
1670
|
});
|
|
@@ -1602,10 +1674,10 @@ var DTSManager = (_a2 = class {
|
|
|
1602
1674
|
console.error(err);
|
|
1603
1675
|
}
|
|
1604
1676
|
}
|
|
1605
|
-
console.log(
|
|
1677
|
+
console.log(import_ansi_colors.default.green("Federated types created correctly"));
|
|
1606
1678
|
} catch (error2) {
|
|
1607
1679
|
if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1608
|
-
console.error(
|
|
1680
|
+
console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${error2}`));
|
|
1609
1681
|
} else {
|
|
1610
1682
|
throw error2;
|
|
1611
1683
|
}
|
|
@@ -1615,7 +1687,7 @@ var DTSManager = (_a2 = class {
|
|
|
1615
1687
|
requestRemoteManifest(remoteInfo) {
|
|
1616
1688
|
return __async(this, null, function* () {
|
|
1617
1689
|
try {
|
|
1618
|
-
if (!remoteInfo.url.includes(
|
|
1690
|
+
if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
|
|
1619
1691
|
return remoteInfo;
|
|
1620
1692
|
}
|
|
1621
1693
|
const url = remoteInfo.url;
|
|
@@ -1642,7 +1714,7 @@ var DTSManager = (_a2 = class {
|
|
|
1642
1714
|
}
|
|
1643
1715
|
}
|
|
1644
1716
|
if (publicPath === "auto") {
|
|
1645
|
-
publicPath = (0,
|
|
1717
|
+
publicPath = (0, import_sdk5.inferAutoPublicPath)(remoteInfo.url);
|
|
1646
1718
|
}
|
|
1647
1719
|
remoteInfo.zipUrl = new URL(import_path4.default.join(addProtocol(publicPath), manifestJson.metaData.types.zip)).href;
|
|
1648
1720
|
if (!manifestJson.metaData.types.api) {
|
|
@@ -1777,7 +1849,7 @@ var DTSManager = (_a2 = class {
|
|
|
1777
1849
|
})));
|
|
1778
1850
|
this.consumeAPITypes(hostOptions);
|
|
1779
1851
|
}
|
|
1780
|
-
console.log(
|
|
1852
|
+
console.log(import_ansi_colors.default.green("Federated types extraction completed"));
|
|
1781
1853
|
} catch (err) {
|
|
1782
1854
|
if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
|
|
1783
1855
|
fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
|
|
@@ -1798,7 +1870,7 @@ var DTSManager = (_a2 = class {
|
|
|
1798
1870
|
if (!this.options.remote) {
|
|
1799
1871
|
return;
|
|
1800
1872
|
}
|
|
1801
|
-
this.generateTypes();
|
|
1873
|
+
yield this.generateTypes();
|
|
1802
1874
|
} else {
|
|
1803
1875
|
const { remoteAliasMap } = this;
|
|
1804
1876
|
if (!this.options.host) {
|