Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable ES transforms in sucrase #1087

Open
Mrtenz opened this issue Feb 27, 2024 · 1 comment
Open

Add option to disable ES transforms in sucrase #1087

Mrtenz opened this issue Feb 27, 2024 · 1 comment

Comments

@Mrtenz
Copy link

Mrtenz commented Feb 27, 2024

tsup uses sucrase to transpile ESM to CJS when code splitting is enabled:

const { transform } = await import('sucrase')
const result = transform(code, {
filePath: info.path,
transforms: ['imports'],
sourceMapOptions: this.options.sourcemap
? {
compiledFilename: info.path,
}
: undefined,
})

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.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@FrederikBolding
Copy link

To be clear, @Mrtenz and I are willing to submit a PR for this feature. But we would need some guidance on how best to implement it. E.g. should we simply add a configuration option for this or automatically determine the value of disableESTransforms by looking at the target?

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

No branches or pull requests

2 participants