Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | # import-fresh
|
---|
2 |
|
---|
3 | > Import a module while bypassing the [cache](https://nodejs.org/api/modules.html#modules_caching)
|
---|
4 |
|
---|
5 | Useful for testing purposes when you need to freshly import a module.
|
---|
6 |
|
---|
7 | ## Install
|
---|
8 |
|
---|
9 | ```
|
---|
10 | $ npm install import-fresh
|
---|
11 | ```
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | // foo.js
|
---|
17 | let i = 0;
|
---|
18 | module.exports = () => ++i;
|
---|
19 | ```
|
---|
20 |
|
---|
21 | ```js
|
---|
22 | const importFresh = require('import-fresh');
|
---|
23 |
|
---|
24 | require('./foo')();
|
---|
25 | //=> 1
|
---|
26 |
|
---|
27 | require('./foo')();
|
---|
28 | //=> 2
|
---|
29 |
|
---|
30 | importFresh('./foo')();
|
---|
31 | //=> 1
|
---|
32 |
|
---|
33 | importFresh('./foo')();
|
---|
34 | //=> 1
|
---|
35 | ```
|
---|
36 |
|
---|
37 | ## import-fresh for enterprise
|
---|
38 |
|
---|
39 | Available as part of the Tidelift Subscription.
|
---|
40 |
|
---|
41 | 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)
|
---|
42 |
|
---|
43 | ## Related
|
---|
44 |
|
---|
45 | - [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache
|
---|
46 | - [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
|
---|
47 | - [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory
|
---|
48 | - [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily
|
---|
Note:
See
TracBrowser
for help on using the repository browser.