I am trying to bundle a node application into a single file.
However after inspecting the output of webpack after the bundling.
I found that one of the libraries uses Module.createRequire to load some module at runtime.
Inspecting the bundled code I understood that webpack doesn't replace Module.createRequire(path).resolve by __webpack_require__ , which results in my application depending on node_module after being bundled.
I can think of a simple solution by modifying the code of the library and use require instead of Module.createRequire. But I prefer not to modify the library code cause that would add extra headache every time I want to update the library.
Secondly I am wondering if I replaced the following code Module.createRequire(myPath) by require(myPath) according to Webpack Context would webpack bundle all of the node_modules as the resulting expression * would match with all the modules ?