Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmodule.unsafeCache is undocumented and causes unexpected errors #10771
Comments
salemhilal
added a commit
to salemhilal/webpack.js.org
that referenced
this issue
May 3, 2020
This PR mirrors webpack#3714 for the v4 documentation. It addresses the following issues: - webpack#2539 - webpack/webpack#10771
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
In Webpack 4, the undocumented
module.unsafeCachedefaulttruevalue can put development servers into a bad state. Changing the default in v4 would probably be a breaking change and is probably not a great solution here (the default value in v5 looks a lot more reasonable), but documenting this option would save a few headaches. I'm willing to open a documentation PR if that's the right solution.What is the current behavior?
src/andnode_modules/, in that order. Ensure thatresolver.unsafeCacheis off andmodule.unsafeCacheis unset.src/foo.jsandsrc/bar.js. Havesrc/foo.jsimport"bar", and addfooas an entrypoint.node_modules/bar/and deletesrc/bar.js.file not founderror something like this:This goes away with a restart. It behaves like
resolver.unsafeCacheis enabled, but some debugging reveals that this is caused by thedependencyCachein theNormalModuleFactory. The defaultmodule.unsafeCachevalue oftrueis unexpected here.What is the expected behavior?
If a file is missing, it should attempt to be re-resolved (which seems to be the default behavior for most modules in Webpack 5).
As I mentioned above, I don't think a code update is reasonable, but I do think that documenting this option and mentioning the defaults for both v4 and v5 would help people track down similar issues.
This issue follows issue #6045, which raised a bug and the need for documentation. I believe that #8277 experienced a similar issue.
Other relevant information:
webpack version: 4.43.0
Node.js version: 12.15.0
Operating System: CentOS 7