SAFE-template
SAFE-template copied to clipboard
Webpack error after upgrading to V3
I'm trying to upgrade my project to V3 and after following all the steps here https://safe-stack.github.io/docs/recipes/upgrading/v2-to-v3/
Now I'm trying to run npm run-script build
, but I get a following error:
ERROR in ./src/Client/output/App.js 261:74
Module parse failed: Unexpected token (261:74)
File was processed with these loaders:
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| const current = current_2;
| window.Elmish_HMR_Count = ((window.Elmish_HMR_Count == null) ? 0 : (window.Elmish_HMR_Count + 1));
> Internal_tryRestoreState(hmrState, (current.tag === 1) ? (((import.meta.webpackHot).accept(), (import.meta.webpackHot).data)) : ((current.tag === 2) ? (((module.hot).accept(), (module.hot).data)) : ((import.meta.hot.accept(), import.meta.hot.data))));
| }
| const map_2 = (tupledArg_4) => [tupledArg_4[0], Cmd_map((arg0_2) => (new Msg$1(0, arg0_2)), tupledArg_4[1])];
How do I debug? I'm not too familiar with webpack so no idea what is going on under the hood. And for the reference running the same command on a vanilla SAFE project works just fine on the same machine.
The line it's pointing to is to do with HMR, so I'd try disabling HMR by commenting out the open Elmish.HMR
line in #if DEBUG
and/or doing a release build to see if it makes a difference.
Are you able to provide a repro?
It's probably this https://github.com/elmish/hmr/issues/35. You can pin Fable.Elmish.HMR
to version 4.1
in your paket.dependencies
, or following step 6 in the upgrade recipe overwrite the paket.lock
file and add back any extra nuget packages.
Ah I must've missed that step. Makes total sense! 🤦 So this got resolved by:
- copying over the
paket.lock
from a vanilla SAFE project - running
dotnet paket install
Thank you!
There are some server errors now, I'll go dig into them.
cc @Akash-Mair @Ryan-Palmer-CIT - might need to update the recipe here?
I might be misunderstanding the above, but far as I can tell pinning Fable.Elmish.HMR
to version 4.1.0
is the only solution under which the build survives a paket update
call. Adding that pin to the template's paket.dependencies
file might be a good idea for now? OTOH, with all the other packages I've had to pin to old versions recently (due to .NET 6 versioning), I'm holding out hope that a .NET 6-compatible SAFE Stack upgrade will magically obviate this problem as well. :-)
Based on https://github.com/SAFE-Stack/SAFE-template/issues/483#issuecomment-979238079 it looks to me like this is resolved and the recipe is correct, so I'll close the issue.