Skip to content

Title: @PWA generates sw.ts with workbox imports but doesn't add workbox dependencies to package.json #23772

@NicoDevX

Description

@NicoDevX

Description of the bug

Description:

When using the @pwa annotation, Vaadin generates a target/sw.ts file that imports from four workbox packages:

import { clientsClaim, cacheNames, WorkboxPlugin } from 'workbox-core';
import { matchPrecache, precacheAndRoute, getCacheKeyForURL } from 'workbox-precaching';
import { NavigationRoute, registerRoute } from 'workbox-routing';
import { NetworkOnly, NetworkFirst } from 'workbox-strategies';

However, these packages are not automatically added to the dependencies section of package.json. This causes the Vite production build (vaadin:build-frontend) to fail:

[vite]: Rollup failed to resolve import "workbox-core" from "target/sw.ts"
[vite]: Rollup failed to resolve import "workbox-precaching" from "target/sw.ts"

Note: workbox-build is added to devDependencies, but workbox-core, workbox-precaching, workbox-routing, and workbox-strategies are missing.

Expected behavior

Vaadin should automatically add the required workbox runtime dependencies to package.json when @pwa is used.

Minimal reproducible example

Workaround:

Manually add the missing dependencies to package.json:

"workbox-core": "7.4.0",
"workbox-precaching": "7.4.0",
"workbox-routing": "7.4.0",
"workbox-strategies": "7.4.0"

Versions

Vaadin version: 25.0.4, Vite 7.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    🆕 Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions