8000 perf(es/minifier): Remove needless JSON conversion by kdy1 · Pull Request #10628 · swc-project/swc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf(es/minifier): Remove needless JSON conversion #10628

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

Merged
merged 11 commits into from
Jun 19, 2025
Merged

perf(es/minifier): Remove needless JSON conversion #10628

merged 11 commits into from
Jun 19, 2025

Conversation

kdy1
Copy link
Member
@kdy1 kdy1 commented Jun 19, 2025

@kdy1 kdy1 added this to the Planned milestone Jun 19, 2025
@kdy1 kdy1 self-assigned this Jun 19, 2025
Copy link
changeset-bot bot commented Jun 19, 2025

⚠️ No Changeset found

Latest commit: 1db0044

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kdy1 kdy1 marked this pull request as ready for review June 19, 2025 00:36
@kdy1 kdy1 requested a review from a team as a code owner June 19, 2025 00:36
kodiakhq[bot]
kodiakhq bot previously approved these changes Jun 19, 2025
kodiakhq[bot]
kodiakhq bot previously approved these changes Jun 19, 2025
@kdy1 kdy1 modified the milestones: Planned, v1.12.2 Jun 19, 2025
@kdy1 kdy1 disabled auto-merge June 19, 2025 01:11
@kdy1 kdy1 merged commit 4a58dca into main Jun 19, 2025
166 checks passed
@kdy1 kdy1 deleted the kdy1/min branch June 19, 2025 01:12
if (bindings) {
return bindings.minify(toBuffer(src), toBuffer(opts ?? {}), extras ?? {});
return bindings.minify(Buffer.from(typeof src === 'object' ? JSON.stringify(src) : src), toBuffer(opts ?? {}), typeof src === 'object', extras ?? {});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdy1
You widened the allowed type of src to include Buffer, in which case typeof src === 'object', which means if a caller passes a Buffer it will get stringified, which is going to make a mess. If you want to include Buffer in the allowed input types you'll want to handle it explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you are right
Thank you!

kdy1 added a commit to vercel/next.js that referenced this pull request Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

minify Node binding wastes cycles performing string -> JSON -> string
2 participants
0