surma / rollup-plugin-off-main-thread

Use Rollup with workers and ES6 modules today.
Apache License 2.0
308 stars 32 forks source link

Use promises in loader instead of async/await #19

Closed surma closed 4 years ago

surma commented 4 years ago

via @lukastaegert

Refactor the loader code to just use Promises instead of async-await. I know async-await is supported by 91% of used browsers by now. But it is particularly hard to transpile and polyfill. This change will push compatibility to 94% but also make it easy to transpile to even lower compatibility targets while simply needing a Promise polyfill.

ansballard commented 4 years ago

I actually should have most of this work done per this comment, I'll take a minute next chance I get and make sure I didn't do anything crazy then I'll put it into a PR. I can also stack the other transpile-y changes on top in a separate commit if that's a change you want to make (see last comment in #3)

lukastaegert commented 4 years ago

Note that even though the release has been stalled until it has been migrated into the rollup/plugins repo, the babel plugin already has an option on master to transpile generated code such as this one. Once this is released, it can be used to transpile to lower compatibility targets provided a Promise polyfill is added. Once this is released, I am not sure there is much value in going below ES6 as there is only one "browser" (aka the "compatibility solution") that is somewhat in use and still needs it. This would save a few bytes for everyone that does not depend on it. Of course, it would mean extra friction for everyone who needs to support it.

surma commented 4 years ago

I removed all usage of async/await in 398dae5. There’s probably some golfing opportunities, but it’s good enough for now :)

surma commented 4 years ago

Published in v1.4.0