Fix issue where babel was retained
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user