[python] only create api builders for .py files that export an app or handler#14493
Merged
Conversation
🦋 Changeset detectedLatest commit: 66e6dc7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🧪 Test StrategyComparing: Strategy: Code changed outside of a package - running ALL tests Affected packages - 39 (100%)
Results
This comment is automatically generated based on the affected testing strategy |
smaeda-ks
approved these changes
Dec 18, 2025
onsclom
approved these changes
Dec 18, 2025
Merged
onsclom
pushed a commit
that referenced
this pull request
Dec 19, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @vercel/build-utils@13.2.4 ### Patch Changes - [python] only create api builders for `.py` files that export an app or handler ([#14493](#14493)) ## vercel@50.1.3 ### Patch Changes - Run install command earlier for vercel.ts ([#14504](#14504)) - [python] only create api builders for `.py` files that export an app or handler ([#14493](#14493)) - Remove vercel.ts feature flag ([#14501](#14501)) - Updated dependencies \[[`f8e79cd385e3635a5d8227cb357af381b883d053`](f8e79cd), [`c55475f865ecf22f27b8b17f6fc98b9e1455ab5d`](c55475f)]: - @vercel/ruby@2.2.4 - @vercel/build-utils@13.2.4 - @vercel/python@6.1.5 - @vercel/backends@0.0.17 - @vercel/elysia@0.1.15 - @vercel/express@0.1.21 - @vercel/fastify@0.1.18 - @vercel/go@3.2.4 - @vercel/h3@0.1.24 - @vercel/hono@0.2.18 - @vercel/hydrogen@1.3.3 - @vercel/nestjs@0.2.19 - @vercel/next@4.15.9 - @vercel/node@5.5.16 - @vercel/redwood@2.4.6 - @vercel/remix-builder@5.5.6 - @vercel/rust@1.0.4 - @vercel/static-build@2.8.15 ## @vercel/client@17.2.18 ### Patch Changes - Updated dependencies \[[`c55475f865ecf22f27b8b17f6fc98b9e1455ab5d`](c55475f)]: - @vercel/build-utils@13.2.4 ## @vercel/elysia@0.1.15 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/express@0.1.21 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/fastify@0.1.18 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/fs-detectors@5.7.11 ### Patch Changes - [python] only create api builders for `.py` files that export an app or handler ([#14493](#14493)) ## @vercel/gatsby-plugin-vercel-builder@2.0.114 ### Patch Changes - Updated dependencies \[[`c55475f865ecf22f27b8b17f6fc98b9e1455ab5d`](c55475f)]: - @vercel/build-utils@13.2.4 ## @vercel/h3@0.1.24 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/hono@0.2.18 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/nestjs@0.2.19 ### Patch Changes - Updated dependencies \[]: - @vercel/node@5.5.16 ## @vercel/node@5.5.16 ### Patch Changes - Updated dependencies \[[`c55475f865ecf22f27b8b17f6fc98b9e1455ab5d`](c55475f)]: - @vercel/build-utils@13.2.4 ## @vercel/python@6.1.5 ### Patch Changes - [python] only create api builders for `.py` files that export an app or handler ([#14493](#14493)) ## @vercel/ruby@2.2.4 ### Patch Changes - Replace bundle install flags with environment variables. ([#14499](#14499)) ## @vercel/static-build@2.8.15 ### Patch Changes - Updated dependencies \[]: - @vercel/gatsby-plugin-vercel-builder@2.0.114 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
smaeda-ks
added a commit
that referenced
this pull request
Apr 8, 2026
Add static entrypoint detection for Node.js files in `/api/`, mirroring #14493 which did the same for Python. Helper/utility files that don't export a valid handler are no longer treated as API routes, avoiding unnecessary Vercel Function creation. Gated behind `VERCEL_NODE_FILTER_ENTRYPOINTS=1` env var for safe incremental rollout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
smaeda-ks
added a commit
that referenced
this pull request
Apr 9, 2026
…15873) ## Summary - Adds static entrypoint detection for Node.js files in `/api/`, mirroring #14493 which did the same for Python - Helper/utility files that don't export a valid handler are no longer treated as API routes, avoiding unnecessary Vercel Function creation - Gated behind `VERCEL_NODE_FILTER_ENTRYPOINTS=1` environment variable for safe incremental rollout ## How it works A new `isNodeEntrypoint()` function in `@vercel/build-utils` uses regex-based heuristics to detect valid handler export patterns in `.js`, `.mjs`, `.ts`, and `.tsx` files: | Pattern | Example | |---------|---------| | ESM default export | `export default function handler(req, res) {}` | | CJS module.exports | `module.exports = (req, res) => {}` | | Named HTTP method exports | `export function GET(request) {}` | | Fetch export | `export function fetch(request) {}` | | Re-exports | `export { handler as default }` | | Server handler | `http.createServer(...)` | Files that don't match any pattern (e.g., utility functions, type-only files, config exports) are skipped in `maybeGetApiBuilder()` and won't produce a Vercel Function. ## Test plan - [ ] 34 unit tests for `isNodeEntrypoint()` covering valid entrypoints, non-entrypoints, and edge cases - [ ] 3 integration tests in fs-detectors verifying builder creation/skipping with actual files on disk - [ ] Verified all 116+ existing handler files across Node builder and CLI test fixtures match at least one detection pattern - [ ] Verified feature is inactive without env var (zero behavior change by default) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A helper file in /api that does not export an app or http handler should not create a lambda. This PR adds a helper to build-utils to detect if a file contains a top-level app or handler