Skip to content

minify Node binding wastes cycles performing string -> JSON -> string #10610

@dmichon-msft

Description

@dmichon-msft

Describe the feature

In the simple case of minifying a block of text, the current minify() projection into NodeJS wastes a fair amount of CPU invoking JSON.stringify on the raw text before passing it into the minifier, which then deserializes the JSON back into a string.

It seems like there should be a better way to handle differentiating the { [fileName: string]: string } input format from code: string that doesn't require such an expensive operation. Projecting separate binding entry points and switching between them in the Node API seems like it would be cleaner? Or having which data type be an option in one of the other parameters?

Babel plugin or link to the feature description

No response

Additional context

I'm currently trying to diagnose why switching from running Terser in 8 worker threads to the SWC minifier isn't showing the performance gains that I expected, and so I'm poking into bottlenecks.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions