Skip to content

Commit 2496f25

Browse files
committed
fixup! module: add clearCache for CJS and ESM
1 parent 723300c commit 2496f25

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

doc/api/module.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ added: REPLACEME
7474
7575
> Stability: 1.1 - Active development
7676
77-
* `specifier` {string|URL} The module specifier or URL to clear.
77+
* `specifier` {string|URL} The module specifier or URL to resolve. The resolved URL/filename
78+
is cleared from the load cache; the specifier (with `parentURL` and `importAttributes`)
79+
is cleared from the resolve cache.
7880
* `options` {Object}
7981
* `mode` {string} Which caches to clear. Supported values are `'all'`, `'commonjs'`, and `'module'`.
8082
**Default:** `'all'`.
@@ -88,8 +90,9 @@ Clears the CommonJS `require` cache and/or the ESM module cache for a module. Th
8890
reload patterns similar to deleting from `require.cache` in CommonJS, and is useful for HMR.
8991
When `mode` is `'all'`, resolution failures for one module system do not throw; check the
9092
returned flags to see what was cleared.
91-
This also clears internal resolution caches for the resolved module. Clearing a module does
92-
not clear cached entries for its dependencies.
93+
This also clears resolution cache entries for that specifier. Clearing a module does not clear
94+
cached entries for its dependencies, and other specifiers that resolve to the same target may
95+
remain.
9396
When a `file:` URL is resolved, cached module jobs for the same file path are cleared even if
9497
they differ by search or hash.
9598

0 commit comments

Comments
 (0)