magic-js: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
π Description
When upgrading from magic-sdk v6.2.1 to magic-sdk v8.1.0 within a perfectly working VueJS3 project, I am getting this warning when serving my app (yarn serve):
WARNING Compiled with 1 warning
warning in ./node_modules/magic-sdk/dist/es/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
π Environment
Software | Version(s) |
---|---|
magic-sdk |
8.1.0 |
Browser | Chrome |
yarn |
1.22.17 |
Operating System | Windows |
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (9 by maintainers)
@Ethella I have a fix for react using CRACO
For pure webpack I believe
alias
is nested withresolve
β¦resolve.alias...
These would be helpful to add to your documentation
I was about to say I found no issues reported during the build because you already fixed it π.
Iβll update our doc to reflect your suggestion. Thx a lot!
Thank you for the code sample @Adamj1232. Iβm off-the-clock this week but will make time for this early next week.
@Adamj1232 It worked! Thanks again. Here is the full snippet for node js using webpack (make sure to update mode, entry, and output per your project).
@andreisucman you would have to look into the documentation for the compiler you are using.
After digging into this issue a bit, the warning appears to be related to this code being inlined into
magic-sdk
βs ESM output:This could either be resolved at the ESBuild layer, but can be worked around for your individual purpose by adjusting your bundler config to resolve
magic-sdk
to its CommonJS entrypoint (magic-sdk/dist/cjs/index.js
), which wonβt manifest this warning. It is also valid to ignore this warning using whatever API/plugin your bundler provides to silence noisy logs. This warning in context ofmagic-sdk
will not manifest any bugs at runtime.