Report alignment issue when inputSourceMap from TypeScript
See original GitHub issueHere is a jest transformer I’m using:
const tsc = require("typescript")
const tsConfig = require("./tsconfig.json") || {}
const babel = require('babel-core')
const jestPreset = require('babel-preset-jest')
const babelPluginIstanbul = require('babel-plugin-istanbul').default
const createTransformer = (options) => {
options = Object.assign({}, options, {
plugins: (options && options.plugins) || [],
presets: ((options && options.presets) || []).concat([jestPreset]),
retainLines: true
});
delete options.cacheDirectory;
delete options.filename;
return {
canInstrument: true,
process(src, filename, config, transformOptions) {
let inputSourceMap
if (filename.endsWith(".ts") || filename.endsWith(".tsx")) {
let compilerOptions = Object.assign({},
tsConfig.compilerOptions, {
sourceMap: true
}
)
let transpileOut = tsc.transpileModule(src, {
fileName: filename,
compilerOptions
});
src = transpileOut.outputText
inputSourceMap = JSON.parse(transpileOut.sourceMapText)
}
const theseOptions = Object.assign({
filename,
//inlineSourceMap,
}, options);
if (transformOptions && transformOptions.instrument) {
theseOptions.auxiliaryCommentBefore = ' istanbul ignore next ';
// Copied from jest-runtime transform.js
theseOptions.plugins = theseOptions.plugins.concat([
[
babelPluginIstanbul, {
inputSourceMap,
cwd: config.rootDir,
exclude: []
}
]
]);
}
return babel.transform(src, theseOptions).code
}
};
};
module.exports = createTransformer();
module.exports.createTransformer = createTransformer;
The highlights in the coverage report is misaligned.
May be related to babel/babel#5408
Apparently babel also takes inputSourceMap as an option, but only takes inputSourceMap into account after plugins have run. I’m assuming that’s why this plugin has that option as well. But no matter what I do I get the same misalignment.
I’ve also tried having TypeScript pass the sourcemap inline, but that still does the same thing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Export report to excel alignment issue - Dynamics 365 ...
Hi there, we got an requirement to resolve alignment issues for Ledger Transaction List Account. The problem is when we are exporting the...
Read more >@netlify/esbuild | Yarn - Package Manager
This release updates esbuild to match TypeScript's new output in this case: // Original code console.log(<a>{...b}</a>) // Old output console.log(/* @__PURE__ ...
Read more >Diff - 053ddb97bfa3b2e3021b6eb07f873233a62b2abb^! - tools
The Typescript compiler provides two things: First, ... + +Once node is installed, you can install typescript using + + [shell]$ npm install ......
Read more >Changelog - esbuild - Breword 文档集合
This means that post-processing esbuild's output with the TypeScript compiler (e.g. for lowering ES6 to ES5) will cause issues since TypeScript will fail...
Read more >Commits · Tyler Longren / frontend-starter · GitLab
"url": "https://github.com/jonschlinkert/align-text/issues" ... feat(typings): add typings to support TypeScript (#646). * use current node.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My setup differs slightly. I used TypeScript -> Webpack transpiling with babel.
@lukescott Can you please upload the source maps of the transpilation pipelines (just for your demo file, istanbul). Then the source maps can be analyzed. If the mapping error already occurs in these source maps, then it is not an error caused by istanbul.
Edit: To me it seems as the input source map is not considered at all when using together with babel
@lukescott just doing some issue cleanup – sounds like you did ultimately land in a good place with this bug, i.e., got everything working.