Installations
npm install @small-tech/import-fresh
Developer Guide
Typescript
No
Module System
ESM
Node Version
14.15.4
NPM Version
6.14.10
Score
64.8
Supply Chain
86.7
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
small-tech
Download Statistics
Total Downloads
845
Last Day
1
Last Week
5
Last Month
22
Last Year
157
GitHub Statistics
3 Stars
5 Commits
3 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.1
Package Id
@small-tech/import-fresh@1.0.1
Unpacked Size
5.67 kB
Size
2.71 kB
File Count
7
NPM Version
6.14.10
Node Version
14.15.4
Total Downloads
Cumulative downloads
Total Downloads
845
Last day
-50%
1
Compared to previous day
Last week
-16.7%
5
Compared to previous week
Last month
266.7%
22
Compared to previous month
Last year
0.6%
157
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
@small-tech/import-fresh
Import a fresh, uncached version of an EcmaScript Module (ESM; aka ES6 module/JavaScript Module).
Note: This will leak memory and eventually crash your system. Garbage collecting stale ESM modules is not a solved problem as of Feb, 2021. Do not use this in production.
Syntax
1importFresh(absolutePathToModule)
Example
In module.mjs:
1export default (() => Math.random())
In index.mjs:
1import path from 'path' 2import importFresh from '@small-tech/importFresh' 3 4console.log((await importFresh(path.resolve('./module.mjs'))).default) 5console.log((await importFresh(path.resolve('./module.mjs'))).default)
Run index.mjs and note that you see two different random numbers.
Do you need this module?
Before you just npm install
this, ask yourself if you really need it.
If you’re only going to use this in one place, you can cache bust using a single line of vanilla JavaScript:
e.g.,
1const myModule = await import(`./my-module?update=${new Date()}`)
(Bonus: you won’t have to use absolute paths.)
And if you want to use it from several places in the same file, you can just make a simple function:
1function importFresh(modulePath) { 2 return await import(`${modulePath}?update=${new Date()}`) 3}
The only time this module really saves you any work is if you need this functionality from multiple files within your project.
So evaluate whether you need to use it and save a dependency if you don’t.
Like this? Fund us!
Small Technology Foundation is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.
Copyright
© 2021 Aral Balkan, Small Technology Foundation.
License
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Score
2.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More