Skip to content

Editing an imported ES module should trigger a reactive update #146

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

Closed
mbostock opened this issue Nov 10, 2023 · 1 comment · Fixed by #235
Closed

Editing an imported ES module should trigger a reactive update #146

mbostock opened this issue Nov 10, 2023 · 1 comment · Fixed by #235
Assignees
Labels
bug Something isn’t working
Milestone

Comments

@mbostock
Copy link
Member

mbostock commented Nov 10, 2023

I.e., hot module reloading for transitive imports. We already watch transitively imported modules, but the problem is that we can’t simply refresh cells that import a module after that module changes: once you import something at a given URL, it is permanently in memory.

To fix this, we need to rewrite top-level imports and transitive imports so they include a content hash or modification time of the imported module and its transitive dependencies. When an imported module changes and we are notified via the watcher, we need to recompile the code for the affected cells and send the new definition to the client as an update↓. The newly compiled code will include the new hash/mtime as part of the imported path, such that when the client runs it, it will import the changed modules.

Related #115 #79 #78 #77 which also require rewriting imported modules. (And #136 which was the first step.)

@mbostock mbostock added the enhancement New feature or request label Nov 10, 2023
@mbostock mbostock self-assigned this Nov 11, 2023
@mbostock
Copy link
Member Author

Also, when an imported module changes, recompiling the top-level code block (or expression) also means that the set of transitively imported modules can change, and therefore we’ll end up watching a different set of files. In other words refreshAttachment must do quite a bit more work than sending a refresh↓ event to the client.

@mbostock mbostock added bug Something isn’t working and removed enhancement New feature or request labels Nov 13, 2023
@mbostock mbostock added this to the Early access milestone Nov 13, 2023
@mbostock mbostock assigned mbostock and unassigned mbostock Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant