Skip to content

transformer: enable / disable each transform instead of target #15373

@sapphi-red

Description

@sapphi-red

esbuild has supported option that allows you to configure enable / disable each transform. There's no option like that in Oxc Transformer.

Quoting the reasons to use this option from esbuild's docs:

Here are some examples of why you might want to use this setting instead of or in addition to setting the target:

  • JavaScript runtimes often do a quick implementation of newer syntax features that is slower than the equivalent older JavaScript, and you can get a speedup by telling esbuild to pretend this syntax feature isn't supported. For example, V8 has a long-standing performance bug regarding object spread that can be avoided by manually copying properties instead of using object spread syntax.
  • There are many other JavaScript implementations in addition to the ones that esbuild's target setting recognizes, and they may not support certain features. If you are targeting such an implementation, you can use this setting to configure esbuild with a custom syntax feature compatibility set without needing to change esbuild itself. For example, TypeScript's JavaScript parser may not support arbitrary module namespace identifier names so you may want to turn those off when targeting TypeScript's JavaScript parser.
  • You may be processing esbuild's output with another tool, and you may want esbuild to transform certain features and the other tool to transform certain other features. For example, if you are using esbuild to transform files individually to ES5 but you are then feeding the output into Webpack for bundling, you may want to preserve import() expressions even though they are a syntax error in ES5.

rolldown/rolldown#6212 also asks for this feature.

(I'm creating this issue as a placeholder, if you actually need this feature, make sure to add "👍" and describe the usecase in the comments)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-transformerArea - Transformer / Transpiler

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions