Error [ERR_REQUIRE_ESM]: require() of ES Module /path/node_modules/imagemin-mozjpeg/index.js from /path/node_modules/next-optimized-images/lib/loaders/img-loader.js not supported.
Instead change the require of index.js in /path/node_modules/next-optimized-images/lib/loaders/img-loader.js to a dynamic import() which is available in all CommonJS modules.
at requireImageminPlugin (/path/node_modules/next-optimized-images/lib/loaders/img-loader.js:21:10)
at getImgLoaderOptions (/path/node_modules/next-optimized-images/lib/loaders/img-loader.js:42:11)
at applyImgLoader (/path/node_modules/next-optimized-images/lib/loaders/img-loader.js:96:28)
at appendLoaders (/path/next-optimized-images/lib/loaders/index.js:137:14)
at Object.webpack (/path/next-optimized-images/lib/index.js:62:24)
at Object.newWebpackFunction [as webpack] (/path/@sentry/nextjs/dist/config/webpack.js:39:40)
at Object.getBaseWebpackConfig [as default] (/path/next/dist/build/webpack-config.js:1176:32)
at async Promise.all (index 0)
at async Span.traceAsyncFn (/path/next/dist/trace/trace.js:79:20)
at async /path/next/dist/build/index.js:322:29
at async /path/next/dist/build/index.js:318:9
at async Span.traceAsyncFn (/path/next/dist/trace/trace.js:79:20)
at async Object.build [as default] (/path/next/dist/build/index.js:55:25) {
code: 'ERR_REQUIRE_ESM'
Same as https://github.com/cyrilwanner/next-optimized-images/issues/264 but for mozjpeg.
I think the change is this one https://github.com/imagemin/imagemin-mozjpeg/commit/9f3f702b44a85e546c57ed0e1044fade757abd00