Unfortunately for developers looking to write with ES2015, many users still use older browsers that do not fully support ES2015.
This problem can be solved by transpiling ES2015 code to older ES5 code at build time using a tool like Babel. This process takes your code and changes any syntax that isn’t compatible with ES5 into one that is compatible. Unfortunately, adding this extra build step is something many developers are not comfortable with, or choose not to do, and so they are unable to enjoy these new language features.
Service workers, however, provide a great opportunity to get started with ES2015. As all browsers that currently implement service workers also implement most ES2015 features, you can safely use these new features in your service worker file—no transpilation needed.
We have already used a few ES2015 features in our service worker, including promises,