@module-federation/dts-plugin 0.8.11 → 0.9.0

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5ebc53f: feat: enable tsc incremental build
8
+
9
+ ### Patch Changes
10
+
11
+ - d872b35: fix(dts-plugin): cache file should have name as its unique path
12
+ - @module-federation/sdk@0.9.0
13
+ - @module-federation/managers@0.9.0
14
+ - @module-federation/third-party-dts-extractor@0.9.0
15
+ - @module-federation/error-codes@0.9.0
16
+
17
+ ## 0.8.12
18
+
19
+ ### Patch Changes
20
+
21
+ - d227303: fix(dts-plugin): only block build process in prod env when generating types
22
+ - @module-federation/sdk@0.8.12
23
+ - @module-federation/managers@0.8.12
24
+ - @module-federation/third-party-dts-extractor@0.8.12
25
+ - @module-federation/error-codes@0.8.12
26
+
3
27
  ## 0.8.11
4
28
 
5
29
  ### Patch Changes
package/dist/core.js CHANGED
@@ -1798,7 +1798,7 @@ function getEffectiveRootDir(parsedCommandLine) {
1798
1798
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
1799
1799
  }
1800
1800
  __name(getEffectiveRootDir, "getEffectiveRootDir");
1801
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
1801
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
1802
1802
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
1803
1803
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
1804
1804
  if (readResult.error) {
@@ -1816,7 +1816,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
1816
1816
  outDir
1817
1817
  };
1818
1818
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
1819
- rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1819
+ rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
1820
+ incremental: true,
1821
+ tsBuildInfoFile: (0, import_path5.resolve)(context, "node_modules/.cache/mf-types/.tsbuildinfo")
1822
+ }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1820
1823
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
1821
1824
  rawTsConfigJson.compilerOptions = restCompilerOptions;
1822
1825
  const filesToCompile = [
@@ -1868,6 +1871,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
1868
1871
  const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
1869
1872
  const mapComponentsToExpose = resolveExposes(remoteOptions);
1870
1873
  const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
1874
+ if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
1875
+ remoteOptions.deleteTypesFolder = false;
1876
+ }
1871
1877
  return {
1872
1878
  tsConfig,
1873
1879
  mapComponentsToExpose,
@@ -4,7 +4,7 @@ import {
4
4
  exposeRpc,
5
5
  getDTSManagerConstructor,
6
6
  isDebugMode
7
- } from "./chunk-7XB7PFWZ.js";
7
+ } from "./chunk-XXMD5NAZ.js";
8
8
  import {
9
9
  __async,
10
10
  __export,
@@ -619,7 +619,7 @@ function getEffectiveRootDir(parsedCommandLine) {
619
619
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
620
620
  }
621
621
  __name(getEffectiveRootDir, "getEffectiveRootDir");
622
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
622
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
623
623
  const resolvedTsConfigPath = resolve2(context, tsConfigPath);
624
624
  const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
625
625
  if (readResult.error) {
@@ -637,7 +637,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
637
637
  outDir
638
638
  };
639
639
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
640
- rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
640
+ rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
641
+ incremental: true,
642
+ tsBuildInfoFile: resolve2(context, "node_modules/.cache/mf-types/.tsbuildinfo")
643
+ }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
641
644
  const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
642
645
  rawTsConfigJson.compilerOptions = restCompilerOptions;
643
646
  const filesToCompile = [
@@ -689,6 +692,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
689
692
  const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions), options);
690
693
  const mapComponentsToExpose = resolveExposes(remoteOptions);
691
694
  const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
695
+ if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
696
+ remoteOptions.deleteTypesFolder = false;
697
+ }
692
698
  return {
693
699
  tsConfig,
694
700
  mapComponentsToExpose,
package/dist/esm/core.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  consumeTypes,
4
4
  generateTypesInChildProcess,
5
5
  rpc_exports
6
- } from "./chunk-2B3WPOMZ.js";
6
+ } from "./chunk-UK7YFESF.js";
7
7
  import {
8
8
  DTSManager,
9
9
  HOST_API_TYPES_FILE_NAME,
@@ -19,7 +19,7 @@ import {
19
19
  retrieveTypesAssetsInfo,
20
20
  retrieveTypesZipPath,
21
21
  validateOptions
22
- } from "./chunk-7XB7PFWZ.js";
22
+ } from "./chunk-XXMD5NAZ.js";
23
23
  import "./chunk-KCWHOFI6.js";
24
24
  import "./chunk-4CSLH7II.js";
25
25
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rpc_exports
3
- } from "./chunk-2B3WPOMZ.js";
3
+ } from "./chunk-UK7YFESF.js";
4
4
  import {
5
5
  ModuleFederationDevServer,
6
6
  createKoaServer,
@@ -9,7 +9,7 @@ import {
9
9
  retrieveMfTypesPath,
10
10
  retrieveRemoteConfig,
11
11
  retrieveTypesZipPath
12
- } from "./chunk-7XB7PFWZ.js";
12
+ } from "./chunk-XXMD5NAZ.js";
13
13
  import {
14
14
  fileLog,
15
15
  getIPV4
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-7XB7PFWZ.js";
5
+ } from "./chunk-XXMD5NAZ.js";
6
6
  import "./chunk-KCWHOFI6.js";
7
7
  import {
8
8
  __async,
package/dist/esm/index.js CHANGED
@@ -2,14 +2,14 @@ import {
2
2
  consumeTypes,
3
3
  generateTypesInChildProcess,
4
4
  rpc_exports
5
- } from "./chunk-2B3WPOMZ.js";
5
+ } from "./chunk-UK7YFESF.js";
6
6
  import {
7
7
  cloneDeepOptions,
8
8
  generateTypes,
9
9
  isTSProject,
10
10
  retrieveTypesAssetsInfo,
11
11
  validateOptions
12
- } from "./chunk-7XB7PFWZ.js";
12
+ } from "./chunk-XXMD5NAZ.js";
13
13
  import {
14
14
  getIPV4,
15
15
  logger
@@ -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
- let compiledOnce = false;
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
- try {
383
- if (pluginOptions.dev === false && compiledOnce) {
384
- return;
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
  });
@@ -2252,7 +2252,7 @@ function getEffectiveRootDir(parsedCommandLine) {
2252
2252
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
2253
2253
  }
2254
2254
  __name(getEffectiveRootDir, "getEffectiveRootDir");
2255
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
2255
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
2256
2256
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
2257
2257
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
2258
2258
  if (readResult.error) {
@@ -2270,7 +2270,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
2270
2270
  outDir
2271
2271
  };
2272
2272
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
2273
- rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
2273
+ rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
2274
+ incremental: true,
2275
+ tsBuildInfoFile: (0, import_path5.resolve)(context, "node_modules/.cache/mf-types/.tsbuildinfo")
2276
+ }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
2274
2277
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
2275
2278
  rawTsConfigJson.compilerOptions = restCompilerOptions;
2276
2279
  const filesToCompile = [
@@ -2322,6 +2325,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
2322
2325
  const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
2323
2326
  const mapComponentsToExpose = resolveExposes(remoteOptions);
2324
2327
  const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
2328
+ if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
2329
+ remoteOptions.deleteTypesFolder = false;
2330
+ }
2325
2331
  return {
2326
2332
  tsConfig,
2327
2333
  mapComponentsToExpose,
@@ -202,7 +202,7 @@ function getEffectiveRootDir(parsedCommandLine) {
202
202
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
203
203
  }
204
204
  __name(getEffectiveRootDir, "getEffectiveRootDir");
205
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
205
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
206
206
  const resolvedTsConfigPath = (0, import_path.resolve)(context, tsConfigPath);
207
207
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
208
208
  if (readResult.error) {
@@ -220,7 +220,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
220
220
  outDir
221
221
  };
222
222
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
223
- rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
223
+ rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
224
+ incremental: true,
225
+ tsBuildInfoFile: (0, import_path.resolve)(context, "node_modules/.cache/mf-types/.tsbuildinfo")
226
+ }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
224
227
  const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
225
228
  rawTsConfigJson.compilerOptions = restCompilerOptions;
226
229
  const filesToCompile = [
@@ -272,6 +275,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
272
275
  const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions), options);
273
276
  const mapComponentsToExpose = resolveExposes(remoteOptions);
274
277
  const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
278
+ if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
279
+ remoteOptions.deleteTypesFolder = false;
280
+ }
275
281
  return {
276
282
  tsConfig,
277
283
  mapComponentsToExpose,
package/dist/index.js CHANGED
@@ -1821,7 +1821,7 @@ function getEffectiveRootDir(parsedCommandLine) {
1821
1821
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
1822
1822
  }
1823
1823
  __name(getEffectiveRootDir, "getEffectiveRootDir");
1824
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
1824
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
1825
1825
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
1826
1826
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
1827
1827
  if (readResult.error) {
@@ -1839,7 +1839,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
1839
1839
  outDir
1840
1840
  };
1841
1841
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
1842
- rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1842
+ rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({
1843
+ incremental: true,
1844
+ tsBuildInfoFile: (0, import_path5.resolve)(context, "node_modules/.cache/mf-types/.tsbuildinfo")
1845
+ }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1843
1846
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
1844
1847
  rawTsConfigJson.compilerOptions = restCompilerOptions;
1845
1848
  const filesToCompile = [
@@ -1891,6 +1894,9 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
1891
1894
  const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
1892
1895
  const mapComponentsToExpose = resolveExposes(remoteOptions);
1893
1896
  const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
1897
+ if (tsConfig.compilerOptions.incremental && tsConfig.compilerOptions.tsBuildInfoFile && options.deleteTypesFolder !== true) {
1898
+ remoteOptions.deleteTypesFolder = false;
1899
+ }
1894
1900
  return {
1895
1901
  tsConfig,
1896
1902
  mapComponentsToExpose,
@@ -2512,11 +2518,22 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
2512
2518
  displayErrorInTerminal: dtsOptions.displayErrorInTerminal
2513
2519
  };
2514
2520
  validateOptions(finalOptions.host);
2515
- consumeTypes(finalOptions).then(() => {
2521
+ const promise = consumeTypes(finalOptions).then(() => {
2516
2522
  callback();
2517
2523
  }).catch(() => {
2518
2524
  callback();
2519
2525
  });
2526
+ compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
2527
+ compilation.hooks.processAssets.tapPromise({
2528
+ name: "mf:generateTypes",
2529
+ stage: (
2530
+ // @ts-expect-error use runtime variable in case peer dep not installed , it should execute before generate types
2531
+ compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER - 1
2532
+ )
2533
+ }, () => __async(this, null, function* () {
2534
+ yield promise;
2535
+ }));
2536
+ });
2520
2537
  }
2521
2538
  };
2522
2539
  __name(_ConsumeTypesPlugin, "ConsumeTypesPlugin");
@@ -2574,7 +2591,84 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2574
2591
  return fn;
2575
2592
  }, "getGenerateTypesFn");
2576
2593
  const generateTypesFn = getGenerateTypesFn();
2577
- let compiledOnce = false;
2594
+ const emitTypesFiles = /* @__PURE__ */ __name((compilation) => __async(this, null, function* () {
2595
+ try {
2596
+ const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
2597
+ if (isProd && zipName && compilation.getAsset(zipName)) {
2598
+ callback();
2599
+ return;
2600
+ }
2601
+ yield generateTypesFn(finalOptions);
2602
+ const config = finalOptions.remote.moduleFederationConfig;
2603
+ let zipPrefix = "";
2604
+ if (typeof config.manifest === "object" && config.manifest.filePath) {
2605
+ zipPrefix = config.manifest.filePath;
2606
+ } else if (typeof config.manifest === "object" && config.manifest.fileName) {
2607
+ zipPrefix = import_path10.default.dirname(config.manifest.fileName);
2608
+ } else if (config.filename) {
2609
+ zipPrefix = import_path10.default.dirname(config.filename);
2610
+ }
2611
+ if (isProd) {
2612
+ const zipAssetName = import_path10.default.join(zipPrefix, zipName);
2613
+ const apiAssetName = import_path10.default.join(zipPrefix, apiFileName);
2614
+ if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
2615
+ compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2616
+ }
2617
+ if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
2618
+ compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2619
+ }
2620
+ callback();
2621
+ } else {
2622
+ const isEEXIST = /* @__PURE__ */ __name((err) => {
2623
+ return err.code == "EEXIST";
2624
+ }, "isEEXIST");
2625
+ if (zipTypesPath) {
2626
+ const zipContent = import_fs4.default.readFileSync(zipTypesPath);
2627
+ const zipOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, zipName);
2628
+ yield new Promise((resolve5, reject) => {
2629
+ compiler.outputFileSystem.mkdir(import_path10.default.dirname(zipOutputPath), (err) => {
2630
+ if (err && !isEEXIST(err)) {
2631
+ reject(err);
2632
+ } else {
2633
+ compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => {
2634
+ if (writeErr && !isEEXIST(writeErr)) {
2635
+ reject(writeErr);
2636
+ } else {
2637
+ resolve5();
2638
+ }
2639
+ });
2640
+ }
2641
+ });
2642
+ });
2643
+ }
2644
+ if (apiTypesPath) {
2645
+ const apiContent = import_fs4.default.readFileSync(apiTypesPath);
2646
+ const apiOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, apiFileName);
2647
+ yield new Promise((resolve5, reject) => {
2648
+ compiler.outputFileSystem.mkdir(import_path10.default.dirname(apiOutputPath), (err) => {
2649
+ if (err && !isEEXIST(err)) {
2650
+ reject(err);
2651
+ } else {
2652
+ compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => {
2653
+ if (writeErr && !isEEXIST(writeErr)) {
2654
+ reject(writeErr);
2655
+ } else {
2656
+ resolve5();
2657
+ }
2658
+ });
2659
+ }
2660
+ });
2661
+ });
2662
+ }
2663
+ callback();
2664
+ }
2665
+ } catch (err) {
2666
+ callback();
2667
+ if (finalOptions.displayErrorInTerminal) {
2668
+ console.error("Error in mf:generateTypes processAssets hook:", err);
2669
+ }
2670
+ }
2671
+ }), "emitTypesFiles");
2578
2672
  compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
2579
2673
  compilation.hooks.processAssets.tapPromise({
2580
2674
  name: "mf:generateTypes",
@@ -2584,42 +2678,9 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2584
2678
  )
2585
2679
  }, () => __async(this, null, function* () {
2586
2680
  yield consumeTypesPromise;
2587
- try {
2588
- if (pluginOptions.dev === false && compiledOnce) {
2589
- return;
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
- }
2681
+ const emitTypesFilesPromise = emitTypesFiles(compilation);
2682
+ if (isProd) {
2683
+ yield emitTypesFilesPromise;
2623
2684
  }
2624
2685
  }));
2625
2686
  });
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.8.11",
3
+ "version": "0.9.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -60,7 +60,7 @@
60
60
  "chalk": "3.0.0",
61
61
  "fs-extra": "9.1.0",
62
62
  "isomorphic-ws": "5.0.0",
63
- "koa": "2.15.3",
63
+ "koa": "2.15.4",
64
64
  "log4js": "6.9.1",
65
65
  "node-schedule": "2.1.1",
66
66
  "ws": "8.18.0"
@@ -72,7 +72,8 @@
72
72
  "@module-federation/runtime": "workspace:*",
73
73
  "vue": "^3.4.29",
74
74
  "@vue/tsconfig": "^0.5.1",
75
- "vue-tsc": "^2.0.26"
75
+ "vue-tsc": "^2.0.26",
76
+ "rimraf": "~3.0.2"
76
77
  },
77
78
  "peerDependencies": {
78
79
  "typescript": "^4.9.0 || ^5.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.8.11",
3
+ "version": "0.9.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -56,14 +56,14 @@
56
56
  "chalk": "3.0.0",
57
57
  "fs-extra": "9.1.0",
58
58
  "isomorphic-ws": "5.0.0",
59
- "koa": "2.15.3",
59
+ "koa": "2.15.4",
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.11",
64
- "@module-federation/managers": "0.8.11",
65
- "@module-federation/third-party-dts-extractor": "0.8.11",
66
- "@module-federation/error-codes": "0.8.11"
63
+ "@module-federation/sdk": "0.9.0",
64
+ "@module-federation/managers": "0.9.0",
65
+ "@module-federation/third-party-dts-extractor": "0.9.0",
66
+ "@module-federation/error-codes": "0.9.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/ws": "8.5.12",
@@ -72,7 +72,8 @@
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.11"
75
+ "rimraf": "~3.0.2",
76
+ "@module-federation/runtime": "0.9.0"
76
77
  },
77
78
  "peerDependencies": {
78
79
  "typescript": "^4.9.0 || ^5.0.0",