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

Provide better ignores for Vercel's file tracer #9885

Merged
merged 2 commits into from
Jan 31, 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
12 changes: 12 additions & 0 deletions .changeset/poor-tips-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@astrojs/vercel": patch
---

Better ignores for Vercel file-tracer

The Vercel adapter has a file-tracer it uses to detect which files should be moved over to the dist folder. When its done it prints warnings for things that it detected that maybe should be moved.

This change expands how we do ignores so that:

- Ignores happen within dot folders like `.pnpm`.
- `@libsql/client` is ignored, a package we know is not bundled.
1 change: 1 addition & 0 deletions packages/integrations/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@vercel/nft": "^0.24.3",
"esbuild": "^0.19.6",
"fast-glob": "^3.3.2",
"minimatch": "^9.0.3",
"set-cookie-parser": "^2.6.0",
"web-vitals": "^3.4.0"
},
Expand Down
17 changes: 16 additions & 1 deletion packages/integrations/vercel/src/lib/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import type { AstroIntegrationLogger } from 'astro';
import { relative, relative as relativePath } from 'node:path';
import { fileURLToPath } from 'node:url';
import { copyFilesToFunction } from './fs.js';
import { Minimatch } from 'minimatch';

const matchers = [
// Never venture into OS folders
'/dev/**',
// libsql contains many native deps that are false-positives.
'**/@libsql/client/**/*'
].map(pattern => new Minimatch(pattern, { dot: true }));

export async function copyDependenciesToFunction(
{
Expand Down Expand Up @@ -38,7 +46,14 @@ export async function copyDependenciesToFunction(
base: fileURLToPath(base),
// If you have a route of /dev this appears in source and NFT will try to
// scan your local /dev :8
ignore: ['/dev/**'],
ignore(path) {
for(const minimatch of matchers) {
if(minimatch.match(path)) {
return true;
}
}
return false;
},
cache,
});

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

Loading