svg / svgo

⚙️ Node.js tool for optimizing SVG files
https://svgo.dev/
MIT License
20.64k stars 1.38k forks source link

SVGO v3 #1429

Open TrySound opened 3 years ago

TrySound commented 3 years ago

Just a list of possible changes

strarsis commented 3 years ago

Would it make sense to add the txml parser PR (https://github.com/svg/svgo/pull/1301) to the milestone, too?

vanillajonathan commented 3 years ago

Maybe TypeScript?

TrySound commented 3 years ago

Maybe. We already started adding jsdoc for ts.

TrySound commented 2 years ago

Started covering plugins with tsdoc. Quite handy. https://github.com/svg/svgo/pull/1527

septs commented 2 years ago

Will this project eventually migrate to TypeScript only? or most files?

TrySound commented 2 years ago

Probably no, I'd like to avoid build step. And tsdoc looks like good enough.

vanillajonathan commented 2 years ago

With tsdoc/esdoc/jsdoc you might want to generate HTML documentation which you can host on GitHub pages.

oscarotero commented 2 years ago

Typescript or, at least, ES modules would be great. I created a fork to provide support for Deno some time ago (https://github.com/lumeland/svgo) but it's hard to maintain and update every new version. If the SVGO core used ESM it would be much more easy to adapt for Deno.

TrySound commented 2 years ago

Thank you for this! Not sure about timing. Will try to start working on v3 before the end of the year.

TrySound commented 2 years ago

Btw @oscarotero svgo provides esm module for browsers https://unpkg.com/browse/svgo@2.7.0/dist/svgo.browser.js

The entry point is this module https://github.com/svg/svgo/blob/master/lib/svgo.js

Instead of https://github.com/svg/svgo/blob/master/lib/svgo-node.js used for node.

Can this help with deno?

oscarotero commented 2 years ago

Yes, It's the same entry point that I've used in the Deno fork https://github.com/lumeland/svgo/blob/deno/mod.js But the browser dist stores the SVG in globalThis (or window), and to use it in Deno it must be imported as module.

TrySound commented 2 years ago

SVGs are not stored in globalThis. Just some dependencies rely on globalThis to cache polyfills.

oscarotero commented 2 years ago

Sorry, you're right. I didn't know SVGO exports ES modules. Just tested it and seems to work fine. Thanks!

I'd love to have some official Deno support (to take advantage of types for configuration and stuff) but, for now, the browser dist just works.

vanillajonathan commented 2 years ago

If you decide not to use TypeScript you might be interested to generate TypeScript defintion files (*.d.ts).

https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html https://github.com/microsoft/dts-gen

TrySound commented 2 years ago

That's not a problem. I'll publish types when whole project migrate to TSDoc.

vanillajonathan commented 2 years ago

That's not a problem. I'll publish types when whole project migrate to TSDoc.

Maybe you could generate HTML docs and host it on GitHub Pages then also?

TrySound commented 2 years ago

@vanillajonathan You already wrote about this. Types are not ready yet.

vanillajonathan commented 2 years ago

I meant when you publish the types and when the project has finished its migration to TSDoc.

amareshsm commented 1 year ago

Hey @TrySound, I would like to contribute to replace default params object with default params syntax in destructuring change Can you give some examples for this?

https://github.com/svg/svgo/blob/a9834efa1603198ae606765292215462ae193d0d/lib/svgo.js#L16-L19

something like this?

 const optimize = (input:string='', config: { [key: string]: string; } | null = null) => { 
   if (config == null) { 
     config = {}; 
   } 
JoKalliauer commented 1 year ago

svgo v3.0 is released. Is this issue still up to date?