From 597a9d697d9c831f0fcab2b921e73181e20e8e31 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 30 Jan 2024 16:55:32 -0500 Subject: [PATCH 1/2] Provide better ignores for Vercel's file tracer --- .changeset/poor-tips-turn.md | 5 +++++ packages/integrations/vercel/package.json | 1 + packages/integrations/vercel/src/lib/nft.ts | 17 ++++++++++++++++- pnpm-lock.yaml | 3 +++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .changeset/poor-tips-turn.md diff --git a/.changeset/poor-tips-turn.md b/.changeset/poor-tips-turn.md new file mode 100644 index 000000000000..f8ce904423f9 --- /dev/null +++ b/.changeset/poor-tips-turn.md @@ -0,0 +1,5 @@ +--- +"@astrojs/vercel": patch +--- + +Expand on ignores Vercel's file tracer diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index bb876d8c1d62..3a4c28ffcdd4 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -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" }, diff --git a/packages/integrations/vercel/src/lib/nft.ts b/packages/integrations/vercel/src/lib/nft.ts index 585a45e998dc..7ce2fa72541b 100644 --- a/packages/integrations/vercel/src/lib/nft.ts +++ b/packages/integrations/vercel/src/lib/nft.ts @@ -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( { @@ -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, }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3438ca898ba0..694e47b5c83e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4738,6 +4738,9 @@ importers: fast-glob: specifier: ^3.3.2 version: 3.3.2 + minimatch: + specifier: ^9.0.3 + version: 9.0.3 set-cookie-parser: specifier: ^2.6.0 version: 2.6.0 From 0f85f0026a082ddf15e0c1b7d8203b889329a8c1 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 30 Jan 2024 16:58:09 -0500 Subject: [PATCH 2/2] Improve the changeset --- .changeset/poor-tips-turn.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.changeset/poor-tips-turn.md b/.changeset/poor-tips-turn.md index f8ce904423f9..aeceb5dccfa2 100644 --- a/.changeset/poor-tips-turn.md +++ b/.changeset/poor-tips-turn.md @@ -2,4 +2,11 @@ "@astrojs/vercel": patch --- -Expand on ignores Vercel's file tracer +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.