Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9317] Module Projects: Support multiple Javascript files

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-08-16T15:11:06.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sSprint 2012-17 Core, Release 3.0.0
ComponentsTiAPI
Labelscore
ReporterBill Dawson
AssigneeBill Dawson
Created2012-05-30T15:31:24.000+0000
Updated2017-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.

Comments

  1. Stephen Tramer 2012-06-13

    Created subtask for iOS. According to mobileweb, require() for modules should work like node.js (of course) where for the library with ID module.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'.
  2. Stephen Tramer 2012-06-13

    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 to require(subpath/lib).
  3. Chris Barber 2012-06-13

    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.
  4. Bill Dawson 2012-08-16

    all child items resolved. Resolving...
  5. Lee Morris 2017-03-24

    Closing ticket as fixed with reference to previous comments.

JSON Source