According to the document (.html), require()
function is one of the global objects/functions. But I'm having a hard time finding its source code on Github. Are they written in JS or C++? I was looking for them in project.
According to the document (https://nodejs/api/globals.html), require()
function is one of the global objects/functions. But I'm having a hard time finding its source code on Github. Are they written in JS or C++? I was looking for them in https://github./nodejs/node project.
2 Answers
Reset to default 3This seems to be it (in node/lib/internal/modules/cjs/helpers.js
).
To answer my own question, I think it's defined in loader.js. And you can see it's implemented for all modules.
It seems to be mapped to global.require
in node.js