From 273f71f2605c417865a49e4c913c771ff26f7661 Mon Sep 17 00:00:00 2001 From: userquin Date: Sat, 19 Oct 2024 02:04:45 +0200 Subject: [PATCH] fix: use `tinyglobby` --- build.config.ts | 2 +- package.json | 3 +- pnpm-lock.yaml | 62 ++++++++++++++++------------------ src/plugins/SvelteKitPlugin.ts | 17 ++++------ 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/build.config.ts b/build.config.ts index bfecf98..417d1c0 100644 --- a/build.config.ts +++ b/build.config.ts @@ -7,7 +7,7 @@ export default defineBuildConfig({ clean: true, declaration: true, externals: [ - 'fast-glob', + 'tinyglobby', 'vite', 'vite-plugin-pwa', 'workbox-build', diff --git a/package.json b/package.json index 9cd92b7..0ed0618 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", @@ -61,6 +61,7 @@ } }, "dependencies": { + "tinyglobby": "^0.2.9", "kolorist": "^1.8.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7b5f73a..556d3fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: kolorist: specifier: ^1.8.0 version: 1.8.0 + tinyglobby: + specifier: ^0.2.9 + version: 0.2.9 devDependencies: '@antfu/eslint-config': specifier: ^0.43.1 @@ -1083,6 +1086,7 @@ packages: '@humanwhocodes/config-array@0.11.14': resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} + deprecated: Use @eslint/config-array instead '@humanwhocodes/module-importer@1.0.1': resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} @@ -1090,6 +1094,7 @@ packages: '@humanwhocodes/object-schema@2.0.3': resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} + deprecated: Use @eslint/object-schema instead '@jridgewell/gen-mapping@0.3.5': resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} @@ -1890,15 +1895,6 @@ packages: supports-color: optional: true - debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - debug@4.3.6: resolution: {integrity: sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==} engines: {node: '>=6.0'} @@ -2218,6 +2214,7 @@ packages: eslint@8.57.0: resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true esm-env@1.0.0: @@ -2283,8 +2280,8 @@ packages: fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} - fdir@6.3.0: - resolution: {integrity: sha512-QOnuT+BOtivR77wYvCWHfGt9s4Pz1VIMbD463vegT5MLqNXy8rYFT/lPVEqf/bhYeT6qmqrNHhsX+rWwe3rOCQ==} + fdir@6.4.2: + resolution: {integrity: sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==} peerDependencies: picomatch: ^3 || ^4 peerDependenciesMeta: @@ -2403,10 +2400,12 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} + deprecated: Glob versions prior to v9 are no longer supported globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} @@ -2520,6 +2519,7 @@ packages: inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -3414,10 +3414,12 @@ packages: rimraf@2.7.1: resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true rollup-plugin-dts@6.1.0: @@ -3775,8 +3777,8 @@ packages: tinybench@2.8.0: resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} - tinyglobby@0.2.5: - resolution: {integrity: sha512-Dlqgt6h0QkoHttG53/WGADNh9QhcjCAIZMTERAVhdpmIBEejSuLI9ZmGKWzB7tweBjlk30+s/ofi4SLmBeTYhw==} + tinyglobby@0.2.9: + resolution: {integrity: sha512-8or1+BGEdk1Zkkw2ii16qSS7uVrQJPre5A9o/XkWPATkk23FZh/15BKFxPnlTy6vkljZxLqYCzzBMj30ZrSvjw==} engines: {node: '>=12.0.0'} tinypool@1.0.1: @@ -4260,7 +4262,7 @@ snapshots: '@babel/traverse': 7.24.5 '@babel/types': 7.24.5 convert-source-map: 2.0.0 - debug: 4.3.4 + debug: 4.3.6 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -5107,7 +5109,7 @@ snapshots: '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.6 espree: 9.6.1 globals: 13.24.0 ignore: 5.3.1 @@ -5125,7 +5127,7 @@ snapshots: '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.4 + debug: 4.3.6 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -5488,7 +5490,7 @@ snapshots: '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 @@ -5506,7 +5508,7 @@ snapshots: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.5) '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 optionalDependencies: typescript: 5.4.5 @@ -5527,7 +5529,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.5) '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: @@ -5557,7 +5559,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.6 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -6100,10 +6102,6 @@ snapshots: dependencies: ms: 2.1.3 - debug@4.3.4: - dependencies: - ms: 2.1.2 - debug@4.3.6: dependencies: ms: 2.1.2 @@ -6468,7 +6466,7 @@ snapshots: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@jridgewell/sourcemap-codec': 1.4.15 - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 eslint-compat-utils: 0.5.0(eslint@8.57.0) esutils: 2.0.3 @@ -6527,7 +6525,7 @@ snapshots: eslint-plugin-yml@1.14.0(eslint@8.57.0): dependencies: - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 eslint-compat-utils: 0.5.0(eslint@8.57.0) lodash: 4.17.21 @@ -6563,7 +6561,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.6 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -6657,7 +6655,7 @@ snapshots: dependencies: reusify: 1.0.4 - fdir@6.3.0(picomatch@4.0.2): + fdir@6.4.2(picomatch@4.0.2): optionalDependencies: picomatch: 4.0.2 @@ -8171,9 +8169,9 @@ snapshots: tinybench@2.8.0: {} - tinyglobby@0.2.5: + tinyglobby@0.2.9: dependencies: - fdir: 6.3.0(picomatch@4.0.2) + fdir: 6.4.2(picomatch@4.0.2) picomatch: 4.0.2 tinypool@1.0.1: {} @@ -8386,7 +8384,7 @@ snapshots: dependencies: debug: 4.3.6 pretty-bytes: 6.1.1 - tinyglobby: 0.2.5 + tinyglobby: 0.2.9 vite: 5.2.10(@types/node@18.19.31)(terser@5.31.0) workbox-build: 7.1.0 workbox-window: 7.1.0 @@ -8443,7 +8441,7 @@ snapshots: vue-eslint-parser@9.4.2(eslint@8.57.0): dependencies: - debug: 4.3.4 + debug: 4.3.6 eslint: 8.57.0 eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 diff --git a/src/plugins/SvelteKitPlugin.ts b/src/plugins/SvelteKitPlugin.ts index a9bcfa5..db04df6 100644 --- a/src/plugins/SvelteKitPlugin.ts +++ b/src/plugins/SvelteKitPlugin.ts @@ -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, @@ -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(