awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Critical dependency: the request of a dependency is an expression

revmischa opened this issue · comments

NextJS fails to build

Critical dependency: the request of a dependency is an expression
Import trace for requested module:
../../node_modules/.pnpm/aws-crt@1.14.1/node_modules/aws-crt/dist/native/crt.js
../../node_modules/.pnpm/aws-crt@1.14.1/node_modules/aws-crt/dist/index.js
../../node_modules/.pnpm/@aws-sdk+util-user-agent-node@3.118.0/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
../../node_modules/.pnpm/@aws-sdk+util-user-agent-node@3.118.0/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
../../node_modules/.pnpm/@aws-sdk+client-cloudformation@3.121.0/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.js
../../node_modules/.pnpm/@aws-sdk+client-cloudformation@3.121.0/node_modules/@aws-sdk/client-cloudformation/dist-cjs/CloudFormationClient.js
../../node_modules/.pnpm/@aws-sdk+client-cloudformation@3.121.0/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js

I don't have any issues building a project that depends on the crt module using pnpm. Lacking further information, I don't see anything actionable here.

commented

This is happening because there is a dynamic require statement in lib/native/binding.js (here).

Since the array is dynamic, Webpack warns since it can't full trust that it's bundling all the necessary code. I believe this might also be affecting source map generation (something I'm looking into right now):

https://stackoverflow.com/a/72653718

Would it be possible to either hardcode search_paths (what the code seems to be iterating over) so we can still search all of them but get the benefits of Webpack's static analyzer?

commented

Just confirmed this does not block generating source maps. Still might be best practice for prod to not expose dynamic imports, but leave that up to y'all!