ember-service-worker
ember-service-worker copied to clipboard
Allow usage of async/await
Every browser with SW support, supports async/await too.
This PR removes regenerator
from the babel options and updates broccoli-rollup
and broccoli-uglify-sourcemap
to be able to parse async/await syntax.
Looks great! But does it not crash on a registration if you use async/await in an unsupported browser?
If it does I'm in favor of a progressive enhancement path rather than bringing in regenerator. The footprint of that plugin is not small.
This will defintely "crash and burn" if one uses async/await in sw-registration code in browsers without SW support. It would crash anyways today as we'd need to import regenerator explicitly (I'm not sure if ember-maybe-import-regenerator works here, never tried).
So this is only a problem if one uses async AND ships code for non-SW browser in registration code (which might not be that uncommon? I don't know).
Maybe implement this as a flag? Or the ability to customize babel options for ember-service-worker?
// ...
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
'ember-service-worker': {
babel: { blacklist: ['regenerator'] },
},
});
// ...
};
I like that idea, to supplement the babel options if possible.