Skip to content

Provider alternative for istanbul-instrumenter-loader #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stahloss opened this issue Apr 11, 2020 · 4 comments
Open

Provider alternative for istanbul-instrumenter-loader #6

stahloss opened this issue Apr 11, 2020 · 4 comments

Comments

@stahloss
Copy link

istanbul-instrumenter-loader uses really old istanbul-lib-instrument

Please provide an alternative or a way to use a recent version of istanbul-lib-instrument.

@stahloss
Copy link
Author

I just got babel-plugin-istanbul working using babel-loader. Maybe it's an idea to update this example?

My coverage.webpack.js:

module.exports = {
    module: {
      rules: [
        {
            test: /\.(js|ts)$/,
            use: {
              loader: 'babel-loader',
              options: {
                // presets: ['@babel/preset-env'],
                plugins: ['babel-plugin-istanbul']
              }
            },
            enforce: 'post',
            include: [
                require('path').join(__dirname, '..', "beheer", 'src', 'app'),
            ],
            exclude: [
                /\.(e2e|spec)\.ts$/,
                /node_modules/,
                /(ngfactory|ngstyle)\.js/
              ]
          }
      ]
    }
  };

@dividendsolo
Copy link

@D0rmouse do you have a working example repo?

@stahloss
Copy link
Author

Nope, but just swap the webpack config with the one I posted here and it will work.
You need to add the babel-plugin-istanbul devDependency too, of course.

@bjuergens
Copy link

can confirm this works.

for me the entire diff for this change looks like like this

--- a/coverage.webpack.js
+++ b/coverage.webpack.js
@@ -7,10 +7,14 @@ module.exports = {
     rules: [
       {
         test: /\.(js|ts)$/,
-        loader: 'istanbul-instrumenter-loader',
-        options: { esModules: true },
+        use: {
+          loader: 'babel-loader',
+          options: {
+            plugins: ['babel-plugin-istanbul']
+          }
+        },
         enforce: 'post',
        include: require('path').join(__dirname, '..', 'src'),
         exclude: [
           /\.(e2e|spec|module|mock)\.ts$/,
           /node_modules/,

and

--- a/package.json
+++ b/package.json
@@ -59,8 +59,8 @@
     "@angular/language-service": "^11.2.14",
     "@types/fingerprintjs2": "^2.0.0",
     "@types/jasmine": "~3.9.0",
+    "babel-plugin-istanbul": "^6.1.1",
     "codelyzer": "^6.0.0",
-    "istanbul-instrumenter-loader": "^3.0.1",
     "jasmine-core": "~3.9.0",
     "jasmine-spec-reporter": "~7.0.0",
     "karma": "~6.3.4",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants