Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
A poor man's module namespacing solution for the browser.
defuse.def('foo.bar', function(exports) {
exports.baz = function() { return 'qux'; }
});
console.log(defuse.use('foo.bar').baz);
For simple projects, I sometimes don't need the power offered by module loaders, bundlers or similar tools, and would prefer to just have a way of namespacing the project's modules, as opposed to a complete solution for require()
ing and using everything, vendor libraries included.
Browserify is really awesome. My only reason for not using it for every browser-based project is that I have yet to find a way of testing browserified projects using phantomjs. For projects that don't use the DOM, or projects which make sense both in node and the browser, browserify is perfect. The tests can be done from node, and each module to be tested can simply be require()
d. Things aren't as simple when phantomjs is involved. Short of writing a very awkward require()
utility available in the tests, we need to test each module using the entire browserified bundle. This makes writing tests a bit more difficult, since the stack traces are less useful than if the modules were still separate files.
defuse.def(name, loader)
Defines a module.
defuse.def('foo.bar', function(exports) {
exports.baz = function() { return 'qux'; }
});
defuse.use(name)
Returns a defined.
console.log(defuse.use('foo.bar').baz);
defuse.pollute()
Pollutes the global namespace with def
, use
and undef
. Tucked away in a function to try be slightly less opinionated.
defuse.pollute();
// we can now do this:
def('foo.bar');
use('foo.bar');
defuse.undef(name)
Undefines a module.
defuse.undef('foo.bar');
FAQs
A poor man's module namespacing solution for the browser
The npm package defuse receives a total of 4 weekly downloads. As such, defuse popularity was classified as not popular.
We found that defuse 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.
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.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.