es-module-shims
es-module-shims copied to clipboard
Replace resolved imports in esModuleShims (for hot reload)
Hello,
I implemented my own WebComponent Library (https://github.com/node-projects/base-custom-webcomponent) wich also has it's own hot reload mechanism. But at the moment you could only reload the components (cause I replace the constructor in the customElemnt registration), but not referenced javascript code (cause the browser only loads once). Would it be possible that I replace the stored javascript wich was resolved by your library when loaded via importShim? Is there any access to it?
Here is how I reload atm: https://github.com/node-projects/base-custom-webcomponent/blob/master/src/HotModuleReplacement.ts
Thanks for sharing. There is actually a hot reload implementation for this project in https://github.com/guybedford/es-module-shims/pull/269, I just never landed it (not sure why... it works fine!). The main issue is just that it needs integration with a server that can send the reload events, but Chomp does support it as well.
If you try it out do share if it works for you.
Will try. At the moment I‘ll switch our complete project to use native import maps. When this is done I‘ll can try
The switch to importmaps takes longer as expected, but i will work on this
I tried it with a good ol browser-sync server a few months back, it was working fine. If I remember correctly, I had a couple issues with the query parameter replacement not checking existing query params: https://github.com/guybedford/es-module-shims/blob/087eae381eaedcb5a22627d7afbde2d14ce4755e/src/hot-reload.js#L32-L35