Skip to content
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 packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"rollup-plugin-license": "^3.6.0",
"sass": "^1.92.1",
"sass-embedded": "^1.92.1",
"sirv": "^3.0.1",
"sirv": "^3.0.2",
"strip-literal": "^3.0.0",
"terser": "^5.44.0",
"tsconfck": "^3.1.6",
Expand Down
30 changes: 24 additions & 6 deletions patches/sirv@3.0.1.patch → patches/sirv@3.0.2.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/build.js b/build.js
index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0922ecb2d 100644
index 3734120d67745ff83b2df07fa5d0a40dcb92a69b..bd57f693ac2bd4555a12e7a5436fb9524789ef66 100644
--- a/build.js
+++ b/build.js
@@ -35,7 +35,7 @@ function viaCache(cache, uri, extns) {
Expand All @@ -11,15 +11,24 @@ index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0
let i=0, arr=toAssume(uri, extns);
let abs, stats, name, headers;
for (; i < arr.length; i++) {
@@ -43,6 +43,7 @@ function viaLocal(dir, isEtag, uri, extns) {
@@ -46,6 +46,7 @@ function viaLocal(dir, isEtag, uri, extns) {
if (abs.startsWith(dir) && fs.existsSync(abs)) {
stats = fs.statSync(abs);
if (stats.isDirectory()) continue;
+ if (shouldServe && !shouldServe(abs)) continue;
headers = toHeaders(name, stats, isEtag);
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
return { abs, stats, headers };
@@ -176,7 +177,7 @@ module.exports = function (dir, opts={}) {
@@ -164,7 +165,7 @@ module.exports = function (dir, opts={}) {
});
}

- let lookup = opts.dev ? viaLocal.bind(0, dir + sep, isEtag) : viaCache.bind(0, FILES);
+ let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep) ? dir : dir + sep, isEtag) : viaCache.bind(0, FILES);

return function (req, res, next) {
let extns = [''];
@@ -179,7 +180,7 @@ module.exports = function (dir, opts={}) {
catch (err) { /* malform uri */ }
}

Expand All @@ -29,7 +38,7 @@ index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0

if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
diff --git a/build.mjs b/build.mjs
index 3ad14d45630a8627b93842a04a96465120d3f223..8451277c015b56a7d2cb99aaee3a318d9c0893dd 100644
index 2f866d5216c951ec125f2044af070fa6b530e375..d5335bfbb16e23b57385c1a83226611e29c39093 100644
--- a/build.mjs
+++ b/build.mjs
@@ -35,7 +35,7 @@ function viaCache(cache, uri, extns) {
Expand All @@ -41,15 +50,24 @@ index 3ad14d45630a8627b93842a04a96465120d3f223..8451277c015b56a7d2cb99aaee3a318d
let i=0, arr=toAssume(uri, extns);
let abs, stats, name, headers;
for (; i < arr.length; i++) {
@@ -43,6 +43,7 @@ function viaLocal(dir, isEtag, uri, extns) {
@@ -46,6 +46,7 @@ function viaLocal(dir, isEtag, uri, extns) {
if (abs.startsWith(dir) && fs.existsSync(abs)) {
stats = fs.statSync(abs);
if (stats.isDirectory()) continue;
+ if (shouldServe && !shouldServe(abs)) continue;
headers = toHeaders(name, stats, isEtag);
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
return { abs, stats, headers };
@@ -176,7 +177,7 @@ export default function (dir, opts={}) {
@@ -164,7 +165,7 @@ export default function (dir, opts={}) {
});
}

- let lookup = opts.dev ? viaLocal.bind(0, dir + sep, isEtag) : viaCache.bind(0, FILES);
+ let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep) ? dir : dir + sep, isEtag) : viaCache.bind(0, FILES);

return function (req, res, next) {
let extns = [''];
@@ -179,7 +180,7 @@ export default function (dir, opts={}) {
catch (err) { /* malform uri */ }
}

Expand Down
2 changes: 1 addition & 1 deletion playground/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"preview": "vite preview"
},
"devDependencies": {
"sirv": "^3.0.1"
"sirv": "^3.0.2"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-conditions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"devDependencies": {
"express": "^5.1.0",
"sirv": "^3.0.1"
"sirv": "^3.0.2"
}
}
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dedupeInjectedDeps: false
overrides:
vite: 'workspace:*'
patchedDependencies:
"sirv@3.0.1": "patches/sirv@3.0.1.patch"
"sirv@3.0.2": "patches/sirv@3.0.2.patch"
"chokidar@3.6.0": "patches/chokidar@3.6.0.patch"
"dotenv-expand@12.0.3": "patches/dotenv-expand@12.0.3.patch"
peerDependencyRules:
Expand Down
Loading