Invalidate cache when using import
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
How do I invalidate the cache of import?
I have a function that installs missing modules when an import fails, but the import statement seems to preserve the failure while the script is still running.
import('some-module').catch(
// this catch will only be reached the first time the script is run because resolveMissingModule will successfully install the module
() => resolveMissingModule('some-module').then(
// again, this will only be reached once, but it will fail, because the import seems to have cached the previous failure
() => import('some-module')
)
)
The only information I found in regards to import caching was this documentation, which does not tell me where the “separate cache” used by import can be found.
No require.cache
require.cacheis not used byimport. It has a separate cache.
— https://nodejs.org/api/esm.html#esm_no_require_cache
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ESM caching section linked in the issue and review the dynamic import example alongside the 151-comment thread. A contribution would need a maintainer-approved scope—documentation, an API or behavior change, or both—and a stated way to verify cache invalidation; the issue currently does not provide that.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100