@@ -75,26 +75,27 @@ added: REPLACEME
7575> Stability: 1.1 - Active development
7676
7777* ` 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.
78+ is cleared from the load cache; the specifier (with ` parentURL` ) is cleared from the
79+ resolve cache.
8080* ` options` {Object}
81- * ` mode` {string} Which caches to clear. Supported values are ` ' all' ` , ` ' commonjs' ` , and ` ' module' ` .
82- **Default:** ` ' all' ` .
8381 * ` parentURL` {string|URL} The parent URL used to resolve non-URL specifiers.
8482 For CommonJS, pass ` pathToFileURL (__filename )` . For ES modules, pass ` import .meta.url` .
85- * ` importAttributes` {Object} Import attributes for ESM resolution.
86- * Returns: {Object} An object with ` { commonjs : boolean , module : boolean }` indicating whether entries
83+ * Returns: {Object} An object with ` { require : boolean , import : boolean }` indicating whether entries
8784 were removed from each cache.
8885
89- Clears the CommonJS ` require` cache and/or the ESM module cache for a module. This enables
86+ Clears the CommonJS ` require` cache and the ESM module cache for a module. This enables
9087reload patterns similar to deleting from ` require.cache` in CommonJS, and is useful for HMR.
91- When ` mode ` is ` ' all ' ` , resolution failures for one module system do not throw; check the
92- returned flags to see what was cleared.
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.
88+ Resolution failures for one module system do not throw; check the returned flags to see what
89+ was cleared.
90+ This does not clear resolution cache entries for that specifier. Clearing a module does not
91+ clear cached entries for its dependencies, and other specifiers that resolve to the same target
92+ may remain.
9693When a ` file:` URL is resolved, cached module jobs for the same file path are cleared even if
9794they differ by search or hash.
95+ If the same file is loaded via multiple specifiers (for example ` require(' ./x' )` alongside
96+ ` import(' ./x.js?t=1' )` and ` import(' ./x.js?t=2' )` ), resolution cache entries for each specifier
97+ remain. Use consistent specifiers, or call ` clearCache()` for each specifier you want to
98+ re-execute.
9899
99100` ` ` mjs
100101import { clearCache } from ' node:module' ;
0 commit comments