Skip to content

Replace the app's own PWA package with an all-in-one toolkit once one supports Bun #166

Closed

Description

@flixbox-ai-agent

Owner's wish: an all-in-one PWA toolkit instead of our own package.

Today packages/pwa (#157) combines favicons (icons, manifest, head tags) and Serwist (service worker, update prompt) behind one pwa-build step, because no single tool does all of it for Bun: vite-plugin-pwa is Vite-only, and its bundler-independent successor unplugin-pwa is not on npm and lists no Bun target (only Vite and Rolldown are marked ready).

Revisit when: unplugin-pwa (or another toolkit) publishes a release that supports Bun's bundler. Then: replace packages/pwa with it, keeping what the e2e check (#159) proves: installable, offline, update prompt.

Activity

  1. Flixbox commented on Oct 11, 2026

    @Flixbox
    Owner

    Would unplugin work via Bun.build({ plugins: [...] }) ?

  2. flixbox-ai-agent commented on Oct 11, 2026

    @flixbox-ai-agent
    ContributorAuthor

    In principle yes: unplugin itself supports Bun. A plugin built with it exposes a /bun entry that goes straight into Bun.build({ plugins: [...] }), and on Bun it gets buildStart, resolveId, load, transform, and since Bun 1.3 buildEnd and writeBundle (the unplugin guide has the table). writeBundle is the hook a PWA toolkit needs to write the service worker after the build.

    In practice not yet, for unplugin-pwa specifically:

    • nothing is published: every package in vite-pwa/unplugin-pwa is still 0.0.0, and there is no /bun entry;
    • the only bundler package is packages/vite, and the repository doesn't mention Bun anywhere;
    • putting the manifest and icon links into index.html uses Vite's transformIndexHtml, which unplugin has no portable equivalent for; on Bun that part would need its own code (as packages/pwa does with Bun's HTMLRewriter).

    So this issue stays open until unplugin-pwa publishes a release with a Bun entry. Asking for one is a conversation for that project's maintainers.

  3. flixbox-ai-agent commented on Oct 11, 2026

    @flixbox-ai-agent
    ContributorAuthor

    Re-evaluated with a fresh research pass (owner's request), as of 2026-10-11. Still no published all-in-one PWA toolkit for Bun's bundler; keep packages/pwa, keep this open.

    What changed:

    • unplugin-pwa reserved its npm names (@unplugin-pwa/core, vite, types, inspector, all 0.0.0 on 2026-10-03), but they are placeholders (module.exports = {}). The repo is very active (commits almost daily); its first release is vite-pwa/unplugin-pwa#4 ("v0.0.1", timetable to be announced), with open pre-release tasks in Connect Google Calendar: create, share and join the household calendar #5 (vite-pwa/unplugin-pwa#5). Its README lists Vite, Rolldown, Webpack/Rspack/Rsbuild (WIP); no Bun. It compiles the service worker through vite-pwa's own Workbox fork (@vite-pwa/workbox-build), which only has Vite and Rolldown builders.
    • vite-plugin-pwa 2.0.0 is still Vite-only; driving it from a Bun script would need a faked Vite config, Vite itself to compile the worker, and the transformIndexHtml and virtual: module parts rebuilt.
    • Serwist has no esbuild/Bun integration and no manifest/icon generation; @serwist/cli wraps the same injectManifest call packages/pwa already makes.
    • Bun plugins still have no counterpart to Vite's transformIndexHtml; oven-sh/bun#40259 still open.
    • Nothing else qualifies: @vite-pwa/assets-generator (icons only, lateral to favicons), pwa-asset-generator (Puppeteer + Chrome), @pwabuilder/cli (2024, starters only), no Bun/esbuild PWA plugin on npm.

    Reopen when one of these happens:

    1. @unplugin-pwa/core publishes a real release and a Bun target lands (an @unplugin-pwa/bun package or /bun export), or @vite-pwa/workbox-build gains a Bun/esbuild worker builder;
    2. Serwist ships a bundler-independent integration that also generates the manifest and icons;
    3. Bun adds an HTML-transform hook for plugins.

    Note for (1): adopting it would mean leaving Serwist for vite-pwa's Workbox fork, a trade-off to weigh then, not a free upgrade.

  4. flixbox-ai-agent commented on Oct 11, 2026

    @flixbox-ai-agent
    ContributorAuthor

    Addendum from the same re-evaluation: ways to make packages/pwa smaller while no toolkit exists (ideas, not decided):

    • Run it as a Bun plugin inside the build (Bun.build({ plugins: [pwa(config)] }), using Bun's onEnd hook) instead of a separate pwa-build step: same code, no new dependency, and the shape an unplugin-pwa Bun adapter would later replace. The HTMLRewriter step stays (Bun has no transformIndexHtml).
    • Drop @serwist/build: we only use it to fill in the precache list; Bun.Glob + Bun.hash + the existing define could do it in ~20 lines (plus our own duplicate-URL check, The offline app doesn't update, and the browser console shows errors on the live site #136). Optionally drop @serwist/window too (~30 lines of plain service-worker API).
    • Smaller icons: SVG icons with sizes="any" plus a few PNG fallbacks rendered by @resvg/resvg-wasm (no native binary) would replace favicons + sharp; we'd write the manifest and head tags ourselves. Only worth it if dropping sharp matters. realfavicon (pre-1.0) is the nearest alternative to favicons, and also injects the head tags.
    • Bundler question (Build the app with Bun instead of Vite #146): Vite 8 now bundles with Rolldown, so much of the speed argument for Bun's bundler is gone, and vite-plugin-pwa 2.0.0 works there today. Staying on Vite for bundling only (Bun remains package manager, runtime and test runner) would drop packages/pwa entirely, at the cost of the "Bun only" goal. Build the app with Bun instead of Vite #146 is blocked on oven-sh/bun#40259 anyway. This is the owner's call.
  5. userquin commented on Oct 12, 2026

    @userquin

    @unplugin-pwa/core is an abstraction to handle PWA configuration. We can build a Bun adapter on top of it, but we'll still use Rolldown to build the service worker.

    On the other hand, we could potentially add a native Bun builder to @vite-pwa/workbox-build. However, generating the service worker in an isolated production build is just half the battle. Integrating it seamlessly into Bun's lifecycle poses real challenges. As mentioned in this thread, Bun's plugin API currently lacks standard hooks for injecting assets into HTML (like Vite's transformIndexHtml), and resolving virtual modules requires significant custom logic.

    Alternatively, we can create a Bun plugin and use Rolldown under the hood, like we did for Webpack or Rspack/Rsbuild (check Webpack build plugin).

    Right now this deep integration is out of our initial scope, but we might explore support in the future as the Bun plugin ecosystem matures.

  6. flixbox-ai-agent commented on Oct 15, 2026

    @flixbox-ai-agent
    ContributorAuthor

    Thank you for the context, that matches what we found: a Bun adapter would still need Rolldown for the worker, and the missing HTML hook in Bun's plugin API (oven-sh/bun#40259) is the harder half. We keep our own packages/pwa for now and leave this open for when Bun's plugin hooks or a Bun target in vite-pwa/unplugin-pwa make it possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions