Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Bug: Butternut fails on some intentional runtime errors #139

Open loilo opened 7 years ago

loilo commented 7 years ago

I tried to squash es6-shim, which among other things provides a polyfill for String.prototype.startsWith.

There seem to be intentional misbehaviours in the source code, which lets Butternut fail its job.

TypeError: First argument to String.prototype.startsWith must not be a regular expression
    at String.startsWith (native)
    at Node.getValue (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:987:22)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:1424:62)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:3553:9)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:190:11)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:1728:40)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:187:33)
    at Node.initialise (/path/to/project/node_modules/butternut/dist/butternut.cjs.js:998:32)
    at /path/to/project/node_modules/butternut/dist/butternut.cjs.js:3146:46
    at Array.forEach (native)
Rich-Harris commented 7 years ago

Ha, tricky. I suppose Butternut ought to have an option to disable optimisations around built-in methods anyway...