{"name":"import-fresh","version":"4.0.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=22.15"},"scripts":{"test":"xo && node --test tests/*.js && tsd","heapdump":"node heapdump.js"},"keywords":["import","require","cache","uncache","uncached","module","fresh","bypass"],"devDependencies":{"@types/node":"^25.3.0","heapdump":"^0.3.15","tsd":"^0.33.0","xo":"^1.2.3"},"tsd":{"directory":"tests","compilerOptions":{"module":"nodenext","moduleResolution":"nodenext"}},"gitHead":"7bc8025e9d957713eee96c07b88f350cd18940a9","types":"./index.d.ts","_id":"import-fresh@4.0.0","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-Fpi660c7VPDM3fPKYovStd9IP1CPOikf6v/dGxJJMmHPcwYQIMJ4W7kO1avBYEpMqkCh+Dx3Ln6H7VYqgztLjw==","shasum":"07057d6f3b6d9bf19b8f287c8d73b43da5f9f289","tarball":"http://registry-npm.ywwl.com/import-fresh/download/import-fresh-4.0.0.tgz","fileCount":5,"unpackedSize":31139,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCnNzq7uv8FkvYbwKe9lICPR4I3ucqJVEMGI1B89Y5lHAIhANtijoPrQg8GvBlZHY3siclHahViS1EYa2Jld6b3brpu"}],"size":7903,"noattachment":false,"key":"/import-fresh/-/import-fresh-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/import-fresh_4.0.0_1772006620789_0.9687590148164518"},"_hasShrinkwrap":false,"readme":"# import-fresh\n\n> Import a module while bypassing the cache\n\nUseful for testing purposes when you need to freshly import a module.\n\n## Requirements\n\n- Node.js 22.15 or later (uses module loader hooks)\n\n## Install\n\n```sh\nnpm install import-fresh\n```\n\n## Usage\n\n```js\n// foo.js\nlet count = 0;\nexport default function increment() {\n\tcount += 1;\n\treturn count;\n}\n```\n\n```js\nimport createImportFresh from 'import-fresh';\n\nconst importFresh = createImportFresh(import.meta.url);\nconst {default: increment} = await importFresh('./foo.js');\n\nincrement();\n//=> 1\n\nincrement();\n//=> 2\n\nconst {default: freshIncrement} = await importFresh('./foo.js');\n\nfreshIncrement();\n//=> 1\n```\n\n## API\n\n### createImportFresh(parentURL, options?)\n\nReturns an `importFresh` function bound to `parentURL`.\n\n`parentURL` must be a valid hierarchical URL string (for example `import.meta.url`) or a `URL` instance.\n\n#### options\n\nType: `object`\n\nThe options are process-global. Every call in the same process must use the same `skipNodeModules` value.\n\n##### skipNodeModules\n\nType: `boolean`\\\nDefault: `false`\n\nWhen `true`, modules inside `node_modules` directories are not cache-busted. This means that dependencies from npm packages will share state across fresh imports, which can be useful when you only want to freshly import your own code.\n\n### importFresh(moduleSpecifier, options?)\n\nThe function returned by `createImportFresh`.\n\n#### options\n\nType: `object`\n\n##### importAttributes\n\nType: `object`\n\nImport attributes passed to `import()`. Each value must be a string. JSON modules are automatically imported with `{type: 'json'}` when the specifier ends with `.json`.\n\n## Caveat\n\nIntended for development usage only. Repeated calls grow the ESM module cache because each call uses a unique cache-busting URL. This is an unavoidable “memory leak” and not considered a vulnerability.\n\n## Related\n\n- [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache\n- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path\n- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory\n- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily\n","publish_time":1772006620935,"_cnpm_publish_time":1772006620935,"dist-tags":{"latest":"4.0.1"}}