babel / babel/minify

Enable warnings for unsafe transformations

Open
#570 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

Having this option enabled by default in `babili` preset can cause a lot of issues, especially when using Babili on the server side with express.js, which relies on `arguments.length`, because it will convert an error handler to a normal middleware by removing the last parameter:
```js
app.use((err, req, res, next) => {
if (err) { res.status(500).send('¯\_(ツ)_/¯') }
});
```
gets converted to:
```js
app.use((a,b,c)=>{a&&c.status(500).send('\xAF_(\u30C4)_/\xAF')});
```

It's also causing issues with ioredis library (and probably many more), which unfortunately also relies on `arguments.length` in a few places.

If enabling this by default is not an option, maybe a warning about it could be added to the README for Babili or babili-preset package? Currently it's only mentioned in the README for dead code elimination plugin itself, but I doubt people usually go through every plugin in the preset to see what options they have and if they are potentially dangerous. Or maybe there could be a `babel-babili-preset-safe` with all these `keep*` options turned on?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.