Skip to content

Commit 90c74ef

Browse files
committed
fix: hack for babel < 6 so that breakpoints do work
It fixes #627, but AFAIK there is badly no way of doing a test for that
1 parent e4c430f commit 90c74ef

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/postprocess.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ function importBabelDeps() {
2626
if (babel) return; // tslint:disable-line
2727
// we must use babel until we handle hoisting of jest.mock() internally
2828
babel = importBabelCore();
29+
30+
// HACK: there is an issue still open in babel 6, this is a hack to bypass it
31+
// and fix our issue #627
32+
// Issue in babel: https://github.com/babel/babel/issues/6577
33+
if (babel.version && parseInt(babel.version.split('.')[0], 10) === 6) {
34+
const File = require('babel-core/lib/transformation/file/index.js').File;
35+
File.prototype.initOptions = (original => {
36+
return function(opt) {
37+
const before = opt.sourceMaps;
38+
const result = original.apply(this, arguments);
39+
if (opt.sourceMaps != null && opt.sourceMaps !== result.sourceMaps) {
40+
result.sourceMaps = opt.sourceMaps;
41+
}
42+
return result;
43+
};
44+
})(File.prototype.initOptions);
45+
}
46+
// end of HACK
47+
2948
istanbulPlugin = importBabelPluginIstanbul();
3049
jestPreset = importBabelPresetJest();
3150
}

0 commit comments

Comments
 (0)