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

fix: use tinyglobby #92

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineBuildConfig({
clean: true,
declaration: true,
externals: [
'fast-glob',
'tinyglobby',
'vite',
'vite-plugin-pwa',
'workbox-build',
Expand Down
3 changes: 2 additions & 1 deletion 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.6.5",
"packageManager": "pnpm@9.9.0",
"packageManager": "pnpm@9.12.2",
"description": "Zero-config PWA for SvelteKit",
"author": "antfu <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -61,6 +61,7 @@
}
},
"dependencies": {
"tinyglobby": "^0.2.9",
"kolorist": "^1.8.0"
},
"devDependencies": {
Expand Down
62 changes: 30 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions src/plugins/SvelteKitPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { lstat, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import type { Plugin, ResolvedConfig } from 'vite'
import type { VitePWAOptions, VitePluginPWAAPI } from 'vite-plugin-pwa'

// @ts-expect-error export = is not supported by @types/node
import fg from 'fast-glob'
import { glob } from 'tinyglobby'

export function SvelteKitPlugin(
options: Partial<VitePWAOptions>,
Expand Down Expand Up @@ -89,13 +87,12 @@ export function SvelteKitPlugin(
await rm(path)
}
// move also workbox-*.js when using generateSW
const result = await fg(
['workbox-*.js'], {
cwd: serverOutputDir,
onlyFiles: true,
unique: true,
},
)
const result = await glob({
patterns: ['workbox-*.js'],
cwd: serverOutputDir,
onlyFiles: true,
expandDirectories: false,
})
if (result && result.length > 0) {
path = join(serverOutputDir, result[0]).replace(/\\/g, '/')
await writeFile(
Expand Down