File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -165,12 +165,18 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
165165 if ( file . exists ( ) ) {
166166 return fileExists ( file ) ;
167167 } else {
168- if ( ( file = new File ( parentDir , moduleName ) ) . exists ( ) ) {
169- return fileExists ( file ) ;
170- } else if ( ( file = new File ( parentDir , moduleName + ".js" ) ) . exists ( ) ) { // try .js extension
171- return file ;
172- } else if ( ( file = new File ( parentDir , moduleName + ".json" ) ) . exists ( ) ) { // try .json extension
173- return file ;
168+ // try appending a .js to the end
169+ pathWithJSExt = file . canonicalPath + '.js' ;
170+ file = new File ( parentDir , pathWithJSExt ) ;
171+ if ( file . exists ( ) ) {
172+ return file ;
173+ } else {
174+ file = new File ( pathWithJSExt ) ;
175+ if ( file . exists ( ) ) {
176+ return file ;
177+ }
178+ }
179+
174180 }
175181 }
176182 return null ;
@@ -244,9 +250,6 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
244250 }
245251 buffered . close ( ) ; // close the stream so there's no file locks
246252
247- if ( canonizedFilename . substring ( canonizedFilename . length - 5 ) === ".json" ) // patch code when it is json
248- code = "module.exports = (" + code + ");" ;
249-
250253 moduleInfo = {
251254 loaded : false ,
252255 id : canonizedFilename ,
You can’t perform that action at this time.
0 commit comments