Astro Info
Astro v5.16.5
Vite v6.4.1
Node v20.19.5
System Windows (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using HMR (Hot Module Replacement) in Astro during development, server-side modules that import other modules (e.g., store files) do not reload when those imported dependencies are modified. The server-side code continues to use the cached version of the imported module's code until the development server is restarted.
To Reproduce
- Clone the example repository: git clone https://github.com/devcustrom/astro-pinia-bug.git
- Run npm install and then npm run dev.
- Open the main page in a browser. You should see the message "test value: 123" printed in both the terminal and the browser console.
- Now, edit src/store/teststore.ts: change the text inside the console.log on line 6 (for example, to console.log('test updated!')).
- Save the file and observe:
- Client Side: A new message (e.g., test updated!) will appear in the browser console if the client component also imports and uses teststore.ts. HMR works on the client.
- Server Side: The message in the terminal, originating from server-only-store.ts (which imports teststore.ts), will not update. Or, if server-only-store.ts renders a result into the HTML, that result will not change until the page is reloaded, and even then, it might still show the old value if the server module wasn't reloaded.
- Restart the Astro dev server (Ctrl+C and npm run dev again).
- Refresh the page in the browser. Now, the console.log from server-only-store.ts will print the new message, and any server-side HTML dependent on this store will also update correctly.
Expected Behavior
When src/store/teststore.ts changes, any server-side modules importing it (e.g., server-only-store.ts) should be notified by HMR and re-run to reflect the changes. This should result in the console.log in the terminal updating and any server-rendered HTML depending on this store updating correctly.
What's the expected result?
Server-side modules (server-only-store.ts) do not reload when their dependencies (teststore.ts) change. They continue using the cached version of the imported code until the entire development server is restarted. HMR works correctly on the client side.
Link to Minimal Reproducible Example
https://github.com/devcustrom/astro-pinia-bug
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using HMR (Hot Module Replacement) in Astro during development, server-side modules that import other modules (e.g., store files) do not reload when those imported dependencies are modified. The server-side code continues to use the cached version of the imported module's code until the development server is restarted.
To Reproduce
Expected Behavior
When src/store/teststore.ts changes, any server-side modules importing it (e.g., server-only-store.ts) should be notified by HMR and re-run to reflect the changes. This should result in the console.log in the terminal updating and any server-rendered HTML depending on this store updating correctly.
What's the expected result?
Server-side modules (server-only-store.ts) do not reload when their dependencies (teststore.ts) change. They continue using the cached version of the imported code until the entire development server is restarted. HMR works correctly on the client side.
Link to Minimal Reproducible Example
https://github.com/devcustrom/astro-pinia-bug
Participation