From 75e8b1644ea4755e346776020cfc08037c414bfe Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 6 Nov 2023 22:26:55 +0700 Subject: [PATCH] Meta tweaks --- .github/funding.yml | 2 -- .github/workflows/main.yml | 4 ++-- package.json | 5 +++++ readme.md | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 10 deletions(-) delete mode 100644 .github/funding.yml diff --git a/.github/funding.yml b/.github/funding.yml deleted file mode 100644 index 4f0376a..0000000 --- a/.github/funding.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: sindresorhus -tidelift: npm/import-fresh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b85fc2a..e4f5acd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,8 @@ jobs: - 8 - 6 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/package.json b/package.json index 0c09362..e00b08a 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,11 @@ "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, + "exports": { + "types": "./index.d.ts", + "default": "./index.js" + }, + "sideEffects": false, "engines": { "node": ">=6" }, diff --git a/readme.md b/readme.md index bd14c79..074c80d 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,18 @@ Useful for testing purposes when you need to freshly import a module. +## ESM + +For ESM, you can use this snippet: + +```js +const importFresh = moduleName => import(`${moduleName}?${Date.now()}`); + +const {default: foo} = await importFresh('foo'); +``` + +**This snippet causes a memory leak, so only use it for short-lived tests.** + ## Install ``` @@ -34,12 +46,6 @@ importFresh('./foo')(); //=> 1 ``` -## import-fresh for enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of import-fresh and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-import-fresh?utm_source=npm-import-fresh&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - ## Related - [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache