@module-federation/dts-plugin 0.11.1 → 0.11.3
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 +20 -0
- package/dist/{DtsWorker-bfe21fe7.d.ts → DTSManager-81645796.d.ts} +1 -53
- package/dist/DtsWorker-c39c84fb.d.ts +56 -0
- package/dist/core.d.mts +7 -15
- package/dist/core.d.ts +7 -15
- package/dist/core.js +28 -3
- package/dist/esm/{chunk-KCWHOFI6.js → chunk-56UE3H52.js} +1 -1
- package/dist/esm/{chunk-4XJKD7QF.js → chunk-A4MGPQ34.js} +29 -4
- package/dist/esm/{chunk-UUXLCZNG.js → chunk-GX5A7XT2.js} +2 -2
- package/dist/esm/{chunk-QAUALHAU.js → chunk-L22LIZUP.js} +1 -1
- package/dist/esm/{chunk-4CSLH7II.js → chunk-SPSJLB6F.js} +1 -1
- package/dist/esm/core.js +4 -4
- package/dist/esm/dynamic-remote-type-hints-plugin.js +2 -2
- package/dist/esm/fork-dev-worker.js +5 -5
- package/dist/esm/fork-generate-dts.js +3 -3
- package/dist/esm/index.js +175 -118
- package/dist/esm/start-broker.js +2 -2
- package/dist/fork-dev-worker.js +28 -3
- package/dist/fork-generate-dts.d.mts +2 -1
- package/dist/fork-generate-dts.d.ts +2 -1
- package/dist/fork-generate-dts.js +28 -3
- package/dist/index.d.mts +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +206 -118
- package/dist/package.json +2 -2
- package/dist/start-broker.js +1 -1
- package/dist/utils-0ec746b7.d.ts +16 -0
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
consumeTypes,
|
|
3
3
|
generateTypesInChildProcess,
|
|
4
4
|
rpc_exports
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GX5A7XT2.js";
|
|
6
6
|
import {
|
|
7
7
|
cloneDeepOptions,
|
|
8
8
|
generateTypes,
|
|
9
9
|
isTSProject,
|
|
10
10
|
retrieveTypesAssetsInfo,
|
|
11
11
|
validateOptions
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-A4MGPQ34.js";
|
|
13
13
|
import {
|
|
14
14
|
getIPV4,
|
|
15
15
|
logger
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-56UE3H52.js";
|
|
17
17
|
import {
|
|
18
18
|
WEB_CLIENT_OPTIONS_IDENTIFIER,
|
|
19
19
|
__async,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
__publicField,
|
|
22
22
|
__spreadProps,
|
|
23
23
|
__spreadValues
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-SPSJLB6F.js";
|
|
25
25
|
|
|
26
26
|
// packages/dts-plugin/src/plugins/DevPlugin.ts
|
|
27
27
|
import fs from "fs-extra";
|
|
@@ -283,52 +283,68 @@ import { normalizeOptions as normalizeOptions4 } from "@module-federation/sdk";
|
|
|
283
283
|
// packages/dts-plugin/src/plugins/ConsumeTypesPlugin.ts
|
|
284
284
|
import { logger as logger2 } from "@module-federation/sdk";
|
|
285
285
|
import { normalizeOptions as normalizeOptions2 } from "@module-federation/sdk";
|
|
286
|
+
var DEFAULT_CONSUME_TYPES = {
|
|
287
|
+
abortOnError: false,
|
|
288
|
+
consumeAPITypes: true
|
|
289
|
+
};
|
|
290
|
+
var normalizeConsumeTypesOptions = /* @__PURE__ */ __name(({ context, dtsOptions, pluginOptions }) => {
|
|
291
|
+
const normalizedConsumeTypes = normalizeOptions2(true, DEFAULT_CONSUME_TYPES, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
292
|
+
if (!normalizedConsumeTypes) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const dtsManagerOptions = {
|
|
296
|
+
host: __spreadValues({
|
|
297
|
+
implementation: dtsOptions.implementation,
|
|
298
|
+
context,
|
|
299
|
+
moduleFederationConfig: pluginOptions
|
|
300
|
+
}, normalizedConsumeTypes),
|
|
301
|
+
extraOptions: dtsOptions.extraOptions || {},
|
|
302
|
+
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
303
|
+
};
|
|
304
|
+
validateOptions(dtsManagerOptions.host);
|
|
305
|
+
return dtsManagerOptions;
|
|
306
|
+
}, "normalizeConsumeTypesOptions");
|
|
307
|
+
var consumeTypesAPI = /* @__PURE__ */ __name((dtsManagerOptions, cb) => __async(void 0, null, function* () {
|
|
308
|
+
const fetchRemoteTypeUrlsPromise = typeof dtsManagerOptions.host.remoteTypeUrls === "function" ? dtsManagerOptions.host.remoteTypeUrls() : Promise.resolve(dtsManagerOptions.host.remoteTypeUrls);
|
|
309
|
+
return fetchRemoteTypeUrlsPromise.then((remoteTypeUrls) => {
|
|
310
|
+
consumeTypes(__spreadProps(__spreadValues({}, dtsManagerOptions), {
|
|
311
|
+
host: __spreadProps(__spreadValues({}, dtsManagerOptions.host), {
|
|
312
|
+
remoteTypeUrls
|
|
313
|
+
})
|
|
314
|
+
})).then(() => {
|
|
315
|
+
typeof cb === "function" && cb(remoteTypeUrls);
|
|
316
|
+
}).catch(() => {
|
|
317
|
+
typeof cb === "function" && cb(remoteTypeUrls);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}), "consumeTypesAPI");
|
|
286
321
|
var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
287
|
-
constructor(pluginOptions, dtsOptions,
|
|
322
|
+
constructor(pluginOptions, dtsOptions, fetchRemoteTypeUrlsResolve) {
|
|
288
323
|
__publicField(this, "pluginOptions");
|
|
289
324
|
__publicField(this, "dtsOptions");
|
|
290
|
-
__publicField(this, "defaultOptions");
|
|
291
325
|
__publicField(this, "callback");
|
|
292
326
|
__publicField(this, "fetchRemoteTypeUrlsResolve");
|
|
293
327
|
this.pluginOptions = pluginOptions;
|
|
294
328
|
this.dtsOptions = dtsOptions;
|
|
295
|
-
this.defaultOptions = defaultOptions;
|
|
296
329
|
this.fetchRemoteTypeUrlsResolve = fetchRemoteTypeUrlsResolve;
|
|
297
330
|
}
|
|
298
331
|
apply(compiler) {
|
|
299
|
-
const { dtsOptions,
|
|
332
|
+
const { dtsOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
|
|
300
333
|
if (isPrd()) {
|
|
301
334
|
fetchRemoteTypeUrlsResolve(void 0);
|
|
302
335
|
return;
|
|
303
336
|
}
|
|
304
|
-
const
|
|
305
|
-
|
|
337
|
+
const dtsManagerOptions = normalizeConsumeTypesOptions({
|
|
338
|
+
context: compiler.context,
|
|
339
|
+
dtsOptions,
|
|
340
|
+
pluginOptions
|
|
341
|
+
});
|
|
342
|
+
if (!dtsManagerOptions) {
|
|
306
343
|
fetchRemoteTypeUrlsResolve(void 0);
|
|
307
344
|
return;
|
|
308
345
|
}
|
|
309
|
-
const finalOptions = {
|
|
310
|
-
host: __spreadValues({
|
|
311
|
-
implementation: dtsOptions.implementation,
|
|
312
|
-
context: compiler.context,
|
|
313
|
-
moduleFederationConfig: pluginOptions
|
|
314
|
-
}, normalizedConsumeTypes),
|
|
315
|
-
extraOptions: dtsOptions.extraOptions || {},
|
|
316
|
-
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
317
|
-
};
|
|
318
|
-
validateOptions(finalOptions.host);
|
|
319
|
-
const fetchRemoteTypeUrlsPromise = typeof normalizedConsumeTypes.remoteTypeUrls === "function" ? normalizedConsumeTypes.remoteTypeUrls() : Promise.resolve(normalizedConsumeTypes.remoteTypeUrls);
|
|
320
346
|
logger2.debug("start fetching remote types...");
|
|
321
|
-
const promise =
|
|
322
|
-
consumeTypes(__spreadProps(__spreadValues({}, finalOptions), {
|
|
323
|
-
host: __spreadProps(__spreadValues({}, finalOptions.host), {
|
|
324
|
-
remoteTypeUrls
|
|
325
|
-
})
|
|
326
|
-
})).then(() => {
|
|
327
|
-
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
328
|
-
}).catch(() => {
|
|
329
|
-
fetchRemoteTypeUrlsResolve(remoteTypeUrls);
|
|
330
|
-
});
|
|
331
|
-
});
|
|
347
|
+
const promise = consumeTypesAPI(dtsManagerOptions, fetchRemoteTypeUrlsResolve);
|
|
332
348
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
333
349
|
compilation.hooks.processAssets.tapPromise({
|
|
334
350
|
name: "mf:generateTypes",
|
|
@@ -350,70 +366,89 @@ var ConsumeTypesPlugin = _ConsumeTypesPlugin;
|
|
|
350
366
|
import fs2 from "fs";
|
|
351
367
|
import path5 from "path";
|
|
352
368
|
import { logger as logger3, normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
|
|
369
|
+
var DEFAULT_GENERATE_TYPES = {
|
|
370
|
+
generateAPITypes: true,
|
|
371
|
+
compileInChildProcess: true,
|
|
372
|
+
abortOnError: false,
|
|
373
|
+
extractThirdParty: false,
|
|
374
|
+
extractRemoteTypes: false
|
|
375
|
+
};
|
|
376
|
+
var normalizeGenerateTypesOptions = /* @__PURE__ */ __name(({ context, outputDir, dtsOptions, pluginOptions }) => {
|
|
377
|
+
const normalizedGenerateTypes = normalizeOptions3(true, DEFAULT_GENERATE_TYPES, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
|
|
378
|
+
if (!normalizedGenerateTypes) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const normalizedConsumeTypes = normalizeOptions3(true, {}, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
382
|
+
const finalOptions = {
|
|
383
|
+
remote: __spreadValues({
|
|
384
|
+
implementation: dtsOptions.implementation,
|
|
385
|
+
context,
|
|
386
|
+
outputDir,
|
|
387
|
+
moduleFederationConfig: pluginOptions
|
|
388
|
+
}, normalizedGenerateTypes),
|
|
389
|
+
host: normalizedConsumeTypes === false ? void 0 : __spreadValues({
|
|
390
|
+
context,
|
|
391
|
+
moduleFederationConfig: pluginOptions
|
|
392
|
+
}, normalizedGenerateTypes),
|
|
393
|
+
extraOptions: dtsOptions.extraOptions || {},
|
|
394
|
+
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
395
|
+
};
|
|
396
|
+
if (dtsOptions.tsConfigPath && !finalOptions.remote.tsConfigPath) {
|
|
397
|
+
finalOptions.remote.tsConfigPath = dtsOptions.tsConfigPath;
|
|
398
|
+
}
|
|
399
|
+
validateOptions(finalOptions.remote);
|
|
400
|
+
return finalOptions;
|
|
401
|
+
}, "normalizeGenerateTypesOptions");
|
|
402
|
+
var getGenerateTypesFn = /* @__PURE__ */ __name((dtsManagerOptions) => {
|
|
403
|
+
let fn = generateTypes;
|
|
404
|
+
if (dtsManagerOptions.remote.compileInChildProcess) {
|
|
405
|
+
fn = generateTypesInChildProcess;
|
|
406
|
+
}
|
|
407
|
+
return fn;
|
|
408
|
+
}, "getGenerateTypesFn");
|
|
409
|
+
var generateTypesAPI = /* @__PURE__ */ __name(({ dtsManagerOptions }) => {
|
|
410
|
+
const fn = getGenerateTypesFn(dtsManagerOptions);
|
|
411
|
+
return fn(dtsManagerOptions);
|
|
412
|
+
}, "generateTypesAPI");
|
|
353
413
|
var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
354
|
-
constructor(pluginOptions, dtsOptions,
|
|
414
|
+
constructor(pluginOptions, dtsOptions, fetchRemoteTypeUrlsPromise, callback) {
|
|
355
415
|
__publicField(this, "pluginOptions");
|
|
356
416
|
__publicField(this, "dtsOptions");
|
|
357
|
-
__publicField(this, "defaultOptions");
|
|
358
417
|
__publicField(this, "fetchRemoteTypeUrlsPromise");
|
|
359
418
|
__publicField(this, "callback");
|
|
360
419
|
this.pluginOptions = pluginOptions;
|
|
361
420
|
this.dtsOptions = dtsOptions;
|
|
362
|
-
this.defaultOptions = defaultOptions;
|
|
363
421
|
this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
|
|
364
422
|
this.callback = callback;
|
|
365
423
|
}
|
|
366
424
|
apply(compiler) {
|
|
367
|
-
const { dtsOptions,
|
|
368
|
-
const
|
|
369
|
-
|
|
425
|
+
const { dtsOptions, pluginOptions, fetchRemoteTypeUrlsPromise, callback } = this;
|
|
426
|
+
const outputDir = getCompilerOutputDir(compiler);
|
|
427
|
+
const context = compiler.context;
|
|
428
|
+
const dtsManagerOptions = normalizeGenerateTypesOptions({
|
|
429
|
+
context,
|
|
430
|
+
outputDir,
|
|
431
|
+
dtsOptions,
|
|
432
|
+
pluginOptions
|
|
433
|
+
});
|
|
434
|
+
if (!dtsManagerOptions) {
|
|
370
435
|
callback();
|
|
371
436
|
return;
|
|
372
437
|
}
|
|
373
|
-
const normalizedConsumeTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
|
|
374
|
-
const finalOptions = {
|
|
375
|
-
remote: __spreadValues({
|
|
376
|
-
implementation: dtsOptions.implementation,
|
|
377
|
-
context: compiler.context,
|
|
378
|
-
outputDir: getCompilerOutputDir(compiler),
|
|
379
|
-
moduleFederationConfig: pluginOptions
|
|
380
|
-
}, normalizedGenerateTypes),
|
|
381
|
-
host: normalizedConsumeTypes === false ? void 0 : __spreadValues({
|
|
382
|
-
context: compiler.context,
|
|
383
|
-
moduleFederationConfig: pluginOptions
|
|
384
|
-
}, normalizedGenerateTypes),
|
|
385
|
-
extraOptions: dtsOptions.extraOptions || {},
|
|
386
|
-
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
387
|
-
};
|
|
388
|
-
if (dtsOptions.tsConfigPath && !finalOptions.remote.tsConfigPath) {
|
|
389
|
-
finalOptions.remote.tsConfigPath = dtsOptions.tsConfigPath;
|
|
390
|
-
}
|
|
391
|
-
validateOptions(finalOptions.remote);
|
|
392
438
|
const isProd = !isDev();
|
|
393
|
-
const getGenerateTypesFn = /* @__PURE__ */ __name(() => {
|
|
394
|
-
let fn = generateTypes;
|
|
395
|
-
let res;
|
|
396
|
-
if (finalOptions.remote.compileInChildProcess) {
|
|
397
|
-
fn = generateTypesInChildProcess;
|
|
398
|
-
}
|
|
399
|
-
if (isProd) {
|
|
400
|
-
res = fn(finalOptions);
|
|
401
|
-
return () => res;
|
|
402
|
-
}
|
|
403
|
-
return fn;
|
|
404
|
-
}, "getGenerateTypesFn");
|
|
405
|
-
const generateTypesFn = getGenerateTypesFn();
|
|
406
439
|
const emitTypesFiles = /* @__PURE__ */ __name((compilation) => __async(this, null, function* () {
|
|
407
440
|
try {
|
|
408
|
-
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(
|
|
441
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(dtsManagerOptions.remote);
|
|
409
442
|
if (isProd && zipName && compilation.getAsset(zipName)) {
|
|
410
443
|
callback();
|
|
411
444
|
return;
|
|
412
445
|
}
|
|
413
446
|
logger3.debug("start generating types...");
|
|
414
|
-
yield
|
|
447
|
+
yield generateTypesAPI({
|
|
448
|
+
dtsManagerOptions
|
|
449
|
+
});
|
|
415
450
|
logger3.debug("generate types success!");
|
|
416
|
-
const config =
|
|
451
|
+
const config = dtsManagerOptions.remote.moduleFederationConfig;
|
|
417
452
|
let zipPrefix = "";
|
|
418
453
|
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
419
454
|
zipPrefix = config.manifest.filePath;
|
|
@@ -440,45 +475,69 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
440
475
|
const zipContent = fs2.readFileSync(zipTypesPath);
|
|
441
476
|
const zipOutputPath = path5.join(compiler.outputPath, zipPrefix, zipName);
|
|
442
477
|
yield new Promise((resolve2, reject) => {
|
|
443
|
-
compiler.outputFileSystem.mkdir(
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
478
|
+
compiler.outputFileSystem.mkdir(
|
|
479
|
+
path5.dirname(zipOutputPath),
|
|
480
|
+
{
|
|
481
|
+
recursive: true
|
|
482
|
+
},
|
|
483
|
+
// @ts-ignore type fixed in https://github.com/webpack/webpack/releases/tag/v5.91.0
|
|
484
|
+
(err) => {
|
|
485
|
+
if (err && !isEEXIST(err)) {
|
|
486
|
+
reject(err);
|
|
487
|
+
} else {
|
|
488
|
+
compiler.outputFileSystem.writeFile(
|
|
489
|
+
zipOutputPath,
|
|
490
|
+
// @ts-ignore
|
|
491
|
+
zipContent,
|
|
492
|
+
(writeErr) => {
|
|
493
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
494
|
+
reject(writeErr);
|
|
495
|
+
} else {
|
|
496
|
+
resolve2();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
454
501
|
}
|
|
455
|
-
|
|
502
|
+
);
|
|
456
503
|
});
|
|
457
504
|
}
|
|
458
505
|
if (apiTypesPath) {
|
|
459
506
|
const apiContent = fs2.readFileSync(apiTypesPath);
|
|
460
507
|
const apiOutputPath = path5.join(compiler.outputPath, zipPrefix, apiFileName);
|
|
461
508
|
yield new Promise((resolve2, reject) => {
|
|
462
|
-
compiler.outputFileSystem.mkdir(
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
509
|
+
compiler.outputFileSystem.mkdir(
|
|
510
|
+
path5.dirname(apiOutputPath),
|
|
511
|
+
{
|
|
512
|
+
recursive: true
|
|
513
|
+
},
|
|
514
|
+
// @ts-ignore type fixed in https://github.com/webpack/webpack/releases/tag/v5.91.0
|
|
515
|
+
(err) => {
|
|
516
|
+
if (err && !isEEXIST(err)) {
|
|
517
|
+
reject(err);
|
|
518
|
+
} else {
|
|
519
|
+
compiler.outputFileSystem.writeFile(
|
|
520
|
+
apiOutputPath,
|
|
521
|
+
// @ts-ignore
|
|
522
|
+
apiContent,
|
|
523
|
+
(writeErr) => {
|
|
524
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
525
|
+
reject(writeErr);
|
|
526
|
+
} else {
|
|
527
|
+
resolve2();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
}
|
|
473
532
|
}
|
|
474
|
-
|
|
533
|
+
);
|
|
475
534
|
});
|
|
476
535
|
}
|
|
477
536
|
callback();
|
|
478
537
|
}
|
|
479
538
|
} catch (err) {
|
|
480
539
|
callback();
|
|
481
|
-
if (
|
|
540
|
+
if (dtsManagerOptions.displayErrorInTerminal) {
|
|
482
541
|
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
483
542
|
}
|
|
484
543
|
logger3.debug("generate types fail!");
|
|
@@ -505,6 +564,14 @@ __name(_GenerateTypesPlugin, "GenerateTypesPlugin");
|
|
|
505
564
|
var GenerateTypesPlugin = _GenerateTypesPlugin;
|
|
506
565
|
|
|
507
566
|
// packages/dts-plugin/src/plugins/DtsPlugin.ts
|
|
567
|
+
var normalizeDtsOptions = /* @__PURE__ */ __name((options, context, defaultOptions) => {
|
|
568
|
+
return normalizeOptions4(isTSProject(options.dts, context), {
|
|
569
|
+
generateTypes: (defaultOptions == null ? void 0 : defaultOptions.defaultGenerateOptions) || DEFAULT_GENERATE_TYPES,
|
|
570
|
+
consumeTypes: (defaultOptions == null ? void 0 : defaultOptions.defaultConsumeOptions) || DEFAULT_CONSUME_TYPES,
|
|
571
|
+
extraOptions: {},
|
|
572
|
+
displayErrorInTerminal: true
|
|
573
|
+
}, "mfOptions.dts")(options.dts);
|
|
574
|
+
}, "normalizeDtsOptions");
|
|
508
575
|
var _DtsPlugin = class _DtsPlugin {
|
|
509
576
|
constructor(options) {
|
|
510
577
|
__publicField(this, "options");
|
|
@@ -512,23 +579,7 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
512
579
|
}
|
|
513
580
|
apply(compiler) {
|
|
514
581
|
const { options } = this;
|
|
515
|
-
const
|
|
516
|
-
generateAPITypes: true,
|
|
517
|
-
compileInChildProcess: true,
|
|
518
|
-
abortOnError: false,
|
|
519
|
-
extractThirdParty: false,
|
|
520
|
-
extractRemoteTypes: false
|
|
521
|
-
};
|
|
522
|
-
const defaultConsumeTypes = {
|
|
523
|
-
abortOnError: false,
|
|
524
|
-
consumeAPITypes: true
|
|
525
|
-
};
|
|
526
|
-
const normalizedDtsOptions = normalizeOptions4(isTSProject(options.dts, compiler.context), {
|
|
527
|
-
generateTypes: defaultGenerateTypes,
|
|
528
|
-
consumeTypes: defaultConsumeTypes,
|
|
529
|
-
extraOptions: {},
|
|
530
|
-
displayErrorInTerminal: true
|
|
531
|
-
}, "mfOptions.dts")(options.dts);
|
|
582
|
+
const normalizedDtsOptions = normalizeDtsOptions(options, compiler.context);
|
|
532
583
|
if (typeof normalizedDtsOptions !== "object") {
|
|
533
584
|
return;
|
|
534
585
|
}
|
|
@@ -541,12 +592,18 @@ var _DtsPlugin = class _DtsPlugin {
|
|
|
541
592
|
generateTypesPromiseResolve = resolve2;
|
|
542
593
|
});
|
|
543
594
|
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
|
|
544
|
-
new GenerateTypesPlugin(options, normalizedDtsOptions,
|
|
545
|
-
new ConsumeTypesPlugin(options, normalizedDtsOptions,
|
|
595
|
+
new GenerateTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
|
|
596
|
+
new ConsumeTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsResolve).apply(compiler);
|
|
546
597
|
}
|
|
547
598
|
};
|
|
548
599
|
__name(_DtsPlugin, "DtsPlugin");
|
|
549
600
|
var DtsPlugin = _DtsPlugin;
|
|
550
601
|
export {
|
|
551
|
-
DtsPlugin
|
|
602
|
+
DtsPlugin,
|
|
603
|
+
consumeTypesAPI,
|
|
604
|
+
generateTypesAPI,
|
|
605
|
+
isTSProject,
|
|
606
|
+
normalizeConsumeTypesOptions,
|
|
607
|
+
normalizeDtsOptions,
|
|
608
|
+
normalizeGenerateTypesOptions
|
|
552
609
|
};
|
package/dist/esm/start-broker.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Broker,
|
|
3
3
|
fileLog
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-56UE3H52.js";
|
|
5
5
|
import {
|
|
6
6
|
__async,
|
|
7
7
|
__name
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SPSJLB6F.js";
|
|
9
9
|
|
|
10
10
|
// packages/dts-plugin/src/server/broker/startBroker.ts
|
|
11
11
|
var broker;
|
package/dist/fork-dev-worker.js
CHANGED
|
@@ -354,7 +354,7 @@ var log4js = __toESM(require("log4js"));
|
|
|
354
354
|
// packages/dts-plugin/src/server/constant.ts
|
|
355
355
|
var DEFAULT_WEB_SOCKET_PORT = 16322;
|
|
356
356
|
var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
|
|
357
|
-
var MF_SERVER_IDENTIFIER = "Module Federation
|
|
357
|
+
var MF_SERVER_IDENTIFIER = "Module Federation DTS";
|
|
358
358
|
var DEFAULT_TAR_NAME = "@mf-types.zip";
|
|
359
359
|
var UpdateMode;
|
|
360
360
|
(function(UpdateMode2) {
|
|
@@ -1703,6 +1703,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1703
1703
|
} catch (error2) {
|
|
1704
1704
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1705
1705
|
if (retries >= hostOptions.maxRetries) {
|
|
1706
|
+
logger.error(`Failed to download ${fileToDownload}, you can set FEDERATION_DEBUG=true to see detail message.`);
|
|
1706
1707
|
if (hostOptions.abortOnError !== false) {
|
|
1707
1708
|
throw error2;
|
|
1708
1709
|
}
|
|
@@ -1772,6 +1773,7 @@ var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
|
1772
1773
|
};
|
|
1773
1774
|
}, "retrieveRemoteInfo");
|
|
1774
1775
|
var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
1776
|
+
var _a3;
|
|
1775
1777
|
const parsedOptions = import_managers.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
|
|
1776
1778
|
remote: Array.isArray(item) ? item[0] : item,
|
|
1777
1779
|
key
|
|
@@ -1779,15 +1781,38 @@ var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1779
1781
|
remote: Array.isArray(item.external) ? item.external[0] : item.external,
|
|
1780
1782
|
key
|
|
1781
1783
|
}));
|
|
1784
|
+
const remoteTypeUrls = (_a3 = hostOptions.remoteTypeUrls) != null ? _a3 : {};
|
|
1785
|
+
if (typeof remoteTypeUrls !== "object") {
|
|
1786
|
+
throw new Error("remoteTypeUrls must be consumed before resolveRemotes");
|
|
1787
|
+
}
|
|
1788
|
+
const remoteInfos = Object.keys(remoteTypeUrls).reduce((sum, remoteName) => {
|
|
1789
|
+
const { zip, api, alias } = remoteTypeUrls[remoteName];
|
|
1790
|
+
sum[alias] = {
|
|
1791
|
+
name: remoteName,
|
|
1792
|
+
url: "",
|
|
1793
|
+
zipUrl: zip,
|
|
1794
|
+
apiTypeUrl: api,
|
|
1795
|
+
alias: alias || remoteName
|
|
1796
|
+
};
|
|
1797
|
+
return sum;
|
|
1798
|
+
}, {});
|
|
1782
1799
|
return parsedOptions.reduce((accumulator, item) => {
|
|
1783
1800
|
const { key, remote } = item[1];
|
|
1784
|
-
|
|
1801
|
+
const res = retrieveRemoteInfo({
|
|
1785
1802
|
hostOptions,
|
|
1786
1803
|
remoteAlias: key,
|
|
1787
1804
|
remote
|
|
1788
1805
|
});
|
|
1806
|
+
if (accumulator[key]) {
|
|
1807
|
+
accumulator[key] = __spreadProps(__spreadValues({}, accumulator[key]), {
|
|
1808
|
+
url: res.url,
|
|
1809
|
+
apiTypeUrl: accumulator[key].apiTypeUrl || res.apiTypeUrl
|
|
1810
|
+
});
|
|
1811
|
+
return accumulator;
|
|
1812
|
+
}
|
|
1813
|
+
accumulator[key] = res;
|
|
1789
1814
|
return accumulator;
|
|
1790
|
-
},
|
|
1815
|
+
}, remoteInfos);
|
|
1791
1816
|
}, "resolveRemotes");
|
|
1792
1817
|
var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
|
|
1793
1818
|
validateOptions(options);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as DtsWorkerOptions } from './DtsWorker-c39c84fb.js';
|
|
2
2
|
import 'child_process';
|
|
3
3
|
import './DTSManagerOptions-c74c59ed.js';
|
|
4
4
|
import '@module-federation/sdk';
|
|
5
|
+
import './DTSManager-81645796.js';
|
|
5
6
|
import 'typescript';
|
|
6
7
|
|
|
7
8
|
declare function forkGenerateDts(options: DtsWorkerOptions): Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as DtsWorkerOptions } from './DtsWorker-c39c84fb.js';
|
|
2
2
|
import 'child_process';
|
|
3
3
|
import './DTSManagerOptions-c74c59ed.js';
|
|
4
4
|
import '@module-federation/sdk';
|
|
5
|
+
import './DTSManager-81645796.js';
|
|
5
6
|
import 'typescript';
|
|
6
7
|
|
|
7
8
|
declare function forkGenerateDts(options: DtsWorkerOptions): Promise<void>;
|
|
@@ -538,7 +538,7 @@ var log4js = __toESM(require("log4js"));
|
|
|
538
538
|
// packages/dts-plugin/src/server/constant.ts
|
|
539
539
|
var DEFAULT_WEB_SOCKET_PORT = 16322;
|
|
540
540
|
var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
|
|
541
|
-
var MF_SERVER_IDENTIFIER = "Module Federation
|
|
541
|
+
var MF_SERVER_IDENTIFIER = "Module Federation DTS";
|
|
542
542
|
var UpdateMode;
|
|
543
543
|
(function(UpdateMode2) {
|
|
544
544
|
UpdateMode2["POSITIVE"] = "POSITIVE";
|
|
@@ -1349,6 +1349,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1349
1349
|
} catch (error2) {
|
|
1350
1350
|
fileLog(`Error during types archive download: ${(error2 == null ? void 0 : error2.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1351
1351
|
if (retries >= hostOptions.maxRetries) {
|
|
1352
|
+
logger.error(`Failed to download ${fileToDownload}, you can set FEDERATION_DEBUG=true to see detail message.`);
|
|
1352
1353
|
if (hostOptions.abortOnError !== false) {
|
|
1353
1354
|
throw error2;
|
|
1354
1355
|
}
|
|
@@ -1418,6 +1419,7 @@ var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
|
1418
1419
|
};
|
|
1419
1420
|
}, "retrieveRemoteInfo");
|
|
1420
1421
|
var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
1422
|
+
var _a2;
|
|
1421
1423
|
const parsedOptions = import_managers2.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
|
|
1422
1424
|
remote: Array.isArray(item) ? item[0] : item,
|
|
1423
1425
|
key
|
|
@@ -1425,15 +1427,38 @@ var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1425
1427
|
remote: Array.isArray(item.external) ? item.external[0] : item.external,
|
|
1426
1428
|
key
|
|
1427
1429
|
}));
|
|
1430
|
+
const remoteTypeUrls = (_a2 = hostOptions.remoteTypeUrls) != null ? _a2 : {};
|
|
1431
|
+
if (typeof remoteTypeUrls !== "object") {
|
|
1432
|
+
throw new Error("remoteTypeUrls must be consumed before resolveRemotes");
|
|
1433
|
+
}
|
|
1434
|
+
const remoteInfos = Object.keys(remoteTypeUrls).reduce((sum, remoteName) => {
|
|
1435
|
+
const { zip, api, alias } = remoteTypeUrls[remoteName];
|
|
1436
|
+
sum[alias] = {
|
|
1437
|
+
name: remoteName,
|
|
1438
|
+
url: "",
|
|
1439
|
+
zipUrl: zip,
|
|
1440
|
+
apiTypeUrl: api,
|
|
1441
|
+
alias: alias || remoteName
|
|
1442
|
+
};
|
|
1443
|
+
return sum;
|
|
1444
|
+
}, {});
|
|
1428
1445
|
return parsedOptions.reduce((accumulator, item) => {
|
|
1429
1446
|
const { key, remote } = item[1];
|
|
1430
|
-
|
|
1447
|
+
const res = retrieveRemoteInfo({
|
|
1431
1448
|
hostOptions,
|
|
1432
1449
|
remoteAlias: key,
|
|
1433
1450
|
remote
|
|
1434
1451
|
});
|
|
1452
|
+
if (accumulator[key]) {
|
|
1453
|
+
accumulator[key] = __spreadProps(__spreadValues({}, accumulator[key]), {
|
|
1454
|
+
url: res.url,
|
|
1455
|
+
apiTypeUrl: accumulator[key].apiTypeUrl || res.apiTypeUrl
|
|
1456
|
+
});
|
|
1457
|
+
return accumulator;
|
|
1458
|
+
}
|
|
1459
|
+
accumulator[key] = res;
|
|
1435
1460
|
return accumulator;
|
|
1436
|
-
},
|
|
1461
|
+
}, remoteInfos);
|
|
1437
1462
|
}, "resolveRemotes");
|
|
1438
1463
|
var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
|
|
1439
1464
|
validateOptions(options);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import { WebpackPluginInstance, Compiler } from 'webpack';
|
|
3
|
+
import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
|
|
4
|
+
export { i as isTSProject } from './utils-0ec746b7.js';
|
|
5
|
+
import './DTSManager-81645796.js';
|
|
6
|
+
import 'typescript';
|
|
3
7
|
|
|
8
|
+
declare const normalizeDtsOptions: (options: moduleFederationPlugin.ModuleFederationPluginOptions, context: string, defaultOptions?: {
|
|
9
|
+
defaultGenerateOptions?: moduleFederationPlugin.DtsRemoteOptions;
|
|
10
|
+
defaultConsumeOptions?: moduleFederationPlugin.DtsHostOptions;
|
|
11
|
+
}) => false | moduleFederationPlugin.PluginDtsOptions;
|
|
4
12
|
declare class DtsPlugin implements WebpackPluginInstance {
|
|
5
13
|
options: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
14
|
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
7
15
|
apply(compiler: Compiler): void;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
declare const normalizeConsumeTypesOptions: ({ context, dtsOptions, pluginOptions, }: {
|
|
19
|
+
context?: string;
|
|
20
|
+
dtsOptions: moduleFederationPlugin.PluginDtsOptions;
|
|
21
|
+
pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
22
|
+
}) => {
|
|
23
|
+
host: {
|
|
24
|
+
typesFolder?: string;
|
|
25
|
+
abortOnError?: boolean;
|
|
26
|
+
remoteTypesFolder?: string;
|
|
27
|
+
deleteTypesFolder?: boolean;
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
consumeAPITypes?: boolean;
|
|
30
|
+
runtimePkgs?: string[];
|
|
31
|
+
remoteTypeUrls?: (() => Promise<moduleFederationPlugin.RemoteTypeUrls>) | moduleFederationPlugin.RemoteTypeUrls;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
implementation: string;
|
|
34
|
+
context: string;
|
|
35
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
36
|
+
};
|
|
37
|
+
extraOptions: Record<string, any>;
|
|
38
|
+
displayErrorInTerminal: boolean;
|
|
39
|
+
};
|
|
40
|
+
declare const consumeTypesAPI: (dtsManagerOptions: DTSManagerOptions, cb?: (options: moduleFederationPlugin.RemoteTypeUrls) => void) => Promise<void>;
|
|
41
|
+
|
|
42
|
+
declare const normalizeGenerateTypesOptions: ({ context, outputDir, dtsOptions, pluginOptions, }: {
|
|
43
|
+
context?: string;
|
|
44
|
+
outputDir?: string;
|
|
45
|
+
dtsOptions: moduleFederationPlugin.PluginDtsOptions;
|
|
46
|
+
pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
47
|
+
}) => DTSManagerOptions;
|
|
48
|
+
declare const generateTypesAPI: ({ dtsManagerOptions, }: {
|
|
49
|
+
dtsManagerOptions: DTSManagerOptions;
|
|
50
|
+
}) => Promise<void>;
|
|
51
|
+
|
|
52
|
+
export { DtsPlugin, consumeTypesAPI, generateTypesAPI, normalizeConsumeTypesOptions, normalizeDtsOptions, normalizeGenerateTypesOptions };
|