import-fresh
- Version 4.0.0
- Published
- 31.1 kB
- No dependencies
- MIT license
Install
npm i import-freshyarn add import-freshpnpm add import-freshOverview
Import a module while bypassing the cache
Index
Functions
Type Aliases
Functions
function createImportFresh
createImportFresh: ( parentURL: string | URL, options?: Options) => ImportFreshFunction;Type Aliases
type ImportAttributes
type ImportAttributes = Record<string, string>;type ImportFreshFunction
type ImportFreshFunction = <T = unknown>( moduleSpecifier: string, options?: ImportFreshOptions) => Promise<T>;type ImportFreshOptions
type ImportFreshOptions = { /** Import attributes passed to `import()`.
Each value must be a string. */ importAttributes?: ImportAttributes;};type Options
type Options = { /** When `true`, modules under `node_modules` are not cache-busted.
This option is process-global, so every `createImportFresh()` call in one process must use the same value. */ skipNodeModules?: boolean;};Import a module while bypassing the cache.
Example 1
// foo.jslet count = 0;export default function increment() {count += 1;return count;}// index.jsimport createImportFresh from 'import-fresh';const importFresh = createImportFresh(import.meta.url);const {default: increment} = await importFresh('./foo.js');increment();//=> 1increment();//=> 2const {default: freshIncrement} = await importFresh('./foo.js');freshIncrement();//=> 1const foo = await importFresh<typeof import('./foo.js')>('./foo.js');
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/import-fresh.
- Markdown[](https://www.jsdocs.io/package/import-fresh)
- HTML<a href="https://www.jsdocs.io/package/import-fresh"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2248 ms. - Missing or incorrect documentation? Open an issue for this package.
