imagemin / imagemin-svgo

SVGO plugin for imagemin
MIT License
125 stars 28 forks source link

Fix/commonjs export #57

Closed michielmetcake closed 6 months ago

michielmetcake commented 2 years ago

Fixes: https://github.com/imagemin/imagemin-svgo/issues/56 and https://github.com/imagemin/imagemin-svgo/issues/51

webketje commented 1 year ago

@michielmetcake Unfortunately this PR breaks all tests and is the opposite direction of where sindre intended his packages to go, see the FAQ section of https://github.com/sindresorhus/meta/discussions/15

Do you plan to include CommonJS fallback files? No. Node.js 12 supports ESM natively. There's no point.

So reverting to the .cjs format is not an option. If you use imagemin directly, you can do as below for a workaround:

const loadImageminSvgo = await import('imagemin-svgo')
const imageminSvgo = loadImageminSvgo.default

If you depend on a package which expects imagemin-svgo to export a CJS module, you can only insist that the maintainers of the depending package implement this fix or migrate to another CJS-supported implementation.

I would consider adding a cjs branch which would allow one to do npm i github:imagemin/imagemin-svgo#cjs, but that would still not solve situations where imagemin-svgo is depended upon by another library.

sindresorhus commented 6 months ago

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

PizzaPete commented 6 months ago

We're no longer blocked by this. That's why there was no activity in this PR for a while.