{ "id": "150599", "key": "TIMOB-19392", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2015-08-21T07:31:02.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "issuelinks": [ { "id": "48760", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "124137", "key": "TIMOB-16078", "fields": { "summary": "Implement full NodeJS require specs so we can use NPM for modules", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": null, "updated": "2018-02-28T19:55:02.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "12305", "name": "Core", "description": "Central component of the Platform (outside of Tooling, or platform specific implementation details)" } ], "description": "There's a growing number of use cases where you would want to {{require()}} JavaScript files and image assets from a different codebase than the default {{Ti.Filesystem.resourcesDirectory}}.\r\n\r\n* [LiveViewer|https://github.com/appcelerator/appc-liveviewer-app], TiShadow and potentially LiveView.\r\n* Apps or frameworks for apps built on Titanium that let you update an app by pushing new scripts and images to it, much like [ChariTi|https://github.com/mcongrove/ChariTi], GoodBarber.com and AppMachine.com\r\n\r\nThese currently require to modify loaded JavaScript files to reroute calls to {{require()}} and paths to image assets to custom methods that look up the actual full path and use that with the original methods. This is hacky and often not that stable.\r\n\r\nh2. Desired behaviour\r\n\r\n*app.js*\r\n{code:javascript}\r\n\r\n// only once use full path\r\nvar b = require(Ti.Filesystem.applicationDataDirectory + 'foo/b');\r\n{code}\r\n\r\n*b.js*\r\n{code:javascript}\r\n\r\n// this will load relative to dirname(b.js)\r\nvar c = require('./c');\r\n\r\nvar i = Ti.UI.createImageView({\r\n // this will load relative to dirname(b.js)\r\n image: './i.png'\r\n});\r\n{code}\r\n\r\nh2. Possible solutions\r\n\r\nRequiring from a full path already works. What needs to be done is that calls to {{require()}} and image assets that start with {{./}} - like NodeJS - will be resolved relative to the directory of the JavaScript file. So somehow, our API needs to be aware of this context.\r\n\r\nThis is probably related to if not included by TIMOB-16078.", "attachment": [], "flagged": false, "summary": "Load JS files and image assets relative to a different codebase than resourcesDirectory", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "SDK 4.1.0 / master", "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }