@module-federation/dts-plugin 0.8.11 → 0.8.12
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/esm/index.js +93 -38
- package/dist/index.js +93 -38
- package/dist/package.json +1 -1
- package/package.json +6 -6
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.8.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d227303: fix(dts-plugin): only block build process in prod env when generating types
|
|
8
|
+
- @module-federation/sdk@0.8.12
|
|
9
|
+
- @module-federation/managers@0.8.12
|
|
10
|
+
- @module-federation/third-party-dts-extractor@0.8.12
|
|
11
|
+
- @module-federation/error-codes@0.8.12
|
|
12
|
+
|
|
3
13
|
## 0.8.11
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -307,11 +307,22 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
307
307
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
308
308
|
};
|
|
309
309
|
validateOptions(finalOptions.host);
|
|
310
|
-
consumeTypes(finalOptions).then(() => {
|
|
310
|
+
const promise = consumeTypes(finalOptions).then(() => {
|
|
311
311
|
callback();
|
|
312
312
|
}).catch(() => {
|
|
313
313
|
callback();
|
|
314
314
|
});
|
|
315
|
+
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
316
|
+
compilation.hooks.processAssets.tapPromise({
|
|
317
|
+
name: "mf:generateTypes",
|
|
318
|
+
stage: (
|
|
319
|
+
// @ts-expect-error use runtime variable in case peer dep not installed , it should execute before generate types
|
|
320
|
+
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER - 1
|
|
321
|
+
)
|
|
322
|
+
}, () => __async(this, null, function* () {
|
|
323
|
+
yield promise;
|
|
324
|
+
}));
|
|
325
|
+
});
|
|
315
326
|
}
|
|
316
327
|
};
|
|
317
328
|
__name(_ConsumeTypesPlugin, "ConsumeTypesPlugin");
|
|
@@ -369,7 +380,84 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
369
380
|
return fn;
|
|
370
381
|
}, "getGenerateTypesFn");
|
|
371
382
|
const generateTypesFn = getGenerateTypesFn();
|
|
372
|
-
|
|
383
|
+
const emitTypesFiles = /* @__PURE__ */ __name((compilation) => __async(this, null, function* () {
|
|
384
|
+
try {
|
|
385
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
|
|
386
|
+
if (isProd && zipName && compilation.getAsset(zipName)) {
|
|
387
|
+
callback();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
yield generateTypesFn(finalOptions);
|
|
391
|
+
const config = finalOptions.remote.moduleFederationConfig;
|
|
392
|
+
let zipPrefix = "";
|
|
393
|
+
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
394
|
+
zipPrefix = config.manifest.filePath;
|
|
395
|
+
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
|
|
396
|
+
zipPrefix = path5.dirname(config.manifest.fileName);
|
|
397
|
+
} else if (config.filename) {
|
|
398
|
+
zipPrefix = path5.dirname(config.filename);
|
|
399
|
+
}
|
|
400
|
+
if (isProd) {
|
|
401
|
+
const zipAssetName = path5.join(zipPrefix, zipName);
|
|
402
|
+
const apiAssetName = path5.join(zipPrefix, apiFileName);
|
|
403
|
+
if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
|
|
404
|
+
compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
|
|
405
|
+
}
|
|
406
|
+
if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
|
|
407
|
+
compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
|
|
408
|
+
}
|
|
409
|
+
callback();
|
|
410
|
+
} else {
|
|
411
|
+
const isEEXIST = /* @__PURE__ */ __name((err) => {
|
|
412
|
+
return err.code == "EEXIST";
|
|
413
|
+
}, "isEEXIST");
|
|
414
|
+
if (zipTypesPath) {
|
|
415
|
+
const zipContent = fs2.readFileSync(zipTypesPath);
|
|
416
|
+
const zipOutputPath = path5.join(compiler.outputPath, zipPrefix, zipName);
|
|
417
|
+
yield new Promise((resolve2, reject) => {
|
|
418
|
+
compiler.outputFileSystem.mkdir(path5.dirname(zipOutputPath), (err) => {
|
|
419
|
+
if (err && !isEEXIST(err)) {
|
|
420
|
+
reject(err);
|
|
421
|
+
} else {
|
|
422
|
+
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => {
|
|
423
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
424
|
+
reject(writeErr);
|
|
425
|
+
} else {
|
|
426
|
+
resolve2();
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (apiTypesPath) {
|
|
434
|
+
const apiContent = fs2.readFileSync(apiTypesPath);
|
|
435
|
+
const apiOutputPath = path5.join(compiler.outputPath, zipPrefix, apiFileName);
|
|
436
|
+
yield new Promise((resolve2, reject) => {
|
|
437
|
+
compiler.outputFileSystem.mkdir(path5.dirname(apiOutputPath), (err) => {
|
|
438
|
+
if (err && !isEEXIST(err)) {
|
|
439
|
+
reject(err);
|
|
440
|
+
} else {
|
|
441
|
+
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => {
|
|
442
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
443
|
+
reject(writeErr);
|
|
444
|
+
} else {
|
|
445
|
+
resolve2();
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
callback();
|
|
453
|
+
}
|
|
454
|
+
} catch (err) {
|
|
455
|
+
callback();
|
|
456
|
+
if (finalOptions.displayErrorInTerminal) {
|
|
457
|
+
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}), "emitTypesFiles");
|
|
373
461
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
374
462
|
compilation.hooks.processAssets.tapPromise({
|
|
375
463
|
name: "mf:generateTypes",
|
|
@@ -379,42 +467,9 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
379
467
|
)
|
|
380
468
|
}, () => __async(this, null, function* () {
|
|
381
469
|
yield consumeTypesPromise;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
if (compiledOnce) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
|
|
390
|
-
if (zipName && compilation.getAsset(zipName)) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
yield generateTypesFn(finalOptions);
|
|
394
|
-
const config = finalOptions.remote.moduleFederationConfig;
|
|
395
|
-
let zipPrefix = "";
|
|
396
|
-
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
397
|
-
zipPrefix = config.manifest.filePath;
|
|
398
|
-
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
|
|
399
|
-
zipPrefix = path5.dirname(config.manifest.fileName);
|
|
400
|
-
} else if (config.filename) {
|
|
401
|
-
zipPrefix = path5.dirname(config.filename);
|
|
402
|
-
}
|
|
403
|
-
const zipAssetName = path5.join(zipPrefix, zipName);
|
|
404
|
-
if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
|
|
405
|
-
compilation.emitAsset(path5.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
|
|
406
|
-
}
|
|
407
|
-
const apiAssetName = path5.join(zipPrefix, apiFileName);
|
|
408
|
-
if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
|
|
409
|
-
compilation.emitAsset(path5.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
|
|
410
|
-
}
|
|
411
|
-
compiledOnce = true;
|
|
412
|
-
callback();
|
|
413
|
-
} catch (err) {
|
|
414
|
-
callback();
|
|
415
|
-
if (finalOptions.displayErrorInTerminal) {
|
|
416
|
-
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
417
|
-
}
|
|
470
|
+
const emitTypesFilesPromise = emitTypesFiles(compilation);
|
|
471
|
+
if (isProd) {
|
|
472
|
+
yield emitTypesFilesPromise;
|
|
418
473
|
}
|
|
419
474
|
}));
|
|
420
475
|
});
|
package/dist/index.js
CHANGED
|
@@ -2512,11 +2512,22 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
|
|
|
2512
2512
|
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
|
|
2513
2513
|
};
|
|
2514
2514
|
validateOptions(finalOptions.host);
|
|
2515
|
-
consumeTypes(finalOptions).then(() => {
|
|
2515
|
+
const promise = consumeTypes(finalOptions).then(() => {
|
|
2516
2516
|
callback();
|
|
2517
2517
|
}).catch(() => {
|
|
2518
2518
|
callback();
|
|
2519
2519
|
});
|
|
2520
|
+
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
2521
|
+
compilation.hooks.processAssets.tapPromise({
|
|
2522
|
+
name: "mf:generateTypes",
|
|
2523
|
+
stage: (
|
|
2524
|
+
// @ts-expect-error use runtime variable in case peer dep not installed , it should execute before generate types
|
|
2525
|
+
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER - 1
|
|
2526
|
+
)
|
|
2527
|
+
}, () => __async(this, null, function* () {
|
|
2528
|
+
yield promise;
|
|
2529
|
+
}));
|
|
2530
|
+
});
|
|
2520
2531
|
}
|
|
2521
2532
|
};
|
|
2522
2533
|
__name(_ConsumeTypesPlugin, "ConsumeTypesPlugin");
|
|
@@ -2574,7 +2585,84 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
2574
2585
|
return fn;
|
|
2575
2586
|
}, "getGenerateTypesFn");
|
|
2576
2587
|
const generateTypesFn = getGenerateTypesFn();
|
|
2577
|
-
|
|
2588
|
+
const emitTypesFiles = /* @__PURE__ */ __name((compilation) => __async(this, null, function* () {
|
|
2589
|
+
try {
|
|
2590
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
|
|
2591
|
+
if (isProd && zipName && compilation.getAsset(zipName)) {
|
|
2592
|
+
callback();
|
|
2593
|
+
return;
|
|
2594
|
+
}
|
|
2595
|
+
yield generateTypesFn(finalOptions);
|
|
2596
|
+
const config = finalOptions.remote.moduleFederationConfig;
|
|
2597
|
+
let zipPrefix = "";
|
|
2598
|
+
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
2599
|
+
zipPrefix = config.manifest.filePath;
|
|
2600
|
+
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
|
|
2601
|
+
zipPrefix = import_path10.default.dirname(config.manifest.fileName);
|
|
2602
|
+
} else if (config.filename) {
|
|
2603
|
+
zipPrefix = import_path10.default.dirname(config.filename);
|
|
2604
|
+
}
|
|
2605
|
+
if (isProd) {
|
|
2606
|
+
const zipAssetName = import_path10.default.join(zipPrefix, zipName);
|
|
2607
|
+
const apiAssetName = import_path10.default.join(zipPrefix, apiFileName);
|
|
2608
|
+
if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
|
|
2609
|
+
compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
|
|
2610
|
+
}
|
|
2611
|
+
if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
|
|
2612
|
+
compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
|
|
2613
|
+
}
|
|
2614
|
+
callback();
|
|
2615
|
+
} else {
|
|
2616
|
+
const isEEXIST = /* @__PURE__ */ __name((err) => {
|
|
2617
|
+
return err.code == "EEXIST";
|
|
2618
|
+
}, "isEEXIST");
|
|
2619
|
+
if (zipTypesPath) {
|
|
2620
|
+
const zipContent = import_fs4.default.readFileSync(zipTypesPath);
|
|
2621
|
+
const zipOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, zipName);
|
|
2622
|
+
yield new Promise((resolve5, reject) => {
|
|
2623
|
+
compiler.outputFileSystem.mkdir(import_path10.default.dirname(zipOutputPath), (err) => {
|
|
2624
|
+
if (err && !isEEXIST(err)) {
|
|
2625
|
+
reject(err);
|
|
2626
|
+
} else {
|
|
2627
|
+
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => {
|
|
2628
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
2629
|
+
reject(writeErr);
|
|
2630
|
+
} else {
|
|
2631
|
+
resolve5();
|
|
2632
|
+
}
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
if (apiTypesPath) {
|
|
2639
|
+
const apiContent = import_fs4.default.readFileSync(apiTypesPath);
|
|
2640
|
+
const apiOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, apiFileName);
|
|
2641
|
+
yield new Promise((resolve5, reject) => {
|
|
2642
|
+
compiler.outputFileSystem.mkdir(import_path10.default.dirname(apiOutputPath), (err) => {
|
|
2643
|
+
if (err && !isEEXIST(err)) {
|
|
2644
|
+
reject(err);
|
|
2645
|
+
} else {
|
|
2646
|
+
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => {
|
|
2647
|
+
if (writeErr && !isEEXIST(writeErr)) {
|
|
2648
|
+
reject(writeErr);
|
|
2649
|
+
} else {
|
|
2650
|
+
resolve5();
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
callback();
|
|
2658
|
+
}
|
|
2659
|
+
} catch (err) {
|
|
2660
|
+
callback();
|
|
2661
|
+
if (finalOptions.displayErrorInTerminal) {
|
|
2662
|
+
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}), "emitTypesFiles");
|
|
2578
2666
|
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
|
|
2579
2667
|
compilation.hooks.processAssets.tapPromise({
|
|
2580
2668
|
name: "mf:generateTypes",
|
|
@@ -2584,42 +2672,9 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
|
|
|
2584
2672
|
)
|
|
2585
2673
|
}, () => __async(this, null, function* () {
|
|
2586
2674
|
yield consumeTypesPromise;
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
}
|
|
2591
|
-
if (compiledOnce) {
|
|
2592
|
-
return;
|
|
2593
|
-
}
|
|
2594
|
-
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
|
|
2595
|
-
if (zipName && compilation.getAsset(zipName)) {
|
|
2596
|
-
return;
|
|
2597
|
-
}
|
|
2598
|
-
yield generateTypesFn(finalOptions);
|
|
2599
|
-
const config = finalOptions.remote.moduleFederationConfig;
|
|
2600
|
-
let zipPrefix = "";
|
|
2601
|
-
if (typeof config.manifest === "object" && config.manifest.filePath) {
|
|
2602
|
-
zipPrefix = config.manifest.filePath;
|
|
2603
|
-
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
|
|
2604
|
-
zipPrefix = import_path10.default.dirname(config.manifest.fileName);
|
|
2605
|
-
} else if (config.filename) {
|
|
2606
|
-
zipPrefix = import_path10.default.dirname(config.filename);
|
|
2607
|
-
}
|
|
2608
|
-
const zipAssetName = import_path10.default.join(zipPrefix, zipName);
|
|
2609
|
-
if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
|
|
2610
|
-
compilation.emitAsset(import_path10.default.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
|
|
2611
|
-
}
|
|
2612
|
-
const apiAssetName = import_path10.default.join(zipPrefix, apiFileName);
|
|
2613
|
-
if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
|
|
2614
|
-
compilation.emitAsset(import_path10.default.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
|
|
2615
|
-
}
|
|
2616
|
-
compiledOnce = true;
|
|
2617
|
-
callback();
|
|
2618
|
-
} catch (err) {
|
|
2619
|
-
callback();
|
|
2620
|
-
if (finalOptions.displayErrorInTerminal) {
|
|
2621
|
-
console.error("Error in mf:generateTypes processAssets hook:", err);
|
|
2622
|
-
}
|
|
2675
|
+
const emitTypesFilesPromise = emitTypesFiles(compilation);
|
|
2676
|
+
if (isProd) {
|
|
2677
|
+
yield emitTypesFilesPromise;
|
|
2623
2678
|
}
|
|
2624
2679
|
}));
|
|
2625
2680
|
});
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/dts-plugin",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
4
4
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"log4js": "6.9.1",
|
|
61
61
|
"node-schedule": "2.1.1",
|
|
62
62
|
"ws": "8.18.0",
|
|
63
|
-
"@module-federation/sdk": "0.8.
|
|
64
|
-
"@module-federation/managers": "0.8.
|
|
65
|
-
"@module-federation/third-party-dts-extractor": "0.8.
|
|
66
|
-
"@module-federation/error-codes": "0.8.
|
|
63
|
+
"@module-federation/sdk": "0.8.12",
|
|
64
|
+
"@module-federation/managers": "0.8.12",
|
|
65
|
+
"@module-federation/third-party-dts-extractor": "0.8.12",
|
|
66
|
+
"@module-federation/error-codes": "0.8.12"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/ws": "8.5.12",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"vue": "^3.4.29",
|
|
73
73
|
"@vue/tsconfig": "^0.5.1",
|
|
74
74
|
"vue-tsc": "^2.0.26",
|
|
75
|
-
"@module-federation/runtime": "0.8.
|
|
75
|
+
"@module-federation/runtime": "0.8.12"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"typescript": "^4.9.0 || ^5.0.0",
|