egoist / egoist/tsup

Add support for specifying external helpers to avoid patching SWC

Open
#1,291 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Currently, in order to enable externalHelpers for legacy decorators in SWC, users need to manually patch swc.transformFile. It would be helpful if tsup provided a way to specify this option without requiring modifications to SWC itself.
### Example workaround:
```
const transformFile = swc.transformFile;
swc.transformFile = (filePath, options) => {
if (options?.jsc?.transform?.legacyDecorator) options.jsc.externalHelpers = true;
return transformFile.call(this, filePath, options);
};
```
### Proposed solution:
Introduce an option in tsup to allow enabling externalHelpers when using decorators, eliminating the need for manual patches.

Contributor guide

Open the contributing guide

Research direction

Start by tracing tsup's SWC integration around swc.transformFile and the decorator-related options shown in the workaround. Define where the new configuration belongs, how it should enable externalHelpers only for the relevant decorator flow, and how the behavior can be verified; the issue names no repository files or tests, so those entry points must first be located.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
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.