From 409fa5c9dee0e394bcdc3b111f5b2e4261131ca0 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sat, 26 Oct 2024 16:52:08 +0800 Subject: [PATCH] fix: handle warmup glob hang (#18462) --- packages/vite/package.json | 2 +- packages/vite/src/node/server/warmup.ts | 6 ++-- playground/backend-integration/package.json | 2 +- playground/css/package.json | 2 +- pnpm-lock.yaml | 34 ++++++++++++++------- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 6c6c31cac..19cc39285 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -148,7 +148,7 @@ "source-map-support": "^0.5.21", "strip-ansi": "^7.1.0", "strip-literal": "^2.1.0", - "tinyglobby": "^0.2.9", + "tinyglobby": "^0.2.10", "tsconfck": "^3.1.4", "tslib": "^2.8.0", "types": "link:./types", diff --git a/packages/vite/src/node/server/warmup.ts b/packages/vite/src/node/server/warmup.ts index 418b17eda..341d360ec 100644 --- a/packages/vite/src/node/server/warmup.ts +++ b/packages/vite/src/node/server/warmup.ts @@ -70,10 +70,12 @@ function fileToUrl(file: string, root: string) { return '/' + normalizePath(url) } -function mapFiles(files: string[], root: string) { - return glob(files, { +async function mapFiles(files: string[], root: string) { + if (!files.length) return [] + return await glob(files, { absolute: true, cwd: root, expandDirectories: false, + ignore: ['**/.git/**', '**/node_modules/**'], }) } diff --git a/playground/backend-integration/package.json b/playground/backend-integration/package.json index 3de1b7be9..a43c838d4 100644 --- a/playground/backend-integration/package.json +++ b/playground/backend-integration/package.json @@ -12,6 +12,6 @@ "devDependencies": { "sass": "^1.80.3", "tailwindcss": "^3.4.14", - "tinyglobby": "^0.2.9" + "tinyglobby": "^0.2.10" } } diff --git a/playground/css/package.json b/playground/css/package.json index 4523fa2b6..3593e5283 100644 --- a/playground/css/package.json +++ b/playground/css/package.json @@ -26,7 +26,7 @@ "sass": "^1.80.3", "stylus": "^0.64.0", "sugarss": "^4.0.1", - "tinyglobby": "^0.2.9" + "tinyglobby": "^0.2.10" }, "imports": { "#imports": "./imports-field.css" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c685b48a..c750eeffe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -406,8 +406,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 tinyglobby: - specifier: ^0.2.9 - version: 0.2.9 + specifier: ^0.2.10 + version: 0.2.10 tsconfck: specifier: ^3.1.4 version: 3.1.4(typescript@5.6.2) @@ -519,8 +519,8 @@ importers: specifier: ^3.4.14 version: 3.4.14(ts-node@10.9.2(@types/node@20.16.13)(typescript@5.6.2)) tinyglobby: - specifier: ^0.2.9 - version: 0.2.9 + specifier: ^0.2.10 + version: 0.2.10 playground/build-old: {} @@ -586,8 +586,8 @@ importers: specifier: ^4.0.1 version: 4.0.1(postcss@8.4.47) tinyglobby: - specifier: ^0.2.9 - version: 0.2.9 + specifier: ^0.2.10 + version: 0.2.10 playground/css-codesplit: {} @@ -4774,6 +4774,14 @@ packages: picomatch: optional: true + fdir@6.4.2: + resolution: {integrity: sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + feed@4.2.2: resolution: {integrity: sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==} engines: {node: '>=0.4.0'} @@ -6743,8 +6751,8 @@ packages: tinyexec@0.3.0: resolution: {integrity: sha512-tVGE0mVJPGb0chKhqmsoosjsS+qUnJVGJpZgsHYQcGoPlG3B51R3PouqTgEGH2Dc9jjFyOqOpix6ZHNMXp1FZg==} - tinyglobby@0.2.9: - resolution: {integrity: sha512-8or1+BGEdk1Zkkw2ii16qSS7uVrQJPre5A9o/XkWPATkk23FZh/15BKFxPnlTy6vkljZxLqYCzzBMj30ZrSvjw==} + tinyglobby@0.2.10: + resolution: {integrity: sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==} engines: {node: '>=12.0.0'} tinypool@1.0.0: @@ -8530,7 +8538,7 @@ snapshots: astring: 1.8.6 estree-walker: 2.0.2 magic-string: 0.30.12 - tinyglobby: 0.2.9 + tinyglobby: 0.2.10 optionalDependencies: rollup: 4.23.0 @@ -10400,6 +10408,10 @@ snapshots: optionalDependencies: picomatch: 4.0.2 + fdir@6.4.2(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + feed@4.2.2: dependencies: xml-js: 1.6.11 @@ -12517,9 +12529,9 @@ snapshots: tinyexec@0.3.0: {} - tinyglobby@0.2.9: + tinyglobby@0.2.10: dependencies: - fdir: 6.4.0(picomatch@4.0.2) + fdir: 6.4.2(picomatch@4.0.2) picomatch: 4.0.2 tinypool@1.0.0: {}