question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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

  1. Checkout this pull request.
  2. yarn install && yarn build
  3. Run yarn reproduce. This will open a local dev server.
  4. Open the DevTools, switch to “Console”.
  5. See the virtual module’s contents (entry.js) in the console.
  6. Try adding/removing *.js files in the examples/virtual-issue directory.
  7. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
camoonkecommented, May 18, 2021

same problem in webpack5

0reactions
larixercommented, Nov 1, 2022

Closing the issue as stale, please retest on latest webpack-virtual-modules and reopen with reproduction steps if the issue still exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] Infinite loop on the webpack 5 example #83 - GitHub
I'd be willing to submit the fix Describe the bug When running the webpack 5 ... [Bug] Stale virtual module contents upon ".writeModule"...
Read more >
Webpack: emit virtual module inside a Plugin - Stack Overflow
Each time you write dynamic module via virtualModules.writeModule it will have the same effect as if it was a real file on the...
Read more >
Agent Modules in Contrail Networking - TechLibrary
The contrail-controller works on a subscription model. Agent must subscribe to the virtual machines of interest and contrail-controller will download all of ...
Read more >
webpack-virtual-modules - npm
This plugin supports watch mode meaning any write to a virtual module is seen by webpack as if a real file stored on...
Read more >
Changelog — Python 3.11.1 documentation
gh-96005: On WASI ENOTCAPABLE is now mapped to PermissionError . The errno modules exposes the new error number. getpath.py now ignores PermissionError when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found