Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dts-plugin): do not regen types on hmr if dev false #3223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-yaks-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

ensure when dev is false that type generation only runs once
6 changes: 5 additions & 1 deletion packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
return fn;
};
const generateTypesFn = getGenerateTypesFn();

let compiledOnce = false;
compiler.hooks.thisCompilation.tap('mf:generateTypes', (compilation) => {
compilation.hooks.processAssets.tapPromise(
{
Expand All @@ -82,6 +82,9 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
},
async () => {
if (pluginOptions.dev === false && compiledOnce) {
return;
}
try {
const { zipTypesPath, apiTypesPath, zipName, apiFileName } =
retrieveTypesAssetsInfo(finalOptions.remote);
Expand Down Expand Up @@ -124,6 +127,7 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
),
);
}
compiledOnce = true;
} catch (err) {
console.error(err);
}
Expand Down
Loading