Back to Explore

sindresorhus/import-fresh

GitHub
1 watchersOpen source

Last release: 3 months ago

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

  • The source appears actively maintained, with a recent update in 2026 (v4.0.0) and a prior maintenance update in 2025 (v3.3.1), though there is a long gap before the earlier update (v3.3.0 in 2020).
  • The apparent updates cadence is uneven, with v3.3.0 in 2020, v3.3.1 in early 2025 (about 1 year later is not supported here, it is 2020 to 2025), and then a major v4.0.0 in 2026 (roughly a year after v3.3.1).

AI summary generated Today

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

Recent updates

  • v4.0.0

    3 months ago

    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

    2/2/2025

    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

    12/20/2020

    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

    11/1/2020

    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

    11/13/2019

    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

    11/13/2019

    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

    6/30/2019

    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

    12/25/2018

    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