Make require("6to5/register") work with browserify
Previously, you'd have to create a separate file for using 6to5 with both node and browserify, as the latter wasn't able to properly handle loading 6to5's dependency tree and would crash on attempting to do so. This change instructs browserify to use "register-browser.js" in place of "register.js". "register-browser.js" still loads the 6to5 polyfill, but is otherwise ignored.
This commit is contained in:
19
test/browserify.js
Normal file
19
test/browserify.js
Normal file
@@ -0,0 +1,19 @@
|
||||
var browserify = require("browserify");
|
||||
var assert = require("assert");
|
||||
var path = require("path");
|
||||
var vm = require("vm");
|
||||
|
||||
suite("browserify", function() {
|
||||
test("6to5/register may be used without breaking browserify", function(done) {
|
||||
var bundler = browserify(path.join(__dirname, "fixtures/browserify/register.js"));
|
||||
|
||||
bundler.bundle(function(err, bundle) {
|
||||
if (err) return done(err);
|
||||
assert.ok(bundle.length, "bundle output code");
|
||||
|
||||
// ensure that the code runs without throwing an exception
|
||||
vm.runInNewContext(bundle, {});
|
||||
done();
|
||||
})
|
||||
})
|
||||
});
|
||||
3
test/fixtures/browserify/register.js
vendored
Normal file
3
test/fixtures/browserify/register.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
require('../../../register')({
|
||||
ignoreRegex: false
|
||||
});
|
||||
Reference in New Issue
Block a user