Hot Module Replacement (HMR) for my JS single page application was working fine until I added
The browser console still says [HMR] connected as before
NodeServices still outputs webpack built 4e73e4e1deb48362321c in 223ms as before
But the browser console now never says [HMR] bundle rebuilding so the changes are never applied.
I've tried the solutions from this issue #4547 regarding Environment.CurrentDirectory, but even when I set it to the same value it has when it's running as OutOfProcess (Environment.CurrentDirectory = Directory.GetParent(AppContext.BaseDirectory).Parent.Parent.Parent.FullName;) HMR still doesn't work.
Commenting out the AspNetCoreHostingModel line from the csproj makes HMR work again.
Versions:
I've tried updating aspnet-webpack but that caused additional issues.
Thank you for filing this issue, @DanielStout5. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.
@ryanbrandenburg, can you please look into this? Thanks
I updated to the latest versions of all the related NPM packages (webpack 4, aspnet-webpack 3.0.0, webpack-hot-middleware 2.24.3, etc) and this issue is still present - as soon as I uncomment the InProcess line in the csproj, webpack will still rebuild the changes on save but they never get applied in the browser.
I'll see if I can setup a minimalistic example.
Thank you! I was about to post an issue here but I didn't know what the problem was, but then this was suggested as a related issue. I confirmed that removing the InProcess line from the csproj fixes it!
Here's an example project to reproduce the issue. Note that you must run "npm i" from the ClientApp folder first, I haven't set that up to be automated. https://github.com/paulirwin/WebpackHMRIssue
If you remove the InProcess line, it works great.
Also, FWIW, that line in the .csproj is included by default in ASP.NET Core 2.2 templates, so it is officially broken in its default configuration.
This is a known issue that we are working to resolve with the inprocess hosting model and visual studio integration. Thanks for letting us know.
cc @BillHiebert
Sounds like this is a Server issue, so tossing it @jkotalik's way.
This is the "Ctrl-F5" work that we're working on. cc @jkotalik
This is fixed in VS 16.1-preview2.
I'm on VS 16.2.2 and I'm still having this issue.
@Daniel-Khodabakhsh as this is a closed issue, I'd suggest filing VS Feedback for this, or a new issue.
I'd lke to add that a workaround is to use the out of process hosting model only when developing. The general settings set in csproj/web.config (as specifed @ https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio ) can be overriden by:
Right-click your project in the Solution Explorer -> Properties -> Debug -> Select all profiles -> (Web Server Settings [at the bottom]) -> Hosting Model -> Set it to Out Of Process
Most helpful comment
I'm on VS 16.2.2 and I'm still having this issue.