Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
browserify-optional
Advanced tools
A browserify transform that allows optional dependencies in try..catch blocks
It is a common pattern in Node to support optional dependencies via requires in try..catch blocks. Browserify doesn't support this by default and throws a compile time error when it cannot find a module. You can solve the problem by using browserify's exclude option, but this works globally instead of at a per-module level. This transform fixes the problem by moving the compile time error to a runtime error for requires of missing modules inside try..catch blocks.
The transform would transform the following code such that requiring missing-module
would throw
a runtime error instead of a compile time error, making the code work as expected.
try {
var x = require('missing-module');
} catch (e) {
var x = require('replacement-module');
}
To set it up in browserify, add this to your package.json:
"browserify": {
"transform": ["browserify-optional"]
}
MIT
FAQs
A browserify transform that allows optional dependencies in try..catch blocks
The npm package browserify-optional receives a total of 355,126 weekly downloads. As such, browserify-optional popularity was classified as popular.
We found that browserify-optional demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.