evanw / evanw/esbuild

Enhancement request: hoist keepNames implementation

Open
#4,239 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

when c8 wraps files transformed via esbuild (i.e. like via tsx), use of the keepNames option (which tsx uses by default) can add a line of unreachable code when the function is declared after a return statement, as demonstrated here:

https://github.com/yaacovcr/esbuild-sourcemap-test

This can cause coverage issues with esbuild/tsx.

It would be great if the keepNames options for esbuild could set the name of the function at the top of the relevant scope.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked esbuild-sourcemap-test reproduction and inspect how the keepNames option handles functions declared after return statements in transformed files. Confirm the unreachable code and coverage impact with the esbuild/tsx scenario; done means the function name is assigned at the top of the relevant scope without adding unreachable code.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, javascript, typescript
Domain
build-system, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.