Skip to content

fix(serverless-framework): handle explicit extensions in handler paths - #2091

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
DreamLongYT:patch-6-serverless-handler-extensions
Oct 4, 2026
Merged

webpro merged 1 commit into
webpro-nl:mainfrom
DreamLongYT:patch-6-serverless-handler-extensions

Conversation

@DreamLongYT

Copy link
Copy Markdown
Contributor

Problem

When a Serverless handler specifies its source extension, such as function/handler.js.handler, Knip appended {js,ts} to the path and searched for function/handler.js.{js,ts}. As a result, the actual handler file could be incorrectly reported as unused.

Solution

Preserve explicit JS/TS-family extensions in handler paths. Continue searching both .js and .ts when the handler path has no explicit source extension. Updated the Serverless fixture and added a regression assertion that the explicit .js handler is not reported as unused.

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2091
npm i https://pkg.pr.new/@knip/language-server@2091
npm i https://pkg.pr.new/@knip/mcp@2091

commit: a856eab

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! This correctly recognizes explicit .js and .cjs handler paths supported by Serverless v3 local invocation.

@webpro
webpro merged commit e939396 into webpro-nl:main Oct 4, 2026
32 checks passed
@webpro

webpro commented Oct 6, 2026

Copy link
Copy Markdown
Member

πŸš€ This pull request is included in v6.40.0. See Release 6.40.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@DreamLongYT
DreamLongYT deleted the patch-6-serverless-handler-extensions branch October 6, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants