ember-service-worker icon indicating copy to clipboard operation
ember-service-worker copied to clipboard

Allow usage of async/await

Open topaxi opened this issue 6 years ago • 4 comments

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.

topaxi avatar Oct 20 '17 09:10 topaxi

Looks great! But does it not crash on a registration if you use async/await in an unsupported browser?

ghost avatar Oct 20 '17 15:10 ghost

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.

bcardarella avatar Oct 20 '17 15:10 bcardarella

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'] },
    },
  });
  // ...
};

topaxi avatar Oct 21 '17 06:10 topaxi

I like that idea, to supplement the babel options if possible.

ghost avatar Oct 31 '17 13:10 ghost