Fix issue where babel was retained

This commit is contained in:
Jan Potoms
2018-01-25 10:18:02 +01:00
parent 0e570eceb2
commit b0d8c62d1c
2 changed files with 18 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ import path from "path";
const maps = {};
const transformOpts = {};
let babel = babelCore;
let babel = null;
let piratesRevert = null;
function installSourceMapSupport() {
@@ -102,7 +102,7 @@ export default function register(opts?: Object = {}) {
// Clone to avoid mutating the arguments object with the 'delete's below.
opts = Object.assign({}, opts);
if (opts.babel) babel = opts.babel;
babel = opts.babel ? opts.babel : babelCore;
if (opts.extensions) hookExtensions(opts.extensions);

View File

@@ -119,4 +119,20 @@ describe("@babel/register", function() {
chai.expect(require(DATA_ES2015)).to.equal("hello");
});
it("Resets babel next register", () => {
function crash() {
throw new Error("shouldn't be called");
}
setupRegister({
babel: {
transform: crash,
getEnv: crash,
},
});
setupRegister();
chai.expect(require(DATA_ES2015)).to.be.ok;
});
});