[TIMOB-13193] TiAPI: Native JS module: support Ti.include
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2014-03-31T21:56:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android, iOS |
Labels | android, axe, include, ios, js, module |
Reporter | Carter Lathrop |
Assignee | Ingo Muschenetz |
Created | 2013-03-25T09:52:58.000+0000 |
Updated | 2017-03-22T22:53:04.000+0000 |
Description
Thanks to TIMOB-9317 we now are able to require submodules inside modules
Now it would nice to be able to use Ti.include with module compiled js files.
Test Steps
Module build
Create a new module project for Android/ios with the id com.foo.bar.
Download the attached assets.zip
Unzip assets.zip in the directory of the new module project
Run ant to build the module.
Project
Download the attached tic2043.zip and unzip it.
Import the resulting directory into TiStudio
Run project
Pass:
The test is simple, if you see "woo :)" in the console then it worked!
Attachments
File | Date | Size |
---|---|---|
assets.zip | 2013-03-25T11:22:55.000+0000 | 677 |
tic2043.zip | 2013-03-25T11:22:55.000+0000 | 2362468 |
Testing
Module build
Create a new module project for Android/ios with the id com.foo.bar. Download the attached assets.zip unzip assets.zip in the directory of the new module project run ant to build the module.Project
Download the attached tic2043.zip and unzip it. Import the resulting directory into TiStudio Run projectPass:
The test is simple, if you see "woo :)" in the console then it worked!This is a new feature request. Changing as such. Thanks for the suggestion, engineering will take a look at it. Regards, Carter
Sorry you are right, wasnt on purpose :s
Ok working with that i realised it was trickier than i though. In fact i cant rely on the context to guess where to get the file (assets or native module). It came to light while using the module. My native JS module has a method which will include a file. What you exepct is for the include to be looked for relatively from where the method was called and not relatively to the context. So what i ended up doing is simply to allow include to "look" for module in the same way require does. Ti.include('com.foo.bar/toto.js"); will look for toto.js in the module com.foo.bar (as it exists and is loaded). If you do Ti.include('/toto.js"); or Ti.include('./toto.js"); or Ti.include('toto.js"); inside a module it will always look for the asset (like it was done before). I updated the test case to reflect all that I will post a pull request for that
Seems that now that it is a TIMOB ticket i cant modify it anymore :s So here is the expected pass [object ComFooBarModule] loaded [INFO] : test1 from module com.foo.bar [INFO] : test1 from app [INFO] : module tested [INFO] : test1 from app [INFO] : test1 from module com.foo.bar Now for the assets, they need to be updated as the ones in the description are not good anymore :s you can get them there [assets](https://dl.dropbox.com/u/255893/titanium/assets.zip) [tic2043](https://dl.dropbox.com/u/255893/titanium/tic2043.zip)
and here is the pull request https://github.com/appcelerator/titanium_mobile/pull/4028
We have decided that we will be deprecating support to Ti.Include, so we don't want to extend support for this behavior.
Closing ticket as "Won't Fix".