{"id":13447356,"url":"https://github.com/sindresorhus/import-fresh","last_synced_at":"2025-05-14T02:08:56.715Z","repository":{"id":18806555,"uuid":"22020904","full_name":"sindresorhus/import-fresh","owner":"sindresorhus","description":"Import a module while bypassing the cache","archived":false,"fork":false,"pushed_at":"2025-02-02T09:45:44.000Z","size":27,"stargazers_count":285,"open_issues_count":8,"forks_count":25,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-04T12:39:24.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-07-19T22:21:27.000Z","updated_at":"2025-05-01T04:34:13.000Z","dependencies_parsed_at":"2024-01-16T04:31:04.193Z","dependency_job_id":"ed66d73b-40e1-47ee-bdf5-f36b460e69fd","html_url":"https://github.com/sindresorhus/import-fresh","commit_stats":{"total_commits":32,"total_committers":7,"mean_commits":4.571428571428571,"dds":0.21875,"last_synced_commit":"75e8b1644ea4755e346776020cfc08037c414bfe"},"previous_names":["sindresorhus/require-uncached"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fimport-fresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fimport-fresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fimport-fresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fimport-fresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/import-fresh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252527347,"owners_count":21762675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:15.294Z","updated_at":"2025-05-14T02:08:51.701Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Packages","包","目录","Miscellaneous"],"sub_categories":["Miscellaneous","其他"],"readme":"# import-fresh\n\n\u003e Import a module while bypassing the [cache](https://nodejs.org/api/modules.html#modules_caching)\n\nUseful for testing purposes when you need to freshly import a module.\n\n## ESM\n\nFor ESM, you can use this snippet:\n\n```js\nconst importFresh = moduleName =\u003e import(`${moduleName}?${Date.now()}`);\n\nconst {default: foo} = await importFresh('foo');\n```\n\n**This snippet causes a memory leak, so only use it for short-lived tests.**\n\n## Install\n\n```sh\nnpm install import-fresh\n```\n\n## Usage\n\n```js\n// foo.js\nlet i = 0;\nmodule.exports = () =\u003e ++i;\n```\n\n```js\nconst importFresh = require('import-fresh');\n\nrequire('./foo')();\n//=\u003e 1\n\nrequire('./foo')();\n//=\u003e 2\n\nimportFresh('./foo')();\n//=\u003e 1\n\nimportFresh('./foo')();\n//=\u003e 1\n```\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fimport-fresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fimport-fresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fimport-fresh/lists"}