[TIMOB-9317] Module Projects: Support multiple Javascript files
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-08-16T15:11:06.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Sprint 2012-17 Core, Release 3.0.0 |
Components | TiAPI |
Labels | core |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2012-05-30T15:31:24.000+0000 |
Updated | 2017-03-24T20:57:23.000+0000 |
Description
Currently, iOS, Android and Mobile Web module projects will really only support runtime execution of code from just one Javascript file in the module project. In the case of mobileweb, it's src/modulename.js, and in the case of Android and iOS it's assets/moduleid.js. Though you can put as many JS files as you want in those folders (and they will be packaged and delivered), at runtime only the "expected" single module file is reachable (i.e., via require()).
We would like to support require()ing (or AMD'ing in the case of mobileweb) the other packaged js files as well. We should discuss what this looks like at runtime and what the expectations are, and come up with a test case. Then create sub-tasks per platform.
MobileWeb will likely go forward quickly as their platform seems to be better suited for doing this. Android/iOS will need to grapple with runtime contexts, and getting this to work in native compiled code. In general it seems a hairier problem for Android/iOS.
Created subtask for iOS. According to mobileweb,
require()
for modules should work likenode.js
(of course) where for the library with IDmodule.id
: *require('module.id')
requires the "main" JS file (the JS file named 'module.id.js') *require('module.id/subpath/lib')
requires the file 'lib.js' which is in the module's relative hierarchy './subpath'.ALSO, in a module file, it should be positioned 'relative' to the root of the module. So for example, the
module.id.js
file would be able torequire(subpath/lib)
.It's worth noting that the "main" JS file should be defined in a package.json file, however, it would work just standardizing on a convention that the main JS file shares the same name as the module. If a module requires another module, it does not need to specify the "module.id". So if module.id.js needed to require module.id/subpath/lib.js, it could simply require("subpath/lib") or require("./subpath/lib") or require("/subpath/lib"). All absolute module ids are rooted to the module's src directory.
all child items resolved. Resolving...
Closing ticket as fixed with reference to previous comments.