Skip to content

Commit

Permalink
feat: add Vite 5 support (#73)
Browse files Browse the repository at this point in the history
* feat: add Vite 5 support

* chore: cleanup
  • Loading branch information
userquin authored Dec 6, 2023
1 parent 96d5e47 commit df821e5
Show file tree
Hide file tree
Showing 8 changed files with 584 additions and 308 deletions.
1 change: 0 additions & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default defineBuildConfig({
declaration: true,
externals: [
'fast-glob',
'kolorist',
'vite',
'vite-plugin-pwa',
'workbox-build',
Expand Down
7 changes: 7 additions & 0 deletions examples/sveltekit-ts/client-test/sw.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {test, expect} from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import {generateSW} from "../pwa.mjs";

test('The service worker is registered and cache storage is present', async ({ page}) => {
Expand All @@ -11,6 +13,7 @@ test('The service worker is registered and cache storage is present', async ({ p
navigator.serviceWorker.ready,
new Promise((_, reject) => setTimeout(() => reject(new Error('Service worker registration failed: time out')), 10000))
])
// @ts-expect-error registration is of type unknown
return registration.active?.scriptURL
});
const swName = generateSW ? 'sw.js' : 'prompt-sw.js'
Expand Down Expand Up @@ -41,4 +44,8 @@ test('The service worker is registered and cache storage is present', async ({ p
expect(urls.some(url => url.startsWith('manifest.webmanifest?__WB_REVISION__='))).toEqual(true)
expect(urls.some(url => url.startsWith('?__WB_REVISION__='))).toEqual(true)
expect(urls.some(url => url.startsWith('about?__WB_REVISION__='))).toEqual(true)
// dontCacheBustURLsMatching: any asset in _app/immutable folder shouldn't have a revision (?__WB_REVISION__=)
expect(urls.some(url => url.startsWith('_app/immutable/') && url.endsWith('.css'))).toEqual(true)
expect(urls.some(url => url.startsWith('_app/immutable/') && url.endsWith('.js'))).toEqual(true)
// expect(urls.some(url => url.includes('_app/version.json?__WB_REVISION__='))).toEqual(true)
});
4 changes: 2 additions & 2 deletions examples/sveltekit-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.24.1",
"@types/cookie": "^0.5.2",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@vite-pwa/sveltekit": "workspace:*",
"eslint": "^8.49.0",
"eslint-plugin-svelte": "^2.34.0",
Expand Down
4 changes: 4 additions & 0 deletions examples/sveltekit-ts/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest'
import { existsSync, readFileSync } from 'node:fs'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { generateSW } from '../pwa.mjs'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { nodeAdapter } from '../adapter.mjs'

describe(`test-build: ${nodeAdapter ? 'node' : 'static'} adapter`, () => {
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@vite-pwa/sveltekit",
"type": "module",
"version": "0.2.8",
"packageManager": "pnpm@8.10.3",
"packageManager": "pnpm@8.11.0",
"description": "Zero-config PWA for SvelteKit",
"author": "antfu <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -51,21 +51,23 @@
},
"peerDependencies": {
"@sveltejs/kit": "^1.3.1",
"vite-plugin-pwa": ">=0.16.5 <1"
"vite-plugin-pwa": ">=0.16.7 <1"
},
"dependencies": {
"kolorist": "^1.8.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.41.0",
"@antfu/ni": "^0.21.8",
"@antfu/eslint-config": "^0.43.1",
"@antfu/ni": "^0.21.12",
"@types/debug": "^4.1.8",
"@types/node": "^18.17.15",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@vite-pwa/sveltekit": "workspace:*",
"bumpp": "^9.2.0",
"eslint": "^8.49.0",
"kolorist": "^1.8.0",
"typescript": "^5.2.2",
"eslint": "^8.55.0",
"typescript": "^5.3.3",
"unbuild": "^2.0.0",
"vite": "^4.4.9",
"vite-plugin-pwa": ">=0.16.5 <1"
"vite": "^4.5.1",
"vite-plugin-pwa": ">=0.16.7 <1"
}
}
Loading

0 comments on commit df821e5

Please sign in to comment.