You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a NestJS based API right now which uses the library nestjs-zod for schema based validation and that library in turn uses merge-deep which in turn uses clone-deep. That's in it self not a problem, but the problem arises when I'm trying to use NestJS within a Monorepo and therefore having to use Webpack in combination with the swc-loader loader.
The error message is something like the following:
ERROR in ../../node_modules/clone-deep/utils.js 13:0-28
Cannot statically analyse 'require(…, …)' in line 13
@ ../../node_modules/clone-deep/index.js 7:12-30
@ ../../node_modules/merge-deep/index.js 11:12-33
@ ../../node_modules/nestjs-zod/dist/index.js 6:16-37
After a long night of googling-around, I found this Stackoverflow answer:
And that does the trick. Now Webpack can statically analyse the require function once again and the build goes through no problem.
This re-assignment of the require function seems to be happen more often, as I found another Issue where one reported the same problem but within another library. See:
Hej,
I'm building a NestJS based API right now which uses the library
nestjs-zod
for schema based validation and that library in turn usesmerge-deep
which in turn usesclone-deep
. That's in it self not a problem, but the problem arises when I'm trying to use NestJS within a Monorepo and therefore having to use Webpack in combination with theswc-loader
loader.The error message is something like the following:
After a long night of
googling-around
, I found this Stackoverflow answer:https://stackoverflow.com/questions/69898244/cannot-statically-analyse-require-in-line-16
and reading his answer I looked at the failing
clone-deep
source code within theutils.js
where you find the following source-code:And having read the Stackoverflow answer I changed the re-assignment of the
require
to something like this:And that does the trick. Now Webpack can statically analyse the require function once again and the build goes through no problem.
This re-assignment of the
require
function seems to be happen more often, as I found another Issue where one reported the same problem but within another library. See:webpack/webpack#15136
Should I open a Pull request for this or do you think it should be handled differently?
The text was updated successfully, but these errors were encountered: