Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basically, here’s what’s going on. Babel has a transformer, called runtime, that can turn ES6 code like `new Promise()` into `new core.Promise()`, where `core.Promise` is a polypill. But, that runtime transformer (which I was already using), can’t polyfill some ES6 code (e.g. `var it = "test"; it.startsWith("t");`) because it doesn't know, e.g., that the `it` in `it.startsWith` is a string, so it doesn't know that you're looking for `String.prototype.startsWith`. The solution to this is to require the babel polypill, which modifies the global `String.prototype` directly. That's what I was doing before this commit, except that it also causes a problem: any dependents of this library also get their globals changed. Now, maybe that should usually be ok in practice—since most of the polyfills match the ES6+ specs—but, of course, there's a possibility of a polyfill having a bug, or two polyfills doing something different in an unpolyfillable case. So, clobbering the dependent's globals is still a bad idea. And, with this in mind, Babel actually throws an error if the dependent tries to load babel/polyfill for a second time…so just transparently modifying the globals and bearing the risk isn't possible even if it's what we wanted to do. So, this commit removes the polyfill's require, which then allows me to move babel to a devDependency (without reopening #11, which was based on the polyfill line). This means no using the ES6/7 `Array.prototype` and `String.prototype` methods, but, oh well. It looks like I’d removed all uses of them earlier anyway in preparation for this change. Should close #47
- Loading branch information