babel / preset-modules

A Babel preset that targets modern browsers by fixing engine bugs (will be merged into preset-env eventually)
MIT License
739 stars 18 forks source link

Not working correctly with webpack-bundle-analyzer #30

Closed Makio64 closed 3 years ago

Makio64 commented 3 years ago

When I user the preset-modules, the bundle analyzer plugin doesnt show the gzip size from the bundle compile by babel.

Works correctly with @babel/preset-env.

I opened an issue also on the webpack-bundle-analyzer repo

https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/440

developit commented 3 years ago

The best way to solve this is to switch from @babel/preset-modules to @babel/preset-env with the new bugfixes:true option. It's the same set of plugins, but you get to control the browser configuration:

{
  "presets": [
-    ["@babel/preset-modules"]
+    ["@babel/preset-env", {
+      "targets": {
+        "esmodules": true
+      },
+      "bugfixes": true
+    }]
  ]
}