-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Introduce hot module replacement (reload) #739
Comments
Svelte doesn't really have an external way to access "trees", but if we want any dev tools then we'll probably need some way to locate nodes. |
Don't think so currently, It's on the roadmap for v2 . See #622 |
As far as I can tell, the real problem is one of state. If I have a situation like this... <!-- App.html -->
<Foo a='{{1}}'/>
<!-- Foo.html -->
<p>a: {{a}}</p>
<p>b: {{b}}</p>
<script>
export default {
data: () => ({ b: 1 }),
oncreate() {
let { b } = this.get();
const interval = setInterval(() => {
this.set({ b: ++b });
}, 1000);
this.on('destroy', () => clearInterval(interval));
}
};
</script> ...then we'll have this to begin with... <p>a: 1</p>
<p>b: 1</p> ...but So I wonder if we would need to have an HMR-friendly mode where components didn't have the |
Now that we have Store support, is this something that can be looked at again? I managed to hack together a very rough HMR setup using Store and Webpack. What I did was basically add this to the entry file: if(module.hot){
module.hot.accept();
} and then in every component had an ...
oncreate() {
var self = this;
if (module.hot) {
module.hot.dispose(function () {
self.destroy();
});
}
}
... And just that worked very well (I haven't tried on a complex codebase yet). But as you can see, patching every component with that snippet manually is not ideal. I'm not sure what the best approach is, just throwing ideas out there. |
Strongly agree. Am currently immersing myself in Webpack, and this will definitely be an area of focus in the near future. |
svelte-hot-loader has reached version 1. Give it a whirl. Would love some feedback on that |
@Rich-Harris two questions. 1) do you plan on incorporating the awesomeness of @ekhaled's hot loader, and 2) should this ticket be moved over to https://github.com/sveltejs/sapper, since I would guess that's where it would be implemented? (or does it make sense to just leave it in a plugin?) |
IMO hot loading should be baked into svelte-loader, rather than relying on a plugin. If @Rich-Harris thinks the PR looks good, I will try and get it finished. |
@arxpoetica I think this can be closed now. Right? |
Yup |
I don't know svelte internals, and if it's possible to implement hot-reloading at all, but any way the feature will greatly help in development.
Feel free to close issue, if no way to implement it (unlikely 😃), or not interested for now :)
The text was updated successfully, but these errors were encountered: