Skip to content

Commit

Permalink
fix: fix hrm with new import
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 30, 2024
1 parent 6abc63f commit 1d651c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion viteroll/viteroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ self.rolldown_runtime.patch(${JSON.stringify(stableIds)}, function(){
${innerCode}
});
`;
return [path.join(this.outDir, "hmr-update.js"), output];
// dump for debugging
const updatePath = path.join(this.outDir, `hmr-update-${Date.now()}.js`);
fs.writeFileSync(updatePath, output);
return [updatePath, output];
}

async handleUpdate(ctx: HmrContext) {
Expand Down Expand Up @@ -477,6 +480,10 @@ function viterollEntryPlugin(
"if (parent && module.parents.indexOf(parent) === -1) {",
)
.replace("if (item.deps.includes(updateModuleId)) {", "if (true) {")
.replace(
"var module = rolldown_runtime.moduleCache[moduleId];",
"var module = rolldown_runtime.moduleCache[moduleId]; if (!module) { continue; }",
)
.replace(
"for (var i = 0; i < module.parents.length; i++) {",
`
Expand Down

0 comments on commit 1d651c8

Please sign in to comment.