ISSUE DESCRIPTION False positive unused file for Vercel vercel.ts config What happened?…
- User
ISSUE DESCRIPTION
False positive unused file for Vercel vercel.ts config
What happened?
fallow dead-codereportsapps/web/vercel.tsas an unused file, but Vercel treatsvercel.tsas a project configuration file that is discovered and executed by convention.The file is not imported by application source, so it looks unused to a pure import graph. It should be treated as a Vercel config entrypoint.
Vercel docs say:
vercel.tsconfigures and overrides Vercel project behavior.- Unlike
vercel.json,vercel.tsexecutes at build time. - The final config must be exported as
config. - Vercel also supports
vercel.js,vercel.mjs,vercel.cjs, andvercel.mts.
The
@vercel/configpackage also treatsvercel.tsas the config input:packages/config/README.mdsays to create avercel.tsfile in the project root.packages/config/README.mdsaysvercel.tsis automatically compiled duringvercel build,vercel dev, andvercel deploy.packages/config/src/cli.tsresolvesprocess.cwd()/vercel.ts.packages/config/src/cli.tsimports the config module and collects named exports.packages/config/example/vercel.tsshows the expectedexport const configshape.
Because Vercel discovers this file by convention, Fallow should not report it as unused.
Reproduction
Create an app/workspace with a
package.jsonlike:{ "name": "@example/web", "private": true, "type": "module", "scripts": { "build": "next build", "env-pull": "vercel env pull" }, "devDependencies": { "@vercel/config": "latest", "vercel": "latest" } }Create
vercel.tsat the app root:import type { VercelConfig } from '@vercel/config/v1'; export const config = { regions: ['dub1'], fluid: true, installCommand: 'pnpm install --filter @example/web...', devCommand: 'next dev --port 3000', crons: [ { path: '/api/jobs/run', schedule: '*/5 * * * *', }, ], } satisfies VercelConfig;Run:
fallow dead-codevercel.tsis reported as an unused file.Expected behavior
Fallow should treat Vercel programmatic config files as used config entrypoints when Vercel is active.
At minimum, the Vercel plugin/config detection should mark these app-root files as always used:
vercel.tsvercel.jsvercel.mjsvercel.cjsvercel.mts
A fix could add these to the relevant Vercel plugin config/always-used patterns, similar to how other framework config files are protected from unused-file reporting.
Fallow version
2.85.0
Operating system
macOS
Configuration
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /fallow, current file: none) bash-$
Assistant
I'll start by exploring the repository structure to understand the codebase and find the relevant Vercel-related files.
Assistant
Let me explore the repository structure further, especially looking for Vercel-related files.
Assistant
Let me look at the plugins directory structure to understand how plugins work in this codebase.
Assistant
Let me continue looking at the plugins mod.rs to understand the Plugin trait and how config files are handled.
Assistant
Let me see the rest of the Plugin trait.
Assistant
Let me look at the registry and check if there's already a Vercel plugin.
Assistant
Let me look at the nextjs plugin and the wrangler plugin to understand the patterns used.
Assistant
Now let me look at the nextjs plugin to understand how it handles Vercel-related configurations.
Assistant
Let me look at how Vercel is referenced in the discover module and understand the activation logic.
Assistant
Let me look at a simple plugin like commitlint to understand the macro usage pattern, and check the registry tests.
Assistant
Now let me understand the test infrastructure and reproduce the issue. Let me look at the registry tests file and how plugins are tested end-to-end.
Assistant
Let me look at the registry helpers and mod to understand how always_used files are processed.
Assistant
Let me look at the full registry builtin.rs to understand plugin categorization.
Assistant
Let me check if there's a vercel module declaration already and look at the full module list in mod.rs.
Assistant
Let me first build the project to understand the build process and reproduce the issue.
Assistant
Now let me create a test project to reproduce the issue.
Assistant
I've reproduced the issue. Now let me understand how
always_usedpatterns are matched against files, especially for workspace scenarios.Assistant
Let me find where always_used patterns are matched against the file set to mark files as used.
Assistant
Let me search the codebase for where the always_used patterns are actually consumed for dead-code analysis (i.e., where they mark files as used/protected).
Assistant
Let me look at how always_used patterns get workspace-prefixed in the registry mod.rs.
Assistant
The
always_usedpatterns get workspace-prefixed viaprefix_if_needed. Now let me check whethervercel.jsonwould also be reported as unused, to understand the full scope.Assistant
Interesting -
vercel.jsonis NOT reported as unused, butvercel.tsis. Let me understand why JSON files aren't reported.Assistant
JSON files aren't in the source extension set, so
vercel.jsonisn't reported. Now let me look at how convention-based detection works for plugins, examining browser_extension which usesis_enabled_with_files.Assistant
Now I have a thorough understanding. Let me create the Vercel plugin. I'll model it after the commitlint/wrangler plugins. Let me first check the
define_plugin!macro's full variants to ensure I use the right syntax forimports_only.Assistant
Now I have a complete understanding. Let me create the Vercel plugin file.
Assistant
Now let me register the module in
mod.rsand add it to the builtin plugins list.Assistant
I'll add the
vercelmodule declaration right afterwrangler(alphabetical order).Assistant
Now let me register the plugin in
builtin.rs. I'll add it to the import and to the "Deployment" section alongside WranglerPlugin.Assistant
Let me view the full import block to add
vercel::VercelPlugincorrectly.Assistant
Now I'll add the import and register the plugin. First, the import (alphabetically by module name, between
veliteandvite):Assistant
Now add the plugin to the Deployment section:
Assistant
Now let me build the project to make sure it compiles.
Assistant
It compiles. Now let me run the reproduction to confirm the fix works.
Assistant
The fix works.
vercel.tsis no longer reported as unused. Let me verify the entry point detection shows the Vercel plugin and test more edge cases.Assistant
The Vercel plugin is now active. Let me test edge cases - all extensions and activation with each enabler separately.
Assistant
All five extensions are protected. Now let me test activation with only
@vercel/configand verify it's NOT protected when Vercel isn't active.Assistant
Let me see the full output for the no-deps case to confirm
vercel.tsis reported as unused when Vercel is not active.Assistant
The behavior is correct. Now let me run the unit tests for the new plugin and verify existing tests pass.
Assistant
Let me fix the type error in the test -
containson&[&str]needs&&str.Assistant
All tests pass. Now let me run the registry tests to ensure the plugin registration works and doesn't break existing tests.
Assistant
Let me check if there's a test that asserts the count of builtin plugins, which might need updating.
Assistant
The test doesn't use a brittle count check. Let me check if there are other places that list plugin names that might need updating (schema, knip migration, docs).
Assistant
Let me understand the context of the knip_tables.rs file.
Assistant
This is a list of knip-specific plugin keys (knip doesn't have a "vercel" plugin, only "vercel-og" which is already listed). Let me check the schema and docs for plugin lists.
Assistant
There's a detection rules document. Let me examine its structure to add a Vercel entry for consistency.
Assistant
Let me view the section around the Wrangler detection entry to add a Vercel entry nearby.
Assistant
I'll add a detection rule entry for the Vercel plugin, right after the Wrangler entry for documentation consistency.
Assistant
Now let me check the public-config-corpus.md and any schema that may need a Vercel entry.
Assistant
Let me check if there are any tests that enumerate all plugin names or check the schema completeness.
Assistant
The tests check for unique/non-empty names and a critical plugin list — my plugin passes these. Let me run the broader test suites to ensure nothing breaks.
Assistant
All lib tests pass. Let me run the integration tests for the core crate.
Assistant
All integration tests pass. Let me run the CLI tests to ensure the migration logic and other CLI tests still pass.
Assistant
There's a failing test
fix_batch_aborts_when_a_target_directory_is_read_only. This looks environment-related (read-only dirs don't apply to root). Let me verify it's pre-existing and unrelated to my change.Assistant
Confirmed — that test fails even without my changes (it's a pre-existing environment issue: running as root bypasses read-only filesystem permissions). Let me run the flags and migrate tests specifically since they reference Vercel.
Assistant
All relevant tests pass. The only failure is pre-existing and environment-related. Let me now test the full reproduction scenario with a realistic
node_modulessetup to verify dependency crediting works too.Assistant
Let me verify dependency crediting more directly with a scenario that isolates the tooling_dependencies behavior.
Assistant
Even without imports/scripts, the packages are credited as tooling dependencies. Let me test production mode to ensure
vercel.tsis still protected there.Assistant
Production mode works. Let me verify that a nested
vercel.ts(not at the app root) is still correctly flagged as unused, since Vercel only discovers root-level config.Assistant
The nested file is correctly flagged. Let me improve the test in the plugin to be more meaningful by actually verifying each extension matches the glob pattern.
Assistant
All tests pass. Let me run clippy to ensure code quality standards are met.
Assistant
Let me see the full clippy warning for my file.
Assistant
The clippy warning is about unnecessary hashes in the raw string literal (content uses single quotes, so
r"..."suffices). Let me fix this.Assistant
No more clippy warnings. Let me verify the full clippy run completes cleanly and re-run the vercel tests.
Assistant
Everything is clean. Let me do a final review of all my changes.
Assistant
Let me fix the alphabetical ordering of the
mod vercel;declaration - it should be betweenveliteandvite, not afterwrangler.Assistant
Now the module is in proper alphabetical order. Let me rebuild and run the tests once more to confirm everything works.
Assistant
Let me check if there's a typos configuration and verify my changes don't introduce spelling issues.
Assistant
typosisn't installed, but my changes use standard English. Let me run the full core test suite (lib + integration) one final time to confirm nothing is broken after the module reordering.Assistant
Let me run the full lib test suite to confirm the combined count.
Assistant
All tests pass. Let me verify one more edge case: a root-level
vercel.ts(not in a workspace) is also protected.Assistant
Root-level
vercel.tsis also protected. Let me clean up the temp test directories and do a final review.Assistant
Let me do a final review of the complete changes to ensure correctness.
Assistant
Let me verify formatting conformance with
cargo fmt --checkon the affected files.Assistant
Let me apply
cargo fmtto fix the formatting issues.Assistant
Formatting is now clean. Let me verify the final formatted state of the changed files and rebuild/test once more.
Assistant
Everything builds and tests pass. Let me do one final end-to-end reproduction to confirm the fix, then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →