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

@swc/core additional binding contracts that accept and receive utf8 data as JsBuffer instead of String #9876

Open
dmichon-msft opened this issue Jan 13, 2025 · 1 comment

Comments

@dmichon-msft
Copy link

Describe the feature

If the caller prefers to delegate file reading to the NodeJS layer and/or has a custom workflow, it can save CPU cycles to pass the data into SWC directly as a UTF-8 encoded Buffer instead of transcoding the internal UTF-16 representation to UTF-8 (or vice versa).

My primary use case is with a flow where I:

  1. Read raw text from disk to a Buffer
  2. Call parse() and get back a serialized AST
  3. Call transform() multiple times with different options, using the AST from (2)
  4. Write the results to disk

All of the transfers between the NodeJS process and SWC would be more efficient if I could pass the data as Buffer instead of string.

Babel plugin or link to the feature description

No response

Additional context

No response

@kdy1 kdy1 self-assigned this Jan 14, 2025
@kdy1 kdy1 added this to the Planned milestone Jan 14, 2025
@kdy1
Copy link
Member

kdy1 commented Jan 14, 2025

We already support Buffer, including from swc-loader. Is it different thing?

@kdy1 kdy1 removed their assignment Jan 14, 2025
@kdy1 kdy1 removed this from the Planned milestone Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants