import-fresh
Advanced tools
Comparing version 3.1.0 to 3.2.0
15
index.js
@@ -11,11 +11,14 @@ 'use strict'; | ||
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); | ||
} | ||
@@ -29,3 +32,3 @@ } | ||
// Return fresh module | ||
return require(filePath); | ||
return require.cache[parentPath].require(filePath); | ||
}; |
{ | ||
"name": "import-fresh", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Import a module while bypassing the cache", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -40,2 +40,9 @@ # import-fresh [![Build Status](https://travis-ci.org/sindresorhus/import-fresh.svg?branch=master)](https://travis-ci.org/sindresorhus/import-fresh) | ||
## 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 | ||
@@ -47,14 +54,1 @@ | ||
- [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> |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4603
46
0
53