Skip to content

Commit

Permalink
fix: hack for babel < 6 so that breakpoints do work
Browse files Browse the repository at this point in the history
It fixes #627, but AFAIK there is badly no way of doing a test for that
  • Loading branch information
huafu committed Aug 5, 2018
1 parent e4c430f commit 90c74ef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/postprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ function importBabelDeps() {
if (babel) return; // tslint:disable-line
// we must use babel until we handle hoisting of jest.mock() internally
babel = importBabelCore();

// HACK: there is an issue still open in babel 6, this is a hack to bypass it
// and fix our issue #627
// Issue in babel: https://github.com/babel/babel/issues/6577
if (babel.version && parseInt(babel.version.split('.')[0], 10) === 6) {
const File = require('babel-core/lib/transformation/file/index.js').File;
File.prototype.initOptions = (original => {
return function(opt) {
const before = opt.sourceMaps;
const result = original.apply(this, arguments);
if (opt.sourceMaps != null && opt.sourceMaps !== result.sourceMaps) {
result.sourceMaps = opt.sourceMaps;
}
return result;
};
})(File.prototype.initOptions);
}
// end of HACK

istanbulPlugin = importBabelPluginIstanbul();
jestPreset = importBabelPresetJest();
}
Expand Down

0 comments on commit 90c74ef

Please sign in to comment.