Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable regenerator in legacy bundles #1617

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

developit
Copy link
Member

What kind of change does this PR introduce?

Transpiles generators to regenerator in legacy bundles.

Summary

In 3.3.0, we stopped using fast-async to transpile async functions, however this meant they were transpiled to generators, which we don't transpile at all. The modern bundles should be unaffected by all of these changes, so let's enable regenerator to handle both async and generator functions in legacy bundles.

Does this PR introduce a breaking change?

No, it fixes an unintentionally-breaking change.

@developit developit requested a review from a team as a code owner November 18, 2021 16:29
@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2021

🦋 Changeset detected

Latest commit: dcf6a21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@developit
Copy link
Member Author

Not sure how I managed to make the Service Worker tests fail with this PR.

@rschristian
Copy link
Member

rschristian commented Nov 19, 2021

Seems both service workers (esm and legacy) are having regenerator inserted in. I imagine they should be excluded?

@developit
Copy link
Member Author

@rschristian I was thinking that was the case, yeah. Neither should have it, or at least the modern one shouldn't have it (the legacy sw file never gets used, no browsers support SW that don't also support ESM).

@developit
Copy link
Member Author

Darn, function Use entries are only supported as of Webpack 4

@@ -182,10 +183,14 @@ module.exports = function createBaseConfig(env) {
loader: require.resolve('babel-loader'),
options: Object.assign(
{ babelrc: false },
createBabelConfig(env, { browsers }),
createBabelConfig(env, {
browsers: info.compiler.name === 'InjectManifest'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does this do?

Copy link
Member Author

@developit developit Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to keep modern syntax in both generated sw.js outputs, since service worker is only supported by fairly modern browsers with generator/async support anyway. The compiler.name check is looking for the child compiler created by the workbox-webpack-plugin InjectManfiest plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would make sense to add a comment for future reference

@@ -173,7 +174,7 @@ module.exports = function createBaseConfig(env) {

module: {
rules: [
{
(info) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests seem to be failing because this is a function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only supported in newer Webpack?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, isn't supported in newer Webpack either. Rules have to be objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants