Skip to content

Commit

Permalink
fix(dts-plugin): do not regen types on hmr if dev false
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Nov 14, 2024
1 parent 7facc10 commit 6acb9e5
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 6acb9e5

Please sign in to comment.