-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Tracking] 🔥 Hot Module Replacement with webpack #6398
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
Comments
@tsonevn Navigation state is also not maintained after HMR. do you want me to create a new issue to track it? |
@shiv19, 10x for the feedback! You don't need to log an issue. I will add TLDR; |
Is HMR supposed to tear down the entire angular app when reloading? Thought it was supposed to maintain the state? We're seeing ngOnDestroy getting called for everything on reloads, and it's causing problems. Can anyone clarify? (I'll create an issue if it's not supposed to do that) EDIT: So EDIT2 Found our particular issue: |
Typically when trying to do HMR like this, you might need to check for (As an example I do for aspnetcore & angular integration with HMR) // // Enable either Hot Module Reloading or production mode
if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => {
modulePromise.then(appModule => appModule.destroy());
});
} else {
enableProdMode();
} |
Updated for 5.2 release. |
Are there any workarounds? When can we expect this to work out of the box? |
Hey @hettiger, This has been implemented for NativeScript applications with JavaScript and TypeScript:
|
I tried it today and it works like a dream! Love it <3 |
Hey guys. When I close the app and open it again, every changes with |
Hey @vahidvdn, There was a regression in some of the next versions of Let me know if still experience this problem. |
I understand that {N} + Angular + HMR means that the application will bootstrap on change. Does this imply that objects created by Angular's DI / bootstrap mechanisms will get recreated from scratch? Or will a @Injectable object be "the same" before and after HMR executes? Right now I see lots of (non-UI) objects getting re-created after HMR. |
Hi @vchimev |
@vahidvdn mine used to do the same until I removed the come on maint.ns.ts that used to listen for hmr module flag. |
@Jonatthu Thanks, but I'm afraid I didn't catch on you. You just turned off the hrm? |
@Jonatthu You are just falling back to the legacy one. Actually that is not a solution. The legacy reloader dropped in version 6.0 It's a bug with |
@vahidvdn I was having problems with my hmr until I commented out this piece of code. |
Would using mettro instead of webpack make things easlier since they seem to have solved the situation with Expo |
@trajano It's not realistic to port our very Webpack-reliant ecosystem over to Metro, which in any case has far worse documentation and is a far less open ecosystem. Callstack are in fact building solutions to move away from Metro to Webpack, which I believe Expo are interested in (as it would allow a common and well-understood bundler for both React Native and React Native Web, and super-fast builds with esbuild). The bundler itself is a relatively minor factor in how good the HMR experience is. |
Thanks @shirakaba I am just trying to see how to get all of this working to the same level as we have with Expo and React-Native where we can make changes and it updates the app automatically. I see announcements for HMR with Nativescript but I could never get it working and a few StackOverflow questions lead to issues that lead here. |
@trajano what specifically is not working, and which flavour of NativeScript are you using (Angular, Vue, etc.), and could you share your |
@shirakaba I created #9507 so I don't make this go too long. |
Uh oh!
There was an error while loading. Please reload this page.
Overview
Hot Module Replacement (HMR) is a feature provided by webpack. It makes it possible to replace modules in a bundled application while the application is running.
Integrating HMR within NativeScript will improve the development experience by:
Design
Implementation details and motivation of the feature can be found in its design document.
Tasks
NativeScript 5.0
HotModuleReplacement
plugin withnativescript-dev-webpack
.reloadPage
on changes in JS/TS-only applications.tns preview
.hmr
flag in the {N}-CLI section.After NativeScript 5.0
The possible improvements are explained in the design doc.
app.(css|scss)
: [HMR] Apply changes in application styles at runtime #6645main-page.(css|scss)
, etc.: [HMR] Apply changes in page styles at runtime #6953Page
, butTabView
,SideDrawer
, etc.Known issues
./ sync recursive...
item in the bundle which is not being accepted, so this will make the CLI restart the app to apply the change[HMR] Changes in plugin do NOT apply in angular projects nativescript-dev-webpack#914
Contributing
HMR provides us with so many possibilities!
If you want to work on a task from the list, tell us and we will do our best to help you!
If you have another great idea on how to make HMR even cooler, share it in the comments!
Discussion
Please, don't report problems here. Instead, open a new issue and link it to this one.
Let's use this discussion for suggestions and improvement ideas. We would love to hear from you!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: