Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
browserify-deoptimizer
Advanced tools
Transforms browserify bundles into a collection of single files
Sometimes you work in browsers without //@ sourceURL
or source maps. But you like using Browserify, since it's
truly amazing. How will you ever debug things? With all your modules squished into one file, it's a disaster.
Enter the Browserify Deoptimizer, which will handily “de-optimize” your Browserify bundles by turning them into individual files, including files for each module you author.
You use the Browserify Deoptimizer by first creating a Browserify bundle, programmatically. Then, instead of creating a
big string with bundle.bundle()
, you just deoptimize it!
var browserify = require("browserify");
var deoptimize = require("browserify-deoptimizer");
var bundle = browserify();
bundle.alias("jquery", "jquery-browserify");
bundle.addEntry("start.js");
var baseDirectory = process.cwd(); // module IDs will be determined relative to this
var deoptimized = deoptimize(bundle, baseDirectory);
Your deoptimized
variable will then look something like this:
{
"browserify-prelude.js": 'var require = function (file, …',
"node_modules/jquery-browserify/package.json": 'require.define("/node_modules/…',
"node_modules/jquery-browserify/index.js": 'require.define("/node_modules/…',
"browserify-aliases.js": 'require.alias("jquery-browseri…',
"start.js": 'require.define("/start.js",fun…',
"browserify-entry.js": 'require("/start.js");'
}
You can then use these module IDs to write out the wrapped files to the filesystem, and the appropriate <script>
tags
to your index.html
.
Since Browserify does some magic, we can't just create a single file for each of your modules. We need some magic files too. These are:
browserify-prelude.js
: contains the definition of require
and process
, as well as any prepends with
bundle.prepend
. This will be the first file in the map.browserify-aliases.js
: Contains any calls to Browserify's require.alias
to set up module aliases. This is inserted
into the map after the entries for the aliased files themselves (e.g. after jquery-browserify's files). If there are
no aliases, this file will not exist.browserify-entry.js
: Contains calls to require
for all entry files in the bundle. If there are no entry files,
this file will not exist.This package owes its name to r.js, the RequireJS optimizer, which turns multiple AMD modules into a single bundled file. Since this package does the opposite, I thought it'd be clever to name it a deoptimizer.
FAQs
Transforms browserify bundles into a collection of single files
The npm package browserify-deoptimizer receives a total of 0 weekly downloads. As such, browserify-deoptimizer popularity was classified as not popular.
We found that browserify-deoptimizer 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.