[Bug] Stale virtual module contents upon ".writeModule"
See original GitHub issue- I’d be willing to submit the fix
Describe the bug
I have a file system watcher (gatsby-page-utils
). I derive a JSON from the file changes (addition/removal) of a given directory. I then use your plugin to write the contents of that JSON as a virtual module for my build.
The issue is that when a file is added/removed, although .writeModule
is called with the right JSON, the value of the virtual module remains stale. Actually, I believe it remains the same as when the build was done. Nothing changes the value: working with files, changing the build’s entrypoint.
To Reproduce
- Checkout this pull request.
yarn install && yarn build
- Run
yarn reproduce
. This will open a local dev server. - Open the DevTools, switch to “Console”.
- See the virtual module’s contents (
entry.js
) in the console. - Try adding/removing
*.js
files in theexamples/virtual-issue
directory. - See the console outputting the same JSON.
You can observe the value of the serializedPages
in the FileRouterPlugin
plugin to see that .writeModule()
call receives updated value.
Environment if relevant (please complete the following information):
- OS: MacOS Catalina 10.15.5
- Node version: v12.18.0
- Webpack version: 5.15.0
Additional context
I’m building a plugin that represents a given directory as a JSON, watches for changes, and exposes that JSON to your bundle. I’d love to use your plugin underneath to provide that JSON as a virtual module. Thank you for creating this plugin!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
same problem in webpack5
Closing the issue as stale, please retest on latest
webpack-virtual-modules
and reopen with reproduction steps if the issue still exists.