regression: require.resolve()
caches package.json
when it shouldn't
#34967
Labels
module
Issues and PRs related to the module subsystem.
What steps will reproduce the bug?
Repro at:
https://runkit.com/andreialecu/5f4a0a45b7d56e001a469c1e
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
I think
require.resolve
should not commit anything to cache (as opposed torequire()
). On node versions<12
this problem didn't exist, so it may be a regression.What do you see instead?
The
main
entry point of the resolved dependency is cached and sticks for the duration of the process.Additional information
The use case is checking whether the version of a dependency needs updating, and if it does, run
npm/yarn install
to update it (as part of a cli tool,@angular/cli
in this case).After the update finishes, the package would still load as the old version. I expect
require()
to cache it, but notrequire.resolve()
. It resulted in a very hard to track bug while working on an issue in the@angular/cli
repository. Additional info in: angular/angular-cli#18610The text was updated successfully, but these errors were encountered: