HMR
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript, vite
- Domain
- build-system, frontend
Research direction
Start by reproducing the HMR behavior with the example files a.ts and b.ts using the documented steps: edit the beginning of b.ts, change the counter, and inspect the logger output. Done means hot replacement preserves store state and does not create duplicate units, connections, or logger executions; the issue leaves the implementation choice open.
Written by the indexing model from the issue text.
Description
There are two issues related with hot module replacement(HMR), these issues is following:
- keep states of stores between module replacements
- avoid duplicates of units and connection between units
For example we have two files a.ts and b.ts:
// a.ts
import { createEvent } from "effector";
export const reset = createEvent();
export const inc = createEvent();
export const dec = createEvent();
// b.ts
import { inc, dec, reset } from "./a";
import { attach, createStore, sample } from "effector";
export const $count = createStore(0)
.on(inc, (count) => count + 1)
.on(dec, (count) => count - 1)
.reset(reset);
const logFx = attach({
source: $count,
effect(count) {
console.log("COUNT: ", count);
},
});
sample({
clock: $count,
target: logFx,
});
import { $count } from "./a";
import { inc, dec } from "./b";
import { useStore } from "effector-react";
import React from "react";
export function App() {
const count = useStore($count);
return (
<>
<div>Count: {count}</div>
<button onClick={() => inc()}>+</button>
<button onClick={() => dec()}>-</button>
</>
);
}
When we start project this files will be compiled and executed by compiler, so we will have one set of units and connections. But when we make a change, vite's hmr will replace changed module and the compiler compiles and executes the changed module again. After all we have two copies of units and connections. Thus, we get a copy for each replaced module.
How to reproduce:
- make change in the beginning of the b.ts file
- increase or decrease counter
- check console, when logger effect fired twice
What I think about possible solutions.:
- For the second issue: we could create domain for each module and wrap up all content of module in withRegion, and when hmr is fired we could clean replaced module
- For both issues: we need a more stable sids that is not related from position in file and can keep between hmr
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from effector/vite-react-template
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
All issues in effector/vite-react-template
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·