About require function #49345
raccoon666666
started this conversation in
Ideas
Replies: 2 comments
-
require() resolves paths relative to the module that calls it. A single global require() doesn't know what module calls it, not in enough detail to function properly. It's technically possible to reconstruct the caller's details through V8's C++ API but that's slower and more complicated than an IIFE. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for your help. I think, there is still a lot details of modular implementation of Nodejs to learn for me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Node packaged the
.js
file as IIFE and passed inrequire
as a parameter.My question is >>
Why is it necessary to pass in the require function and directly use the global require function?
Isn't it the same?
Beta Was this translation helpful? Give feedback.
All reactions