Project: titanium
Issue TIMOB-23138: Parity: On Android require() tries current folder first
Take the following app: *Resources/app.js* {code:js} Ti.UI.createWindow().open(); console.log(require('folder/foo').whoami); {code} *Resources/folder/foo.js* {code:js} exports.whoami = 'Resources/folder/foo.js'; console.log(require('foo').whoami); {code} *Resources/foo.js* {code:js} exports.whoami = 'Resources/foo.js'; {code} On iOS the console will be: {code} [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/app.js, Resource: app_js [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/folder/foo.js, Resource: folder/foo_js [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/foo.js, Resource: foo_js [INFO] Resources/foo.js [INFO] Resources/folder/foo.js {code} While on Android it will be: {code} [DEBUG] Module: Loading module: folder/foo -> Resources/folder/foo.js [INFO] Resources/folder/foo.js [INFO] Resources/folder/foo.js {code} The [documentation|http://docs.appcelerator.com/platform/latest/#!/api/Global-method-require] does mention that only on Android you can use absolute and relative paths, but it does not say that it will always try to resolve relative to the current directory first. I'd expect Android to work as iOS and *not* attempt to resolve relative to the current directory first. Ideally we'd resolve this as part of TIMOB-16078
Story points: 5