diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8aa0069a..aab5b526 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ The `vite-plugin-pwa` repo includes a set of examples where you can test the cha - `pnpm run examples`: select `sveltekit` framework and default options on the cli (you can also test another options) - `pnpm run examples`: select `solid` framework and default options on the cli (you can also test another options) -> The default options from the `cli` are just to check your changes are not breaking major ui/app frameworks build: `generateSW` strategy, `Prompt for update` behavior and `Enable periodic SW updates` to `no`. +> The default options from the `cli` are just to check your changes are not breaking major ui/app frameworks build: `generateSW` strategy, `Prompt for update` behavior and `Enable periodic SW updates` to `no`. > If your changes are specific to some behavior, just use the corresponding option on the `cli`. diff --git a/README.md b/README.md index 91138625..a8673dba 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ Zero-config PWA Framework-agnostic Plugin for Vite

- ## 🚀 Features - 📖 [**Documentation & guides**](https://vite-pwa-org.netlify.app/) @@ -53,12 +52,12 @@ Zero-config PWA Framework-agnostic Plugin for Vite > From v0.13, `vite-plugin-pwa` requires **Vite 3.1 or above**. ```bash -npm i vite-plugin-pwa -D +npm i vite-plugin-pwa -D -# yarn +# yarn yarn add vite-plugin-pwa -D -# pnpm +# pnpm pnpm add vite-plugin-pwa -D ``` @@ -77,8 +76,7 @@ export default { } ``` -Read the [📖 documentation](https://vite-pwa-org.netlify.app/guide/) for a complete guide on how to configure and use -this plugin. +Read the [📖 documentation](https://vite-pwa-org.netlify.app/guide/) for a complete guide on how to configure and use this plugin. Check out the client type declarations [client.d.ts](./client.d.ts) for built-in frameworks support. @@ -89,7 +87,6 @@ Check out the type declaration [src/types.ts](./src/types.ts) and the following - [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest) - [Workbox](https://developers.google.com/web/tools/workbox) - ## 📄 License [MIT](./LICENSE) License © 2020-PRESENT [Anthony Fu](https://github.com/antfu) diff --git a/eslint.config.js b/eslint.config.js index 0633cf35..7598d06c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,8 +3,10 @@ import antfu from '@antfu/eslint-config' export default await antfu( { ignores: [ + 'netlify.toml', '**/build/**', '**/dist/**', + '**/docs/**', '**/dev-dist/**', ], }, diff --git a/examples/assets-generator/src/pwa.ts b/examples/assets-generator/src/pwa.ts index 1afc1ec5..682a360a 100644 --- a/examples/assets-generator/src/pwa.ts +++ b/examples/assets-generator/src/pwa.ts @@ -1,6 +1,6 @@ -import { pwaInfo } from 'virtual:pwa-info' import { pwaAssetsHead } from 'virtual:pwa-assets/head' import { pwaAssetsIcons } from 'virtual:pwa-assets/icons' +import { pwaInfo } from 'virtual:pwa-info' import { registerSW } from 'virtual:pwa-register' console.log(pwaInfo) diff --git a/examples/assets-generator/vite.config.ts b/examples/assets-generator/vite.config.ts index 7a363d5c..7f5089d5 100644 --- a/examples/assets-generator/vite.config.ts +++ b/examples/assets-generator/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import type { PWAAssetsOptions } from 'vite-plugin-pwa' +import { defineConfig } from 'vite' import { VitePWA } from 'vite-plugin-pwa' const pwaAssets: PWAAssetsOptions = process.env.INLINE_PWA_ASSETS diff --git a/examples/preact-router/src/ReloadPrompt.tsx b/examples/preact-router/src/ReloadPrompt.tsx index af2d7beb..d7c71af4 100644 --- a/examples/preact-router/src/ReloadPrompt.tsx +++ b/examples/preact-router/src/ReloadPrompt.tsx @@ -1,7 +1,7 @@ -import './ReloadPrompt.css' +import { pwaInfo } from 'virtual:pwa-info' import { useRegisterSW } from 'virtual:pwa-register/preact' -import { pwaInfo } from 'virtual:pwa-info' +import './ReloadPrompt.css' console.log(pwaInfo) diff --git a/examples/preact-router/src/app.tsx b/examples/preact-router/src/app.tsx index a71c2b7b..a99dd1ea 100644 --- a/examples/preact-router/src/app.tsx +++ b/examples/preact-router/src/app.tsx @@ -1,9 +1,9 @@ import { Router } from 'preact-router' -import ReloadPrompt from './ReloadPrompt' -import Home from './pages/Home' import About from './pages/About' import Hi from './pages/hi/[name]' +import Home from './pages/Home' +import ReloadPrompt from './ReloadPrompt' import './App.css' diff --git a/examples/preact-router/src/claims-sw.ts b/examples/preact-router/src/claims-sw.ts index 32a2f72f..66a1aea7 100644 --- a/examples/preact-router/src/claims-sw.ts +++ b/examples/preact-router/src/claims-sw.ts @@ -1,5 +1,5 @@ -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' declare let self: ServiceWorkerGlobalScope diff --git a/examples/preact-router/src/pages/Home.tsx b/examples/preact-router/src/pages/Home.tsx index 5fe5002d..b97403d3 100644 --- a/examples/preact-router/src/pages/Home.tsx +++ b/examples/preact-router/src/pages/Home.tsx @@ -1,5 +1,5 @@ -import { useState } from 'preact/hooks' import { route } from 'preact-router' +import { useState } from 'preact/hooks' import './Home.css' function Home() { diff --git a/examples/preact-router/test/build.test.ts b/examples/preact-router/test/build.test.ts index c0b0c28b..0384f55f 100644 --- a/examples/preact-router/test/build.test.ts +++ b/examples/preact-router/test/build.test.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import process from 'node:process' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' @@ -32,13 +32,13 @@ describe('preact: test-build', () => { const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`) expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy() const workboxContent = readFileSync(workboxName, 'utf-8') - match = workboxContent.match(/self\['workbox:core:[0-9.]+']/) + match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() } else { - match = swContent.match(/self\['workbox:core:[0-9.]+']/) + match = swContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() diff --git a/examples/preact-router/vite.config.ts b/examples/preact-router/vite.config.ts index 895e8979..872c8957 100644 --- a/examples/preact-router/vite.config.ts +++ b/examples/preact-router/vite.config.ts @@ -1,9 +1,9 @@ +import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' import process from 'node:process' -import { defineConfig } from 'vite' import preact from '@preact/preset-vite' -import { VitePWA } from 'vite-plugin-pwa' -import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' import replace from '@rollup/plugin-replace' +import { defineConfig } from 'vite' +import { VitePWA } from 'vite-plugin-pwa' const pwaOptions: Partial = { mode: 'development', diff --git a/examples/react-router/src/ReloadPrompt.tsx b/examples/react-router/src/ReloadPrompt.tsx index 1eaaf2b1..50bf4031 100644 --- a/examples/react-router/src/ReloadPrompt.tsx +++ b/examples/react-router/src/ReloadPrompt.tsx @@ -1,8 +1,8 @@ import React from 'react' -import './ReloadPrompt.css' +import { pwaInfo } from 'virtual:pwa-info' import { useRegisterSW } from 'virtual:pwa-register/react' -import { pwaInfo } from 'virtual:pwa-info' +import './ReloadPrompt.css' console.log(pwaInfo) diff --git a/examples/react-router/src/claims-sw.ts b/examples/react-router/src/claims-sw.ts index 32a2f72f..66a1aea7 100644 --- a/examples/react-router/src/claims-sw.ts +++ b/examples/react-router/src/claims-sw.ts @@ -1,5 +1,5 @@ -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' declare let self: ServiceWorkerGlobalScope diff --git a/examples/react-router/src/main.tsx b/examples/react-router/src/main.tsx index 0364b716..86f760ee 100644 --- a/examples/react-router/src/main.tsx +++ b/examples/react-router/src/main.tsx @@ -1,11 +1,11 @@ import React from 'react' -import { BrowserRouter, Route, Routes } from 'react-router-dom' import { createRoot } from 'react-dom/client' -import './index.css' +import { BrowserRouter, Route, Routes } from 'react-router-dom' import App from './App' -import Home from './pages/Home' import About from './pages/About' import Hi from './pages/hi/[name]' +import Home from './pages/Home' +import './index.css' createRoot(document.getElementById('app')!).render( diff --git a/examples/react-router/test/build.test.ts b/examples/react-router/test/build.test.ts index 6bfc4a46..9bcb634c 100644 --- a/examples/react-router/test/build.test.ts +++ b/examples/react-router/test/build.test.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import process from 'node:process' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' const _dirname = typeof __dirname !== 'undefined' @@ -31,13 +31,13 @@ describe('react: test-build', () => { const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`) expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy() const workboxContent = readFileSync(workboxName, 'utf-8') - match = workboxContent.match(/self\['workbox:core:[0-9.]+']/) + match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() } else { - match = swContent.match(/self\['workbox:core:[0-9.]+']/) + match = swContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() diff --git a/examples/react-router/vite.config.ts b/examples/react-router/vite.config.ts index 7fbd0dfe..b7d7a2d4 100644 --- a/examples/react-router/vite.config.ts +++ b/examples/react-router/vite.config.ts @@ -1,9 +1,9 @@ +import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' import process from 'node:process' -import { defineConfig } from 'vite' +import replace from '@rollup/plugin-replace' import react from '@vitejs/plugin-react' -import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' +import { defineConfig } from 'vite' import { VitePWA } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' const pwaOptions: Partial = { mode: 'development', diff --git a/examples/solid-router/src/ReloadPrompt.tsx b/examples/solid-router/src/ReloadPrompt.tsx index 6ff9fcea..d4611da7 100644 --- a/examples/solid-router/src/ReloadPrompt.tsx +++ b/examples/solid-router/src/ReloadPrompt.tsx @@ -1,7 +1,7 @@ import type { Component } from 'solid-js' import { Show } from 'solid-js' -import { useRegisterSW } from 'virtual:pwa-register/solid' import { pwaInfo } from 'virtual:pwa-info' +import { useRegisterSW } from 'virtual:pwa-register/solid' import styles from './ReloadPrompt.module.css' console.log(pwaInfo) diff --git a/examples/solid-router/src/app.tsx b/examples/solid-router/src/app.tsx index aeecb3f1..68369466 100644 --- a/examples/solid-router/src/app.tsx +++ b/examples/solid-router/src/app.tsx @@ -1,8 +1,8 @@ import type { Component } from 'solid-js' import { useRoutes } from '@solidjs/router' -import { routes } from './routes' import styles from './app.module.css' import ReloadPrompt from './ReloadPrompt' +import { routes } from './routes' const App: Component = () => { // replaced dynamically diff --git a/examples/solid-router/src/claims-sw.ts b/examples/solid-router/src/claims-sw.ts index 32a2f72f..66a1aea7 100644 --- a/examples/solid-router/src/claims-sw.ts +++ b/examples/solid-router/src/claims-sw.ts @@ -1,5 +1,5 @@ -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' declare let self: ServiceWorkerGlobalScope diff --git a/examples/solid-router/src/index.tsx b/examples/solid-router/src/index.tsx index 8141e7e4..3a99d6b0 100644 --- a/examples/solid-router/src/index.tsx +++ b/examples/solid-router/src/index.tsx @@ -1,5 +1,5 @@ -import { render } from 'solid-js/web' import { Router } from '@solidjs/router' +import { render } from 'solid-js/web' import App from './app' render( diff --git a/examples/solid-router/src/pages/home.tsx b/examples/solid-router/src/pages/home.tsx index 1e41d728..ab50ec1d 100644 --- a/examples/solid-router/src/pages/home.tsx +++ b/examples/solid-router/src/pages/home.tsx @@ -1,5 +1,5 @@ -import { createSignal } from 'solid-js' import { useNavigate } from '@solidjs/router' +import { createSignal } from 'solid-js' import styles from './home.module.css' export default function Home() { diff --git a/examples/solid-router/src/routes.ts b/examples/solid-router/src/routes.ts index a819677e..04a45f71 100644 --- a/examples/solid-router/src/routes.ts +++ b/examples/solid-router/src/routes.ts @@ -1,8 +1,8 @@ -import { lazy } from 'solid-js' import type { RouteDefinition } from '@solidjs/router' +import { lazy } from 'solid-js' -import Home from './pages/home' import HiData from './pages/hi/[name].data' +import Home from './pages/home' export const routes: RouteDefinition[] = [ { diff --git a/examples/solid-router/test/build.test.ts b/examples/solid-router/test/build.test.ts index 979ff7d6..acf1664e 100644 --- a/examples/solid-router/test/build.test.ts +++ b/examples/solid-router/test/build.test.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import process from 'node:process' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' const _dirname = typeof __dirname !== 'undefined' @@ -31,13 +31,13 @@ describe('solid: test-build', () => { const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`) expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy() const workboxContent = readFileSync(workboxName, 'utf-8') - match = workboxContent.match(/self\['workbox:core:[0-9.]+']/) + match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() } else { - match = swContent.match(/self\['workbox:core:[0-9.]+']/) + match = swContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() diff --git a/examples/solid-router/vite.config.ts b/examples/solid-router/vite.config.ts index 157e59c9..7d01874b 100644 --- a/examples/solid-router/vite.config.ts +++ b/examples/solid-router/vite.config.ts @@ -1,9 +1,9 @@ +import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' import process from 'node:process' +import replace from '@rollup/plugin-replace' import { defineConfig } from 'vite' -import solidPlugin from 'vite-plugin-solid' import { VitePWA } from 'vite-plugin-pwa' -import type { ManifestOptions, VitePWAOptions } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' +import solidPlugin from 'vite-plugin-solid' const pwaOptions: Partial = { mode: 'development', diff --git a/examples/svelte-routify/src/claims-sw.ts b/examples/svelte-routify/src/claims-sw.ts index 32a2f72f..66a1aea7 100644 --- a/examples/svelte-routify/src/claims-sw.ts +++ b/examples/svelte-routify/src/claims-sw.ts @@ -1,5 +1,5 @@ -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' declare let self: ServiceWorkerGlobalScope diff --git a/examples/svelte-routify/test/build.test.ts b/examples/svelte-routify/test/build.test.ts index 0cb48e34..8bce73a3 100644 --- a/examples/svelte-routify/test/build.test.ts +++ b/examples/svelte-routify/test/build.test.ts @@ -32,13 +32,13 @@ describe('svelte: test-build', () => { const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`) expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy() const workboxContent = readFileSync(workboxName, 'utf-8') - match = workboxContent.match(/self\['workbox:core:[0-9.]+']/) + match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() } else { - match = swContent.match(/self\['workbox:core:[0-9.]+']/) + match = swContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() diff --git a/examples/svelte-routify/vite.config.js b/examples/svelte-routify/vite.config.js index 81d6d92d..f7ebbbc6 100644 --- a/examples/svelte-routify/vite.config.js +++ b/examples/svelte-routify/vite.config.js @@ -1,8 +1,8 @@ import process from 'node:process' -import { defineConfig } from 'vite' +import replace from '@rollup/plugin-replace' import { svelte } from '@sveltejs/vite-plugin-svelte' +import { defineConfig } from 'vite' import { VitePWA } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' /** @type { Partial } */ const pwaOptions = { diff --git a/examples/sveltekit-pwa/pwa.js b/examples/sveltekit-pwa/pwa.js index 2518d06e..fe260127 100644 --- a/examples/sveltekit-pwa/pwa.js +++ b/examples/sveltekit-pwa/pwa.js @@ -1,8 +1,8 @@ import { copyFileSync } from 'node:fs' -import { resolveConfig } from 'vite' import replace from '@rollup/plugin-replace' -import { VitePWA } from 'vite-plugin-pwa' import minimist from 'minimist' +import { resolveConfig } from 'vite' +import { VitePWA } from 'vite-plugin-pwa' const args = minimist(process.argv.slice(2)) diff --git a/examples/sveltekit-pwa/src/claims-sw.ts b/examples/sveltekit-pwa/src/claims-sw.ts index 32a2f72f..66a1aea7 100644 --- a/examples/sveltekit-pwa/src/claims-sw.ts +++ b/examples/sveltekit-pwa/src/claims-sw.ts @@ -1,5 +1,5 @@ -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' declare let self: ServiceWorkerGlobalScope diff --git a/examples/sveltekit-pwa/svelte.config.js b/examples/sveltekit-pwa/svelte.config.js index b5a99a60..55870d02 100644 --- a/examples/sveltekit-pwa/svelte.config.js +++ b/examples/sveltekit-pwa/svelte.config.js @@ -1,7 +1,7 @@ +import replace from '@rollup/plugin-replace' import adapter from '@sveltejs/adapter-static' import preprocess from 'svelte-preprocess' import { VitePWA } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' import { pwaConfiguration, replaceOptions } from './pwa-configuration.js' /** @type {import('@sveltejs/kit').Config} */ diff --git a/examples/vanilla-js-custom-sw/service-worker/sw.js b/examples/vanilla-js-custom-sw/service-worker/sw.js index 2cfabb67..e0504850 100644 --- a/examples/vanilla-js-custom-sw/service-worker/sw.js +++ b/examples/vanilla-js-custom-sw/service-worker/sw.js @@ -1,6 +1,6 @@ /// -import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { clientsClaim } from 'workbox-core' +import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching' import { NavigationRoute, registerRoute } from 'workbox-routing' // self.__WB_MANIFEST is default injection point diff --git a/examples/vanilla-js-custom-sw/src/main.js b/examples/vanilla-js-custom-sw/src/main.js index 11c50d02..493e508b 100644 --- a/examples/vanilla-js-custom-sw/src/main.js +++ b/examples/vanilla-js-custom-sw/src/main.js @@ -1,6 +1,7 @@ import { pwaInfo } from 'virtual:pwa-info' import { registerSW } from 'virtual:pwa-register' +// eslint-disable-next-line no-undef const date = __DATE__ console.log(pwaInfo) diff --git a/examples/vanilla-ts-no-ip/client-test/sw.spec.ts b/examples/vanilla-ts-no-ip/client-test/sw.spec.ts index 678adc69..c98ea4e8 100644 --- a/examples/vanilla-ts-no-ip/client-test/sw.spec.ts +++ b/examples/vanilla-ts-no-ip/client-test/sw.spec.ts @@ -1,5 +1,5 @@ -import process from 'node:process' import type { Page } from '@playwright/test' +import process from 'node:process' import { expect, test } from '@playwright/test' const customSW = process.env.SW === 'true' diff --git a/examples/vanilla-ts-no-ip/src/custom-sw.ts b/examples/vanilla-ts-no-ip/src/custom-sw.ts index 0b86c8f0..ec95036e 100644 --- a/examples/vanilla-ts-no-ip/src/custom-sw.ts +++ b/examples/vanilla-ts-no-ip/src/custom-sw.ts @@ -1,9 +1,9 @@ +import orderBy from 'lodash-es/orderBy.js' +import { CacheableResponsePlugin } from 'workbox-cacheable-response' import { clientsClaim } from 'workbox-core' +import { ExpirationPlugin } from 'workbox-expiration' import { registerRoute } from 'workbox-routing' import { CacheFirst, NetworkFirst, StaleWhileRevalidate } from 'workbox-strategies' -import { CacheableResponsePlugin } from 'workbox-cacheable-response' -import { ExpirationPlugin } from 'workbox-expiration' -import orderBy from 'lodash-es/orderBy.js' console.log(orderBy) diff --git a/examples/vanilla-ts-no-ip/test/build.test.ts b/examples/vanilla-ts-no-ip/test/build.test.ts index 4020e4fe..57ee16d4 100644 --- a/examples/vanilla-ts-no-ip/test/build.test.ts +++ b/examples/vanilla-ts-no-ip/test/build.test.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import process from 'node:process' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' const _dirname = typeof __dirname !== 'undefined' @@ -50,13 +50,13 @@ describe('typescript (no injection point): test-build', () => { const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`) expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy() const workboxContent = readFileSync(workboxName, 'utf-8') - match = workboxContent.match(/self\['workbox:core:[0-9.]+']/) + match = workboxContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() } else { - match = swContent.match(/self\['workbox:core:[0-9.]+']/) + match = swContent.match(/self\['workbox:core:[0-9.]+'\]/) expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy() match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/) expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy() diff --git a/examples/vue-basic-cdn/vite.config.ts b/examples/vue-basic-cdn/vite.config.ts index eb00ab77..5ddb95e1 100644 --- a/examples/vue-basic-cdn/vite.config.ts +++ b/examples/vue-basic-cdn/vite.config.ts @@ -1,8 +1,8 @@ -import process from 'node:process' import type { UserConfig } from 'vite' +import process from 'node:process' +import replace from '@rollup/plugin-replace' import Vue from '@vitejs/plugin-vue' import { VitePWA } from 'vite-plugin-pwa' -import replace from '@rollup/plugin-replace' const config: UserConfig = { base: 'https://cdn.com/', diff --git a/examples/vue-router/src/App.vue b/examples/vue-router/src/App.vue index 4844da41..b0cae374 100644 --- a/examples/vue-router/src/App.vue +++ b/examples/vue-router/src/App.vue @@ -1,6 +1,6 @@