webpack-contrib / istanbul-instrumenter-loader

Istanbul Instrumenter Loader
MIT License
273 stars 65 forks source link

[bug] location of line is not match the source code #109

Open Sara2009 opened 3 years ago

Sara2009 commented 3 years ago

This is my webpack.config.js

module.exports = {
    module: {
        rule: [
            {
                test: /\.(ts|tsx)$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                options: {},
            },
            {
                test: /\.ts$|\.tsx$/,
                use: {
                    loader: 'istanbul-instrumenter-loader',
                    options: { esModules: true, produceSourceMap: true },
                },
               enforce: 'post',
               exclude: /node_modules|\.spec\.js$/,
           },
        ]
    }

}

But i found the loc is not correct. In the file istanbul-instrumenter-loader/dist/index.js: image I found the source is dealed with babel. image So the AST is generated with the babel-resolved code not the real source code. So the fileCoverage is not correct. It does not match the real source code.

image

image

So i wonder how to solve this problem?