Suppress webpack's critical dependency warnings for libheif

Supressing it for now since it obscures other important information in the console.

Upstream issue, which currently doesn't have a workaround:
https://github.com/catdad-experiments/libheif-js/issues/23

Full error message:

     ⚠ ../../node_modules/libheif-js/libheif-wasm/libheif-bundle.js
    Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

    Import trace for requested module:
    ../../node_modules/libheif-js/libheif-wasm/libheif-bundle.js
    ../../node_modules/libheif-js/wasm-bundle.js
    ../../node_modules/heic-decode/index.js
    ../../node_modules/heic-convert/index.js
    ./src/worker/convert.worker.ts
    ./src/utils/comlink/ComlinkConvertWorker.ts
    ./src/services/heic-convert/service.ts
    ...

Refs:
- https://stackoverflow.com/questions/38392697/webpack-umd-critical-dependency-cannot-be-statically-extracted
This commit is contained in:
Manav Rathi 2024-04-15 13:43:02 +05:30
parent 89b832d21f
commit 9eab93cfdf
No known key found for this signature in database

View file

@ -59,11 +59,21 @@ const nextConfig = {
GIT_SHA: gitSHA(),
},
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
// Customize the webpack configuration used by Next.js
webpack: (config, { isServer }) => {
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
if (!isServer) {
config.resolve.fallback.fs = false;
}
// Suppress the warning "Critical dependency: require function is used
// in a way in which dependencies cannot be statically extracted" when
// import heic-convert.
//
// Upstream issue, which currently doesn't have a workaround.
// https://github.com/catdad-experiments/libheif-js/issues/23
config.ignoreWarnings = [{ module: /libheif-js/ }];
return config;
},
};