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

fix: Correcting SW flag in dev #1534

Merged
merged 8 commits into from
Mar 8, 2021

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Feb 7, 2021

What kind of change does this PR introduce?

Bug fix

Did you add tests for your changes?

No

Summary

Running yarn dev --sw would create an error that process was not defined. This is because there was no DefinePlugin entry for process.env.ES_BUILD on dev. This was found here #1531 (comment)

Upon adding that, the service worker would attempt to be installed but run into errors upon registering. The solution for that seems to be adding the InjectManifest as a plugin, though this isn't ideal and throws a workbox warning (GoogleChrome/workbox#1790). Kinda seems like we just shouldn't support the non-debug SW during dev?

Additionally, this still fails if ran with the --esm flag, as no sw-esm.js is generated in dev. But that's probably a separate issue.

Does this PR introduce a breaking change?
No

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2021

🦋 Changeset detected

Latest commit: fae2269

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

@rschristian rschristian marked this pull request as ready for review February 7, 2021 03:18
@rschristian rschristian requested a review from a team as a code owner February 7, 2021 03:18
@rschristian rschristian changed the title fix: Correcing SW flag in dev fix: Correcting SW flag in dev Feb 7, 2021
@@ -103,6 +117,38 @@ async function clientConfig(env) {
},
].filter(Boolean)
),
...(env.sw
Copy link
Member

Choose a reason for hiding this comment

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

this makes things a lot less readable

Copy link
Member Author

Choose a reason for hiding this comment

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

The nested ternary?

Yeah, sorry, can't remember why I did it like that. I'll try to fix that up tomorrow (3am here)

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed an update, hopefully that's more readable.

@ForsakenHarmony ForsakenHarmony merged commit 9f9277b into preactjs:master Mar 8, 2021
@preact-bot preact-bot mentioned this pull request Mar 8, 2021
@rschristian rschristian deleted the fix/swOnDev branch March 22, 2021 15:48
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.

2 participants