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

[transformer] bundle runtime helpers / remove runtime helper import code from output #7599

Open
sapphi-red opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
C-enhancement Category - New feature or request

Comments

@sapphi-red
Copy link
Contributor

I'm trying to use the transform api as a replacement of esbuild.transform. When esbuild needs to use a helper function for lowering, it injects them at the top of the output (esbuild try).
On the other hand, oxc injects a import or require for the helper function.

This makes it difficult to use it as an replacement for my case. I'm running esbuild in renderChunk hook of rollup and at that time the chunking has already done. I have to analyze the output and run a different build to get the helper functions and connect the chunks.

If oxc has a flag that injects the helper function into the output, it will be really easy to swap esbuild with oxc.

Or if oxc has a flag that makes the output to not include the import/require, I won't need to analyze the output.
An example API looks like this:

const result = transformWithOxc(name, 'const bar = {..."bb"}', {
  target: 'es2017',
  sourceType: 'module',
  helpers: 'external' // proposed flag
})

console.log(result.helpers) // { '_objectSpread': '@babel/runtime/helpers/objectSpread2' }

Then, I can know which helpers are needed without analyzing the output.

@sapphi-red sapphi-red added the C-enhancement Category - New feature or request label Dec 3, 2024
@Boshen Boshen self-assigned this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants