[TIMOB-23138] Parity: On Android require() tries current folder first
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-06-10T08:05:06.000+0000 |
Affected Version/s | Release 5.2.1 |
Fix Version/s | Release 6.0.0 |
Components | Android |
Labels | notable, parity |
Reporter | Fokke Zandbergen |
Assignee | Christopher Williams |
Created | 2016-04-02T09:26:31.000+0000 |
Updated | 2017-09-19T20:25:23.000+0000 |
Description
Take the following app:
*Resources/app.js*
Ti.UI.createWindow().open();
console.log(require('folder/foo').whoami);
*Resources/folder/foo.js*
exports.whoami = 'Resources/folder/foo.js';
console.log(require('foo').whoami);
*Resources/foo.js*
exports.whoami = 'Resources/foo.js';
On iOS the console will be:
[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
While on Android it will be:
[DEBUG] Module: Loading module: folder/foo -> Resources/folder/foo.js
[INFO] Resources/folder/foo.js
[INFO] Resources/folder/foo.js
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
FT passed. PR APPROVED!
[~bimmel] see description on 'documentation'. needs to be updated.
Thanks for the heads up [~cng]. I'll add this to the docs when we get to 6.0.0 release.
Verified the fix. Android does not attempt to resolve relative to the current directory first. Closing. Environment: Appc Studio : 4.7.0.201607250649 Ti SDK : 6.0.0.v20160816021339 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-24 Node: 4.4.4 Nexus 6 - Android 6.0.1