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

HMR for local development #48

Open
1 of 5 tasks
thescientist13 opened this issue Apr 18, 2019 · 5 comments
Open
1 of 5 tasks

HMR for local development #48

thescientist13 opened this issue Apr 18, 2019 · 5 comments
Labels
CLI feature New feature or request question Further information is requested
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Apr 18, 2019

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

As opposed to watch / livereload, which refreshes the full browser on each local development change, enabling HRM (hot module replacement) can help speed up local development by only reloading the part of the page, that needs to change, not the whole application.

Details

For example, given a page with an <input> (for example):

  1. Type something in the input element (like your name)
  2. Change the CSS background of the page

expected: the page would change color, but the text in the input would remain

note: this might require needing to sync with a state management library like redux.

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) chore unit testing, maintenance, etc labels Apr 18, 2019
@hutchgrant
Copy link
Member

hutchgrant commented Apr 19, 2019

This is problematic and would require removing our current live reload solution entirely. The 2(hmr and live reload) would conflict. If I add a new component or change a page-template, or add a new template, I need to re-generate compilation. That can't be done by HMR by default. Currently, by using filewatcher-webpack-plugin we're able to catch that event and run that compile function. But if we turned on HMR it would still continue to live-reload because of the regex we're watching for (any change in our userWorkspace).

One possible solution, but I don't know how viable it is, would be to modify regex for only certain files we live-reload and re-compile. This is tricky.

@thescientist13
Copy link
Member Author

Interesting thread from React land

Would be cool if this could work with GraphQL as well, but we can certainly develop it, enabled only by a flag, with certain caveats documented; e.g. might not work for all use cases, YMMV, etc.

@thescientist13
Copy link
Member Author

This cool project from pikapkg
https://github.com/pikapkg/esm-hmr

@thescientist13 thescientist13 added this to the Post 1.0 milestone Apr 11, 2021
@thescientist13 thescientist13 added CLI feature New feature or request question Further information is requested and removed enhancement Improve something existing (e.g. no docs, new APIs, etc) chore unit testing, maintenance, etc labels Jan 9, 2022
@thescientist13
Copy link
Member Author

There is some work in the Community Protocols space happening around this discussion that may be worth following up on whenever (if) we get around to this - webcomponents-cg/community-protocols#6

@thescientist13 thescientist13 removed this from the Post 1.0 milestone Mar 15, 2022
@thescientist13 thescientist13 changed the title As a user I would HMR supported for local development HMR for local development Aug 26, 2023
@thescientist13 thescientist13 added this to the 1.x milestone Nov 4, 2023
@thescientist13
Copy link
Member Author

Could be a good article for reference
https://bjornlu.com/blog/hot-module-replacement-is-easy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI feature New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants