Skip to content
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

Replace resolved imports in esModuleShims (for hot reload) #380

Open
jogibear9988 opened this issue Jul 15, 2023 · 5 comments
Open

Replace resolved imports in esModuleShims (for hot reload) #380

jogibear9988 opened this issue Jul 15, 2023 · 5 comments

Comments

@jogibear9988
Copy link
Contributor

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?

@jogibear9988
Copy link
Contributor Author

@guybedford
Copy link
Owner

Thanks for sharing. There is actually a hot reload implementation for this project in #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.

@jogibear9988
Copy link
Contributor Author

Will try. At the moment I‘ll switch our complete project to use native import maps. When this is done I‘ll can try

@jogibear9988
Copy link
Contributor Author

The switch to importmaps takes longer as expected, but i will work on this

@dmnsgn
Copy link

dmnsgn commented Dec 2, 2023

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:

const toVersioned = url => {
const { v } = getHotData(url);
return url + (v ? '?v=' + v : '');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants