point-of-view icon indicating copy to clipboard operation
point-of-view copied to clipboard

support for async minify methods

Open quiquelhappy opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Add support for async minify methods.

html-minifier-terser uses exactly the same call type, so it would be as easy as executing the exact same call this library is already using, but with an await right before it

I would do a PR myself, but when I saw the codebase and the amount of calls to the minify method everywhere, I felt kinda overwelmed mostly because none of them are inside an async method. If someone who better knows this lib could just add async where needed and await the minify method, it'd be enough to add support for this alternative

I would consider this change to be quite important and something to do in the near future, since with time, new vulnerabilities for html-minify will rise, and it's been unmantained for 4 years now

Motivation

The mentioned html-minifiier lib mentioned in the docs is now long unmantained and shouldn't be used.

html-minifier-terser seems like a good performant options which uses the same option settings.

Example

html-minifier-terser:

export function minify(value: string, options?: Options): Promise<string>;

currently used method call, html-minifier

export function minify(text: string, options?: Options): string;

quiquelhappy avatar Jun 03 '23 09:06 quiquelhappy

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar Jun 10 '23 05:06 mcollina

I saw both projects. I think the terser version is a fork since they share same readme and same options :) tried to help you @quiquelhappy with a PR: https://github.com/fastify/point-of-view/pull/378

multivoltage avatar Jul 06 '23 14:07 multivoltage

@quiquelhappy release 9.0 use minifier-terser. Can you consider this issue closed?

multivoltage avatar Mar 20 '24 21:03 multivoltage