-
Notifications
You must be signed in to change notification settings - Fork 71
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
Make it work with Webpack 5, use webpack-virtual-modules as a dependency #146
Conversation
d8637dd
to
66cf57b
Compare
This approach was considered before at #59 (comment). This would probably be a better approach than #136, since this doesn't involve trying to do some weird compiler hooking here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, the package.json
should have a major version bump to 3.0.0
.
The only thing he mentioned is that we would get unhelpful and cryptic error message, which is easier to fix than trying to put wvm in the loader, and continually fix problems which arise from that. |
243c69f
to
4bef5ac
Compare
Before this licence was in the package.json but it wasn't actually in the repo. sveltejs#136 would have added a license but now sveltejs#146 is the future, and that PR clears up the license issue by not including webpack-virtual-modules in-repo, so it doesn't have to affect the LICENSE file.
These changes should be documented in the |
I just tested this on a project that uses |
@Smittyvb have you tested changing css in components with |
@non25 Just tried that, and it appears I have to restart the watch server whenever I change the CSS. It looks like changes to the CSS aren't being automatically picked up and updated |
@Smittyvb That is sad. Webpack 5 hard-caches virtual modules, sadly. |
This looks like it might have been a regression in |
@Smittyvb I feel like it fixed the reload every virtual file on any change bug too much. 😄 |
Luckily, I've found an easy workaround here: instead of doing Perhaps |
That is what I'm using right now, but it has important caveat: Personally, I would document the issues, merge a Webpack 5 compatible PR and work from there. The current state of I'm currently in the middle of hacking around virtual-modules free solution, which is based on inlining the css in base64 into compiled component and making some custom loader string looked up here: Will post another branch once I manage to get something working. |
@Smittyvb I would also recommend using svelte-loader-hot with similar PR in the meantime. It has working HMR. |
@non25 Yep, just tested on |
So, my friend made it possible with little help from me. We can drop I think this approach is much better.
The only downside is that webpack devServer log is polluted with base64'd styles after filenames, but I would take that trade anyday. 🙂 Take a look: https://github.com/non25/svelte-loader/tree/emitcss-inline I think we could close this and open that. 😄 |
There's also another approach: https://github.com/non25/svelte-loader/tree/emitcss-to-map |
Here's a comparison of the branches:
|
The safe solution based on What do you think? 🤔 |
Just tested the if (module.hot) {
const { configure, register, reload } = require('[root]/node_modules/svelte-loader/lib/hot-api.js');
module.hot.accept();
if (!module.hot.data) {
// initial load
configure({});
$2 = register("node_modules/svelte-routing/src/Router.svelte", $2);
} else {
// hot update
$2 = reload("node_modules/svelte-routing/src/Router.svelte", $2);
}
}
export default $2;
|
That is due to |
So I've tested |
@rixo is our resident HMR expert if you have questions about getting it working |
@benmccann |
Without really knowing what's involved, I'd say that sounds reasonable |
@benmccann master...non25:emitcss-to-map |
looks nice! I don't know this code base super well, but I like that you're supporting an extra version of webpack with less code! I'd say go ahead and send it as a PR. (fyi, I merged #149 already so you can rebase against that. and also it's probably better not to bump the version number because we'll do that during the release process) |
Closing in favor of: #151 |
Using webpack-virtual-modules as a dependency has the benefit of easier maintenance in contrary to copypasting.
The downside is that users are required to make slight changes to their webpack.config.js.
The message existing users will recieve on update trying to compile without SveltePlugin is quite straighforward.
What do you guys think ? :)