An open-source entry in TopGit's GitHub warehouse: babel/babelify, 1.7k stars, JavaScript. Browserify transform for Babel
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
var fs = require("fs");
var browserify = require("browserify");
browserify("./script.js")
.transform("babelify", {presets: ["@babel/preset-env", "@babel/preset-react"]})
.bundle()
.pipe(fs.createWriteStream("bundle.js"));
NOTE: Presets and plugins need to be installed as separate modules. For the above examples to work, you'd need to also install @babel/preset-env and @babel/preset-react:
import NavBar from "nav-bar.babel";
var Panels = require("panels.babel");
NOTE: By default, Browserify will only lookup .js and .json files when the extension is omitted (like node's require). To lookup additional extensions, use browserify's extensions option.
Now you can omit the extension and compile .babel files:
import NavBar from "nav-bar";
var Panels = require("panels");
Source maps
By default, browserify sets the source map sources paths relative to the basedir (or to process.cwd() if not set). To make the sources paths absolute, set the sourceMapsAbsolute option on babelify:
browserify().transform(babelify.configure({
// Optional ignore regex - if any filenames **do** match this regex then
// they aren't compiled
ignore: /regex/,
// Optional only regex - if any filenames **don't** match this regex
// then they aren't compiled
only: /my_es6_folder/
}))
Babelify emits a babelify event with Babel's full result object as the first
argument, and the filename as the second. Browserify doesn't pass-through the
events emitted by a transform, so it's necessary to get a reference to the
transform instance before you can attach a listener for the event:
var b = browserify().transform(babelify);
b.on("transform", function(tr) {
if (tr instanceof babelify) {
tr.once("babelify", function(result, filename) {
result; // => { code, map, ast, metadata }
});
}
});
FAQ
Why aren't files in node_modules being transformed?
This is the default browserify behavior.
A possible solution is to add:
{
"browserify": {
"transform": ["babelify"]
}
}
to the root of all your modules package.json that you want to be transformed. If you'd like to
specify options then you can use:
Another solution (proceed with caution!) is to run babelify as a global transform. Use the babel ignore option to narrow the number of files transformed:
The above example will result in a transform that also includes the app module in node_modules: the global flag transform all files, and the ignore regular expression then excludes all those in the node_modules directory except those that are in node_modules/app (since ?! will match if the given suffix is absent).
Why am I not getting source maps?
To use source maps, enable them in browserify with the debug option:
browserify({debug: true}).transform("babelify");
$ browserify -d -t [ babelify ]
If you want the source maps to be of the post-transpiled code, then leave debug on, but turn off babelify's sourceMaps:
TopGit's last sync did not record any GitHub topics for babel/babelify. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on babel/babelify?
The most recent commit recorded on babel/babelify was 5.1 years ago, based on the GitHub push timestamp. The repository has 112 forks — one of the better signals of community interest.
How many stars does babel/babelify have?
babel/babelify has 1.7k GitHub stars — refresh the page for the live number, or check github.com/babel/babelify. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is babel/babelify written in?
babel/babelify is written primarily in JavaScript. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about babel/babelify?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/babel/babelify is the definitive source.
Read full README in the tab above.
Want a second opinion on babelify?
Ask an AI that can read this page — one click and you get its take on babelify.