summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/import-fresh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/import-fresh')
-rw-r--r--tools/node_modules/eslint/node_modules/import-fresh/index.js21
-rw-r--r--tools/node_modules/eslint/node_modules/import-fresh/package.json2
-rw-r--r--tools/node_modules/eslint/node_modules/import-fresh/readme.md20
3 files changed, 20 insertions, 23 deletions
diff --git a/tools/node_modules/eslint/node_modules/import-fresh/index.js b/tools/node_modules/eslint/node_modules/import-fresh/index.js
index 7abc670619..425ed98c42 100644
--- a/tools/node_modules/eslint/node_modules/import-fresh/index.js
+++ b/tools/node_modules/eslint/node_modules/import-fresh/index.js
@@ -8,22 +8,25 @@ module.exports = moduleId => {
throw new TypeError('Expected a string');
}
- const filePath = resolveFrom(path.dirname(parentModule(__filename)), moduleId);
+ const parentPath = parentModule(__filename);
+ const filePath = resolveFrom(path.dirname(parentPath), moduleId);
+
+ const oldModule = require.cache[filePath];
// Delete itself from module parent
- if (require.cache[filePath] && require.cache[filePath].parent) {
- let i = require.cache[filePath].parent.children.length;
+ if (oldModule && oldModule.parent) {
+ let i = oldModule.parent.children.length;
while (i--) {
- if (require.cache[filePath].parent.children[i].id === filePath) {
- require.cache[filePath].parent.children.splice(i, 1);
+ if (oldModule.parent.children[i].id === filePath) {
+ oldModule.parent.children.splice(i, 1);
}
}
}
- // Delete module from cache
- delete require.cache[filePath];
+ delete require.cache[filePath]; // Delete module from cache
+
+ const parent = require.cache[parentPath]; // If `filePath` and `parentPath` are the same, cache will already be deleted so we won't get a memory leak in next step
- // Return fresh module
- return require(filePath);
+ return parent === undefined ? require(filePath) : parent.require(filePath); // In case cache doesn't have parent, fall back to normal require
};
diff --git a/tools/node_modules/eslint/node_modules/import-fresh/package.json b/tools/node_modules/eslint/node_modules/import-fresh/package.json
index 73e9316d89..38892a62e4 100644
--- a/tools/node_modules/eslint/node_modules/import-fresh/package.json
+++ b/tools/node_modules/eslint/node_modules/import-fresh/package.json
@@ -47,5 +47,5 @@
"heapdump": "node heapdump.js",
"test": "xo && ava && tsd"
},
- "version": "3.1.0"
+ "version": "3.2.1"
} \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/import-fresh/readme.md b/tools/node_modules/eslint/node_modules/import-fresh/readme.md
index f5414b8cf3..0bfa1c9044 100644
--- a/tools/node_modules/eslint/node_modules/import-fresh/readme.md
+++ b/tools/node_modules/eslint/node_modules/import-fresh/readme.md
@@ -37,22 +37,16 @@ importFresh('./foo')();
```
+## 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
- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory
- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily
-
-
----
-
-<div align="center">
- <b>
- <a href="https://tidelift.com/subscription/pkg/npm-require-uncached?utm_source=npm-require-uncached&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
- </b>
- <br>
- <sub>
- Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
- </sub>
-</div>