code-loader
Advanced tools
Comparing version 1.0.0 to 1.1.0
31
index.js
@@ -1,5 +0,30 @@ | ||
const requireFromString = require('require-from-string') | ||
// refs | ||
// https://stackoverflow.com/a/17585470/1793548 | ||
// https://github.com/floatdrop/require-from-string | ||
const Module = require('module') | ||
const path = require('path') | ||
module.exports = function (content) { | ||
return requireFromString(content, this.resourcePath) | ||
module.exports = function (code) { | ||
const filename = this.resourcePath | ||
const m = new Module(filename) | ||
m.filename = filename | ||
// m.paths = Module._nodeModulePaths(path.dirname(filename)) | ||
m._compile(code, filename) | ||
// watch | ||
const dep = ({ children }) => { | ||
for (const m of children) { | ||
this.addDependency(m.filename) | ||
// clear cache | ||
// https://stackoverflow.com/a/11477602/1793548 | ||
delete require.cache[m.filename] | ||
if (m.children.length) dep(m) | ||
} | ||
} | ||
dep(m) | ||
const result = m.exports | ||
if (typeof result !== 'string') throw new Error('exports must be a string') | ||
return result | ||
} |
{ | ||
"name": "code-loader", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
"repository": "git@github.com:rhyzx/code-loader.git", | ||
"author": "Bin Xin <rhyzix@gmail.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"require-from-string": "^2.0.2" | ||
} | ||
"license": "MIT" | ||
} |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1423
0
26
0
2
- Removedrequire-from-string@^2.0.2
- Removedrequire-from-string@2.0.2(transitive)