Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
externalize
Advanced tools
Create external Browserify bundles for lazy asynchronous loading
npm install externalize
The module exports a single function
externalize(
<parent bundle or array of parent bundles>,
<bundle or arrays of bundles to be externalized from the parent bundles>,
<callback fucntion>
);
Create two bundles where the second one is a subset of the parent and call
externalize(parent, subset, callback)
on them. It will do following:
in code:
var fs = require("fs");
var browserify = require("browserify");
var externalize = require("externalize");
// Parent bundle with an entry point
var parent = browserify("./index.js");
// Make subset bundle from external.js by making it explicitly requireable
var second = browserify().require("./external.js");
// Remove the subset bundle code from the parent
externalize(parent, subset, function(err) {
if (err) throw err;
// Write bundles to files after externalization
parent.bundle.pipe(fs.createWriteStream("bundle/parent.js");
second.bundle.pipe(fs.createWriteStream("bundle/second.js");
});
index.js
// would not work here because external.js is externalized to the subset bundle
// require("./external");
// Use any script loader to load the subset bundle to make the require work
// again
jQuery.getScript("bundle/second.js", function(){
var value = require("./external");
// Alerts: "external module: external module contents"
alert("external module: " + value);
});
external.js:
module.exports = "external module contents";
FAQs
Create external Browserify bundles for lazy asynchronous loading
The npm package externalize receives a total of 1 weekly downloads. As such, externalize popularity was classified as not popular.
We found that externalize 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.