import-from
Advanced tools
Comparing version 3.0.0 to 4.0.0
'use strict'; | ||
const resolveFrom = require('resolve-from'); | ||
const path = require('path'); | ||
const {createRequire} = require('module'); | ||
module.exports = (fromDirectory, moduleId) => require(resolveFrom(fromDirectory, moduleId)); | ||
module.exports = (fromDirectory, moduleId) => createRequire(path.resolve(fromDirectory, 'noop.js'))(moduleId); | ||
module.exports.silent = (fromDirectory, moduleId) => { | ||
try { | ||
return require(resolveFrom(fromDirectory, moduleId)); | ||
} catch (_) {} | ||
return createRequire(path.resolve(fromDirectory, 'noop.js'))(moduleId); | ||
} catch {} | ||
}; |
{ | ||
"name": "import-from", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Import a module like with `require()` but from a given path", | ||
"license": "MIT", | ||
"repository": "sindresorhus/import-from", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12.2" | ||
}, | ||
@@ -32,5 +33,2 @@ "scripts": { | ||
], | ||
"dependencies": { | ||
"resolve-from": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -37,0 +35,0 @@ "ava": "^1.4.1", |
@@ -1,6 +0,5 @@ | ||
# import-from [![Build Status](https://travis-ci.org/sindresorhus/import-from.svg?branch=master)](https://travis-ci.org/sindresorhus/import-from) | ||
# import-from | ||
> Import a module like with [`require()`](https://nodejs.org/api/modules.html#modules_require_id) but from a given path | ||
## Install | ||
@@ -12,3 +11,2 @@ | ||
## Usage | ||
@@ -24,3 +22,2 @@ | ||
## API | ||
@@ -48,3 +45,2 @@ | ||
## Tip | ||
@@ -61,3 +57,2 @@ | ||
## Related | ||
@@ -71,6 +66,1 @@ | ||
- [import-global](https://github.com/sindresorhus/import-global) - Import a globally installed module | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
42
1
4909
62
- Removedresolve-from@^5.0.0
- Removedresolve-from@5.0.0(transitive)