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

feat!: new custom service worker build #629

Merged
merged 11 commits into from
Feb 10, 2024

Conversation

userquin
Copy link
Member

@userquin userquin commented Dec 23, 2023

After some digging, we found the problem in esbuild and the solution:

  • change Vite build to use .mjs extension instead .js
  • rename .mjs file to the original after the build
  • rename also .mjs.map when sourcemap file generated

Thanks to @benmccann for filing the issue on Vite vitejs/vite#15379 and @Rich-Harris for the solution on SvelteKit sveltejs/kit#11400, this PR is a copy of the SvelteKit solution.

This PR also includes:

  • include custom vite build module (vite.ts): extract logic to a new module
  • include custom inject manifest strategy options for target, minify, sourcemap and dead code elimination: current version using mode option for minify and dead code elimination in workbox modules used in the sw; with new approach we can minify, add source map and use workbox logs in a production build (we can minify the code having sourcemap and workbox logs for example)
  • deprecate plugins including new buildPlugins option for Rollup and Vite plugins: added an example and the corresponding test in vue-route example using Vite plugin with a simple virtual module

NOTE: added lodash-es to test it in Vite ecosystem-ci.

closes #566
closes #571
closes #575
closes #615
closes #625
closes #655

supersedes #572

Copy link

netlify bot commented Dec 23, 2023

Deploy Preview for vite-plugin-pwa-legacy ready!

Name Link
🔨 Latest commit 3d8633e
🔍 Latest deploy log https://app.netlify.com/sites/vite-plugin-pwa-legacy/deploys/65c77af7965a590008ccb7eb
😎 Deploy Preview https://deploy-preview-629--vite-plugin-pwa-legacy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@userquin userquin mentioned this pull request Dec 24, 2023
Copy link
Member

@antfu antfu left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

src/modules.ts Outdated Show resolved Hide resolved
@userquin userquin changed the title feat: new custom service worker build feat!: new custom service worker build Dec 29, 2023
src/vite-build.ts Outdated Show resolved Hide resolved
@svihpinc
Copy link

svihpinc commented Feb 4, 2024

@userquin thank you for resolving the linked issues. When can we expect this to be released as v0.18? Also, is there a way to use this in a project somehow, maybe through a next release?

@userquin userquin merged commit 865fdad into main Feb 10, 2024
4 checks passed
@userquin userquin deleted the userquin/feat-new-custom-sw-vite-build branch February 10, 2024 13:41
renovate bot added a commit to SebastianGoeb/chinese-chart that referenced this pull request Feb 12, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [vite-plugin-pwa](https://togithub.com/vite-pwa/vite-plugin-pwa) |
[`^0.17.4` ->
`^0.18.0`](https://renovatebot.com/diffs/npm/vite-plugin-pwa/0.17.5/0.18.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/vite-plugin-pwa/0.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/vite-plugin-pwa/0.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/vite-plugin-pwa/0.17.5/0.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/vite-plugin-pwa/0.17.5/0.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>vite-pwa/vite-plugin-pwa (vite-plugin-pwa)</summary>

###
[`v0.18.1`](https://togithub.com/vite-pwa/vite-plugin-pwa/releases/tag/v0.18.1)

[Compare
Source](https://togithub.com/vite-pwa/vite-plugin-pwa/compare/v0.18.0...v0.18.1)

#####    🐞 Bug Fixes

- Handle Vite's base properly in dev server  -  by
[@&#8203;userquin](https://togithub.com/userquin) in
[vite-pwa/vite-plugin-pwa#657
[<samp>(8cac9)</samp>](https://togithub.com/vite-pwa/vite-plugin-pwa/commit/8cac935)

#####     [View changes on
GitHub](https://togithub.com/vite-pwa/vite-plugin-pwa/compare/v0.18.0...v0.18.1)

###
[`v0.18.0`](https://togithub.com/vite-pwa/vite-plugin-pwa/releases/tag/v0.18.0)

[Compare
Source](https://togithub.com/vite-pwa/vite-plugin-pwa/compare/v0.17.5...v0.18.0)

#####    🚨 Breaking Changes

- New custom service worker build  -  by
[@&#8203;userquin](https://togithub.com/userquin) in
[vite-pwa/vite-plugin-pwa#629
[<samp>(865fd)</samp>](https://togithub.com/vite-pwa/vite-plugin-pwa/commit/865fdad)

#####    🐞 Bug Fixes

- Register client module and prompt  -  by
[@&#8203;userquin](https://togithub.com/userquin) in
[vite-pwa/vite-plugin-pwa#633
[<samp>(b3474)</samp>](https://togithub.com/vite-pwa/vite-plugin-pwa/commit/b347432)

#####     [View changes on
GitHub](https://togithub.com/vite-pwa/vite-plugin-pwa/compare/v0.17.5...v0.18.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/SebastianGoeb/chinese-chart).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants