sysgears / webpack-virtual-modules

Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Old version of file shown on initial load, one save fixes it

natew opened this issue · comments

Getting a strange bug where Webpack serves a stale version of a module file that I write to throughout the initial build.

Sorry for not providing example code here, just wondering if you may have an idea how this even happens as a starting point so I can debug it a bit more on my own...

I have a monorepo with a few packages, Webpack runs fine, I to create a fake module module/style.css which works - except on the first load it serves a version of the file from earlier in the build process. It seems like it only gets the styles from within the app, but not within another package that also writes to the same virtual module.

But, if I log out during build, it's definitely writing out the correct final file before the end of the first build. It just seems to not notify the app that file uploaded. It's all in one big chunk during dev mode.

If I save any file in the app, it will work from then on just fine. It's just on initial load for whatever reason.

Nope, no ideas

Ok, so debugging this and I see where it happens now at least, it stops updating the file once webpack follows an async import(). DEBUG shows Writing virtual module with the right output, but the content upon first build is stuck at whatever was written before the first import().

Going to see if I can't figure out now a fix...

Edit: It's actually likely not this, super hard to isolate really, it seems to not be deterministic in build order, ongoing...

@natew Without reproduction it is hard to help in any way. Even if it reproduces "sometimes", but I will able to see it, I will able to share some ideas what is wrong.