Back to Explore

sindresorhus/import-fresh

GitHub
2 watchersOpen source

Last release:

Import-fresh is a Node.js utility for importing an ES module while bypassing the import cache, so code can be reloaded with fresh state. It is useful for development and testing scenarios where you need a freshly imported module, with an optional option to avoid cache-busting modules inside node_modules.

Project status

  • Actively maintained: Yes. The repo shows a recent update in 2026-02-25 (v4.0.0), indicating ongoing attention rather than maintenance-only status.
  • Update cadence: After an older gap (last notable updates in 2025 and earlier), there has been a major update within the past few months relative to today (2026-06-09), suggesting a renewed or active development cycle at least recently.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v4.0.0

    v4.0.0 is a major release that converts import-fresh to pure ESM and requires Node.js 22.15+. The core behavior changes to an async, hook-based implementation that supports “fresh” importing of ESM modules.

    BreakingFeatures
  • v3.3.1

    v3.3.1 is a small maintenance release that claims to fix Bun compatibility. The code changes primarily adjust how module loading falls back when the parent module lacks a usable require function.

  • v3.3.0

    v3.3.0 primarily updates the TypeScript type declarations for import-fresh. It also replaces the Travis CI configuration with a GitHub Actions workflow and includes a few metadata/docs formatting changes.

    Features
  • v3.2.2

    v3.2.2 updates import-fresh to safely handle situations where there is no parent module. The change adjusts how the base directory (cwd) is determined when resolving the target module, and adds a regression test for this scenario.

  • v3.2.1

    v3.2.1 adds handling for cases where the parent module is missing from the require cache, and for self-import scenarios. The implementation changes how the fresh module is re-required, adding a fallback to normal require when the parent cache entry is unavailable.

  • v3.2.0

    v3.2.0 changes how import-fresh reloads modules so the reloaded module keeps a transparent parent relationship to the original caller. This is implemented by removing the cached module from its parent children list and then requiring the fresh module using the caller module's require method rather than requiring it directly from import-fresh's module context.

    Breaking
  • v3.1.0

    Release v3.1.0 primarily adds TypeScript type definitions for import-fresh. The diff also updates tooling and CI configuration by adding tsd-based type tests and expanding the Travis Node.js matrix.

    Features
  • v3.0.0

    v3.0.0 introduces a breaking platform requirement and improves the logic used to find modules to import. Developers upgrading should ensure their runtime matches the new Node.js requirement to avoid immediate startup or compatibility failures.

    Breaking