svg-sprite / svg-sprite

SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)

Home Page:https://github.com/svg-sprite/svg-sprite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Needed dependency '@resvg/resvg-js-linux-x64-gnu' marked as optional

userjoergjakoby opened this issue · comments

We did an update of svg-sprite from version 1.5.4 to version 2.0.2 and afterwards we had the issue that our build failed with the error message:

2022-11-29 14:11:07.527 - error: Optimizing "setting.svg" with SVGO failed with error "Error: Cannot find module '@resvg/resvg-js-linux-x64-gnu'.

Our CI uses npm ci --omit=optional to skip dependencies necessary only on developer machines.

In this case however, the @resvg dependencies are necessary to the build with svg-sprite, which is why they should not be marked as optional.

commented

@yisibl Hello! Can you please check this? I think optionalDependencies can't be omited in resvg package. What can you suggest? Thanks

We're facing the same issue in our atos-parallel project...
It seems that this is the intended behavior from napi-rs though.

We use optional dependencies for developer helper tools like commit hooks.
Since those dependencies are not necessary on CI, we skip installing them to save time and bandwidth.
Being forced to install all optional dependencies would have a negative impact on our CI.

So a solution on resvg-js level would be highly appreciated 😊

If don't distribute native addons with optionalDependencies, the only other way is to distribute it with postinstall scripts, which is harmful to the developer experience and also introduces unnecessary dependencies for runtime (only for download binaries in postinstall), and can't be omitted at all.

There is an RFC in npm which may solve this problem in future: npm/rfcs#519