-
Notifications
You must be signed in to change notification settings - Fork 8
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
Recent updates do not work with SAFE Template #35
Comments
From my point of view, the problem is not with Elmish.HMR but because SAFE Template not being up to date with latest JavaScript stuff. Meaning it doesn't understand the being syntax used. There are 3 solutions:
From all of this solution, solution 1 is the easiest/best choice. Elmish.HMR is being tested against Webpack 5 and here is the configuration file used https://github.com/elmish/hmr/blob/master/tests/webpack/webpack.config.js |
There is a PR open to upgrade webpack. I think this is an issue with Fable.Elmish.HMR; dropping support for Webpack 4 is a breaking change so should be a major version change. Even the elmish templates use Webpack 4 (I know they're very out of date but still). Actually even if it was a major version change it wouldn't've helped because unfortunately the SAFE template and elmish templates don't even set major versions... Would I be correct in guessing that most users of this package are probably currently using Webpack 4? If so, a lot of people are going run into this as soon as they do a paket update. Is there anything that can be done to prevent or help others running into this issue in the future? Is it possible to make it work with the older syntax, or at least give a more useful error message? |
The thing is that we didn't drop support for Webpack 4 as it depends on how people have it set up. Webpack 5 is out since 1 year now, and most (all?) of the bundler now support ES6 syntax out of the box. We can't do anything to improve the error message from this package because this is Webpack which generates an error explaining what is happening.
Support for the older syntax is still here for example It is true that I could have release Elmish.HMR as a new major version, but I didn't think it was a breaking change because the old syntax is still here. Even, if I did that people would probably still have the problem because most people don't pin their dependencies version based on the major range. Now that several versions has been released in the wild since 1 month, I think this is probably too late to act on this for little benefit. |
I see. It's a tricky one. I agree, I don't think using compiler directives is ideal. The only other solution I can think of is using a new package name on nuget and archiving the old one. Which is also not ideal.
Okay, this might be a silly thought, but webpack does actually print the line of code with the syntax error. [<Emit("(import.meta.hot /* if error see https://github.com/elmish/hmr/issues/35 */)")>] |
So I unlisted the recent released version and release it under a new major version 5.0.0. This version, include your comment proposition as it didn't seems to affect the functionalities. And it also fix an issue with
It would increase the maintenance work by a lot and also could confuse the user. Thank you for taking the time to discuss the problem with me and coming up with the comment idea :) |
Thanks @MangelMaxime, you've handled this issue well 👍. I'll edit the issue description to add clear instructions for anyone who finds it. I just checked and the comment doesn't show up as the error message is now
I think the comment will have to be added to every emit that mentions |
How to fix if you come accross this error
If you're using the SAFE template, upgrade it to Webpack 5.
Alternatively, if you prefer to stack with Webpack 4 at the moment, you can pin the version of
Fable.Elmish.Hmr
in yourpaket.dependencies
file:Then paket install
Description
Using version
4.2
or above ofFable.Elmish.HMR
leads to an error during webpack build.Repro code
With safe template v3.1.1
There is also a repo linked in SAFE-Stack/SAFE-template#481
Related information
The text was updated successfully, but these errors were encountered: