evanw / evanw/esbuild

esbuild should emit a warning when `emitDecoratorMetadata` is found in `tsconfig`

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

Description

I am nearing the end of a multi-month long effort to port a large, old production build system from 4-5 separate Webpack/Rollup configs to a single esbuild config.

Throughout these efforts I have been carefully exploring, iterating, and checking that both at buildtime and runtime things are working out and esbuild is satisfying the needs of our existing codebase without major modifications. Things have been going well, and I've been able to make small changes where necessary to accommodate the lack of type information / `tsc`.

Tonight I was very worried to discover that:

* `tsyringe` relies on the `emitDecoratorMetadata` tsc feature
* esbuild does not support `emitDecoratorMetadata`

I came across some discussion about `tsyringe` and esbuild online, which is the first I've realized that they won't necessarily play well together (I didn't introduce `tsyringe` into this codebase and I've never used it before, so I wasn't familiar with what it required). I've been building and using the built outputs from esbuild without issue for over a month now, so it was concerning to discover this potential runtime problem this late in the porting process. I spent the last 4 hours doing a lot of reading / discovery, and I've been able to fairly confidently prove that our codebase uses `tsyringe` in a way that [does not depend on the single location where `tsyringe` accesses the metadata emitted by tsc when `emitDecoratorMetadata` is `true`](https://github.com/microsoft/tsyringe/blob/2cd2e00a5fd25308bcf911ca250ded3fe9083af5/src/reflection-helpers.ts#L10), but I really would have preferred to have found out about this much earlier.

I would like to open a PR that would cause esbuild to emit a warning at build time when `emitDecoratorMetadata` is found in `tsconfig`, with a link to esbuild's docs stating that `emitDecoratorMetadata` is not supported. Would that be welcome? 🙂

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how esbuild reads tsconfig and how it reports build-time warnings; the issue does not name specific files or tests. Done means warning when emitDecoratorMetadata is present, with a link to documentation explaining that the option is unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, typescript
Domain
build-system, compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.