Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #308
vladmandic
started this conversation in
General
Replies: 1 comment
-
Example of webpack configuration inside
/** @type {import('next').NextConfig} */
module.exports = {
...
webpack: (config, options) => {
config.module.rules.push({ test: /human.esm.js/, type: 'javascript/esm' });
return config
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
WebPack version 5 changed how it handles dynamic imports
Human
library itself does not use dynamic imports, but bundled TensorFlow/JS inhuman.esm.js
includes some additional platform-specific capabilitiesFor example, WASM binaries can be loaded using filesystem read file calls, but only when platform is NodeJS
Presence of those dynamic capabilities detection calls causes WebPack to misinterpret type of a library used and generate warning messages:
Note that this is NOT AN ERROR, but simply a
WebPack
warning that can be safely ignored.However, if you want to eliminate such warnings,
solution is to explicitly specify in
WebPack
configuration thatHuman
is an ESM library:in
webpack.config.js
add:Note that WebPack is internally used by many frameworks and location of the config file may differ between frameworks (React, Angular, Vue, Next, etc.)
To see how to modify WebPack configuration in cases when non-default configuration files are used, check framework specific documentation.
Beta Was this translation helpful? Give feedback.
All reactions