istanbul is throwing an error of an unexpected character "#"

85 views Asked by At

We have this webpack configuration file, setup in our custom webpack for Angular:

// configure cypress to output code coverage for sonar
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|ts)$/,
        loader: 'istanbul-instrumenter-loader',
        options: { esModules: true },
        enforce: 'post',
        include: require('path').join(__dirname, '..', 'src'),
        exclude: [
          /\.(e2e|spec)\.ts$/,
          /node_modules/,
          /(ngfactory|ngstyle)\.js/
        ]
      }
    ]
  }
};

When I run ng serve, I get the following error:

./src/app/app.module.ts - Error: Module build failed (from ./node_modules/istanbul-instrumenter-loader/dist/cjs.js):
SyntaxError: Unexpected character '#' (106:11)

If I comment out the rule, the error goes away and the application runs properly. However, we need this rule for unit testing to generate code coverage. What is causing this issue when the rule is enabled?

0

There are 0 answers