marcuswestin/require

__require__[<unknown path to file>] in main module

Opened this issue · 0 comments

KrawN commented

Running server on Windows:
Dependency search in __require__ fails because the path to the dependency being pasted as text to the modified main module file is created in a different way.
Due to path.resolve it is created with backslashes which being pasted as a source code is interpreted as escaping of a character. In fact the __require__ object's properties have their keys created somehow with normal slashes.
I managed to quick-fix it via changing:
code = code.replace(requireStmnt, '__require__["'+depPath+'"]')
to:
code = code.replace(requireStmnt, '__require__["'+depPath.replace(/\\/g, '/')+'"]')