Skip to content

Commit 8db7611

Browse files
fix(dts-plugin): do not regen types on hmr if dev false (#3223)
1 parent ae5ee1e commit 8db7611

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/honest-yaks-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/dts-plugin': patch
3+
---
4+
5+
ensure when dev is false that type generation only runs once

packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
7272
return fn;
7373
};
7474
const generateTypesFn = getGenerateTypesFn();
75-
75+
let compiledOnce = false;
7676
compiler.hooks.thisCompilation.tap('mf:generateTypes', (compilation) => {
7777
compilation.hooks.processAssets.tapPromise(
7878
{
@@ -82,6 +82,9 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
8282
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
8383
},
8484
async () => {
85+
if (pluginOptions.dev === false && compiledOnce) {
86+
return;
87+
}
8588
try {
8689
const { zipTypesPath, apiTypesPath, zipName, apiFileName } =
8790
retrieveTypesAssetsInfo(finalOptions.remote);
@@ -124,6 +127,7 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
124127
),
125128
);
126129
}
130+
compiledOnce = true;
127131
} catch (err) {
128132
console.error(err);
129133
}

0 commit comments

Comments
 (0)