New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

code-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-loader - npm Package Compare versions

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
}

7

package.json
{
"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"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc