.babelrc breaks Tree Shaking

Do you want to request a feature or report a bug?

Bug/Lack of Documentation.

What is the current behavior?

Tree Shaking works as expected when not using .babelrc, but stops working withit enabled.

If the current behavior is a bug, please provide the steps to reproduce.

Gist:
https://github.com/krobolt/webpack-4-trees-shaking

If you remove the .babelrc config, everything works as expected. With it, tree shaking is ignored and longString() is being compiled in the final bundle.js (production)

I have also tried the following (taken from github):

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "> 2%%"]
      }
    }]
  ],
  "plugins": ["syntax-dynamic-import"]
}

What is the expected behavior?

Should remove dead code src/math.js longString();

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

Author: Fantashit

1 thought on “.babelrc breaks Tree Shaking

Comments are closed.