Webpack build warning
ChristopherGillis opened this issue · 4 comments
Repeatedly seeing this warning:
Warning: in ../../../node_modules/aws-crt/dist/native/binding.js 59:18-31
Critical dependency: the request of a dependency is an expression
I see a related PR that is closed, but as of latest release, still seeing the error. #220
I have aws-crt@1.15.13
installed as a dependency of @aws-sdk/credential-provider-node@3.297.0
What exactly are you trying to build? Is this warning preventing you from useing this dependency?
We have the browser samples working for aws-iot-device-sdk-js-v2 with webpack, so this should be working for you
I get the same warning building with NextJS.
FWIW the aws-crt still works this warning is just cluttering up the logs.
I am able to work around this issue by suppressing the warning as described here.
My updated next.config.js excerpt:
const webpack = require("webpack");
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.plugins.push(
new webpack.ContextReplacementPlugin(/\/aws-crt\//, (data) => {
delete data.dependencies[0].critical;
return data;
})
);
return config;
},
};
module.exports = nextConfig;
The native addon is loaded from a path computed dynamically based on the local host's architecture and OS properties. So on the surface this isn't something we can "fix."
You can suppress the warning using the solution above.
Another alternative is to use the browser distribution which does not need to load the native addon. In our browser samples, the redirection is found in the tsconfig: https://github.com/awslabs/aws-crt-nodejs/blob/main/samples/browser/http/tsconfig.json#L39-L41
The caveat about the browser implementation is that it does not contain Sigv4a support (AWS authentication that uses ECDSA signatures)