Add option to disable ES transforms in `sucrase`
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
`tsup` uses `sucrase` to transpile ESM to CJS when code splitting is enabled:
https://github.com/egoist/tsup/blob/83c7c7f3131ca6d46aaad4de3111c2fd5e5b5c21/src/plugins/cjs-splitting.ts#L21-L31
Unfortunately there is no way right now to specify the settings for `sucrase`. In our case, we wanted to disable the optional chaining polyfill that `sucrase` adds, since it's problematic for static analysis. The only way to do so seems to be by setting `disableESTransforms: true` in the options. It would be great if `tsup` had an option to set this.
Contributor guide
Research direction
Start in src/plugins/cjs-splitting.ts at the linked Sucrase call, then trace how tsup exposes build options. Check how the disableESTransforms setting can reach Sucrase without changing existing code-splitting behavior. Done means users can configure that option and the generated CJS no longer applies the unwanted optional-chaining transform.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100