diff --git a/src/main/js/lib/require.js b/src/main/js/lib/require.js index 0a5d5a4..4090e1d 100644 --- a/src/main/js/lib/require.js +++ b/src/main/js/lib/require.js @@ -165,12 +165,18 @@ When resolving module names to file paths, ScriptCraft uses the following rules. if ( file.exists() ) { return fileExists(file); } else { - if ((file = new File(parentDir, moduleName)).exists()) { - return fileExists(file); - } else if ((file = new File(parentDir, moduleName + ".js")).exists()) { // try .js extension - return file; - } else if ((file = new File(parentDir, moduleName + ".json")).exists()) { // try .json extension - return file; + // try appending a .js to the end + pathWithJSExt = file.canonicalPath + '.js'; + file = new File( parentDir, pathWithJSExt ); + if (file.exists()) { + return file; + } else { + file = new File(pathWithJSExt); + if ( file.exists() ) { + return file; + } + } + } } return null; @@ -244,9 +250,6 @@ When resolving module names to file paths, ScriptCraft uses the following rules. } buffered.close(); // close the stream so there's no file locks - if(canonizedFilename.substring(canonizedFilename.length - 5) === ".json") // patch code when it is json - code = "module.exports = (" + code + ");"; - moduleInfo = { loaded: false, id: canonizedFilename,