Repository navigation
Plugin patch hot-reload re-runs apply() but keeps already-imported ESM modules cached #10774
Replies: 3 comments 2 replies
|
Check the HMR watch scope first. DSH already has a module-replacement path, separate from reapplying plugin configuration. In the current source ( For development, configure the existing - id: hmr
disabled: false
config:
base: 'file:///F:/path/to/your/repo/'
root: ['.']Replace that example URL with your repository directory, including the trailing slash. You can narrow There is also a limit to the timestamp workaround: changing the handler URL does not change the URLs of its static imports. I checked this on Node 22.23.4 and 26.12.1 with DSH's documented replacement path follows static module links; its limitations section distinguishes dynamic imports, existing Workers and TSX loader caches. For a handler that can be imported statically, that gives HMR a dependency path back to the plugin to replace. This is a source check plus a standalone Node reproduction, not verification of your packaged Desktop build. If that build differs, the source behavior above may not all be present there. |
|
Thanks — that explains it, and it matches what I see: my plugin is a Three things on my side:
If this is by design rather than a gap, one sentence in the plugin docs — "a |
|
Thanks — the Config now (both - id: hmr
disabled: false
config:
base: 'file:///F:/dsh/直播工作台/'
root:
- 'plugin/dsh-live-workbench'
- 'server'Two-phase test — a small script appends a marker comment to one file, polls my plugin's activation breadcrumb for a new 1. Broad check,
2. Narrowed,
So on the packaged build the behaviour matches your description: entry reload alone is not the whole story, and with One honest data point for the source/packaged difference you flagged: with I also switched the plugin's host entry to a static import of the handler (the dynamic Docs + the verification script are in Dogwind221/Dw-LiveWorkbench#3 (README §6 states that |
Uh oh!
There was an error while loading. Please reload this page.
What I did
I'm developing a local plugin registered through a profile patch:
The plugin's
apply()dynamically imports a handler module that lives elsewhere in my repo, then registers a prefix route with it:What I expected
Editing the handler module and touching
cordis.patch.ymlshould reload the plugin so the new code takes effect — i.e. the documented behaviour that a patch change hot-reloads without restarting DSH.What actually happened
apply()runs again (my activation breadcrumb confirms it: a newapply()line is appended on every patch touch), but the module it imports is not re-evaluated. Node's ESM cache is keyed by the resolved URL, so the GUI keeps serving the old handler until I restart DSH entirely.Workaround
Bust the cache manually on every load, as in the snippet above:
It works, but the reload is only "real" if the plugin author knows to do this. A plugin that imports statically gets a silently stale engine after a patch reload.
Questions
Environment
cordis.patch.ymlwithfile://pathsinject: ['webServer'], prefix route registrationAll reactions