File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ mod.prototype.require = function (name) {
162162
163163 /* Try to load it with NodeJS first */
164164 try {
165- return node_require . apply ( this , [ name ] ) ;
165+ return node_require . apply ( this , [ require . resolve ( name ) ] ) ;
166166 } catch ( e ) {
167167 if ( e . code !== 'MODULE_NOT_FOUND' ) {
168168 throw e ;
@@ -184,12 +184,15 @@ mod.prototype.require = function (name) {
184184
185185 /* If there is no extension or the extension is not supported or it is 'node', load it with NodeJS require */
186186 try {
187- /* Cache the port */
188- if ( require . resolve ( name ) === path . resolve ( __filename ) ) {
187+ const filename = require . resolve ( name ) ;
188+
189+ /* Cache the port (detect if this file is being loaded) */
190+ if ( filename === path . resolve ( __filename ) ) {
189191 return module_exports ;
190192 }
193+
191194 /* Call to real NodeJS require */
192- return node_require . apply ( this , [ name ] ) ;
195+ return node_require . apply ( this , [ filename ] ) ;
193196 } catch ( e ) {
194197 /* If it is not a NodeJS module, try to guess the runtime */
195198 const loaders = new Set ( Object . values ( tags ) ) ;
You can’t perform that action at this time.
0 commit comments