fastify / point-of-view

Template rendering plugin for Fastify
MIT License
338 stars 86 forks source link

support for async minify methods #372

Closed quiquelhappy closed 5 months ago

quiquelhappy commented 1 year ago

Prerequisites

🚀 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;
mcollina commented 1 year ago

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

multivoltage commented 1 year ago

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 commented 5 months ago

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