imagemin / imagemin-svgo

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

Support both ESM and CommonJS module #51

Closed 3c1u closed 4 months ago

3c1u commented 3 years ago

The recent update (v10.0.0) breaks nuxt-optimized-images because of lacking support of CommonJS. Including both ESM and CommonJS files would be ideal.

creage commented 3 years ago

It also breaks image-minimizer-webpack-plugin:

WARNING in Unknown plugin: imagemin-svgo
Did you forget to install the plugin?
You can install it with:
$ npm install imagemin-svgo --save-dev
$ yarn add imagemin-svgo --dev
MrTomek commented 3 years ago
 ERROR  Must use import to load ES Module: .../node_modules/imagemin-svgo/index.js                                                           nuxt:@aceforth/nuxt-optimized-images 15:25:54
require() of ES modules is not supported.
require() of .../node_modules/imagemin-svgo/index.js from .../node_modules/@aceforth/nuxt-optimized-images/lib/loaders/img-loader.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from .../node_modules/imagemin-svgo/package.json.
derBlume commented 2 years ago

It also breaks next-optimized-images:

> Build error occurred
122Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: .../node_modules/imagemin-svgo/index.js
123require() of ES modules is not supported.
124require() of .../node_modules/imagemin-svgo/index.js from .../node_modules/next-optimized-images/lib/loaders/img-loader.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
125Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from .../node_modules/imagemin-svgo/package.json.

Releated issue: https://github.com/cyrilwanner/next-optimized-images/issues/264

joemaller commented 2 years ago

https://github.com/webpack-contrib/image-minimizer-webpack-plugin/issues/237

Emiliano-Bucci commented 2 years ago

News on this?

patrikjuvonen commented 2 years ago

Any updates?

cc @1000ch

darshanputtaswamy commented 2 years ago

Any Updates ?

yaeru commented 2 years ago

Any news?

kouhin commented 2 years ago

cc @1000ch 😁

yordis commented 2 years ago

Hey there, any opportunity to get #57 reviewed and merged?

sindresorhus commented 4 months ago

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