Open jcwillox opened 10 months ago
Thanks a bunch for pointing out this issue and suggesting a cool fix! I appreciate your help in making the library better. Your solution looks like a great way to tackle the problem, and I'd be stoked if you could submit a pull request for it 😃
I'm submitting a...
Current behavior
The app fails to start when bundling with webpack, even if you exclude
class-validator
from bundling.Webpack copies the https://github.com/Nikaple/nest-typed-config/blob/main/lib/utils/imports.util.ts directly into the bundle, except it tries to replace the
require
call but can't resolve the dependency, so instead replaces it with an empty context, which causes therequireFromRootNodeModules
to throw an exception when starting.I created a basic patch that looks to fix the issue
Besides the
requireFromRootNodeModules
, theloadPackage
function also causes issues with webpacks resolution, while it's a convenient shorthand i'd suggest inlining it instead to avoid the issue.You could still have some sort of utility function if you want, like
Expected behavior
Support being bundled
Minimal reproduction of the problem with instructions
Set
externals: []
in your webpack configWhat is the motivation / use case for changing the behavior?
Environment