svg / svgo

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

svgo/lib/svgo/svg2js is no longer available - is there a replacement? #1612

Open daKmoR opened 2 years ago

daKmoR commented 2 years ago

Describe the bug Since 2.7.0 the file svgo/lib/svgo/svg2js no longer exists... it is used in https://github.com/Ashung/svg2vectordrawable

Is there a "public" API with the capabilities of svg2js?

To Reproduce Steps to reproduce the behavior:

  1. mkdir test; cd test
  2. npm i svg2vectordrawable svgo
  3. $ npx s2v -h
  4. node:internal/modules/cjs/loader:936
     throw err;
     ^
    
    Error: Cannot find module 'svgo/lib/svgo/svg2js'
    Require stack:
    // ...

Expected behavior s2v to run

Desktop (please complete the following information):

Additional context

I search through some issues and it seems svg2js is considered a private API? if so how about releasing a new major version with an "export" map then those apis will become actually private (e.g. users will no longer be able to import anything that is NOT in the export map)

https://nodejs.org/api/packages.html#exports

TrySound commented 2 years ago

Those were not documented in readme. Sticking with some file structure would not let the project to evolve.

Id recommend to refactor svgo usage as plugin instead of hacking internals. As fast fix you can use /lib/parser module which is also private so do not expect it to work forever.

daKmoR commented 2 years ago

Those were not documented in readme. Sticking with some file structure would not let the project to evolve.

fully agree with that 👍. that's why I would highly recommend an export map as it will "enforce" this. You can freely restructure without breaking any public API. (e.g. the internal API will not be accessible at all - if a user require/import it node will throw an error)

Id recommend to refactor svgo usage as plugin instead of hacking internals.

I'm just a user of svg2vectordrawable but I will raise this suggestion there as that sounds like a good path forward 🤗

TrySound commented 2 years ago

Exports field may break some usages. Wouldnt like to introduce it before next major.

daKmoR commented 2 years ago

Exports field may break some usages. Wouldnt like to introduce it before next major.

makes sense 👍

TrySound commented 2 years ago

Btw this project need to get rid from coa which was compromised recently.