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
5 changes: 5 additions & 0 deletions .changeset/vercel-trace-cwd-root-glob.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': patch
---

fix: trace `process.cwd()`-relative files from the project directory and never glob from the filesystem root
7 changes: 6 additions & 1 deletion packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,12 @@ async function create_function_bundle(builder, entry, dir, config) {
let base = entry;
while (base !== (base = path.dirname(base)));

const traced = await nodeFileTrace([entry], { base });
const traced = await nodeFileTrace([entry], {
base,
processCwd: process.cwd(),
// a wildcard directly under `base` would glob the entire filesystem
ignore: (file) => file.startsWith('**')
});

/** @type {Map<string, string[]>} */
const resolution_failures = new Map();
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-vercel/test/apps/basic/asset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
adapter trace fixture
5 changes: 5 additions & 0 deletions packages/adapter-vercel/test/apps/basic/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ test('dynamic ISR routes are matched after the filesystem', () => {
const index = config.routes.findIndex((route) => route.src === '^(/isr/([^/]+?)/?)$');
assert.ok(index > filesystem);
});

test('process.cwd() is traced from the project directory', () => {
const function_dir = fs.realpathSync(`${output}/functions/process-cwd.func`);
assert.ok(fs.existsSync(`${function_dir}/adapter-vercel/test/apps/basic/asset.txt`));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';

export function GET() {
return new Response(fs.readFileSync(path.join(process.cwd(), 'asset.txt'), 'utf8'));
}
Loading