I'm not exactly clear about what you want to achieve.
For one, the C code you looked at is to figure out when executing at run time wether the module is a built-in module, and built-in means being a part of the flashed ...bin.
On JavaScript upload, the IDE knows when parsing the code before actual upload whether the required module is built-in and has not to be pulled from somewhere and uploaded or not.
Currently, no modules are pulled from Espruino at runtime. They are all expected to be built-in, cached in Modules, or on (connected) SD card. In your case you may connect an SD card and use a string variable with the module name as value in the require() rather than a literal - single or double quoted - string.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm not exactly clear about what you want to achieve.
For one, the C code you looked at is to figure out when executing at run time wether the module is a built-in module, and built-in means being a part of the flashed ...bin.
On JavaScript upload, the IDE knows when parsing the code before actual upload whether the required module is built-in and has not to be pulled from somewhere and uploaded or not.
Currently, no modules are pulled from Espruino at runtime. They are all expected to be built-in, cached in Modules, or on (connected) SD card. In your case you may connect an SD card and use a string variable with the module name as value in the require() rather than a literal - single or double quoted - string.