[TIMOB-2478] Tooling: Allow Excluding JS files from Compilation
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Tooling |
Labels | cb-tooling, dr-list, parity |
Reporter | Don Thorp |
Assignee | Chris Barber |
Created | 2011-04-15T03:20:50.000+0000 |
Updated | 2017-11-10T15:27:53.000+0000 |
Description
Please create an implementation ticket for each platform once the feature has been designed.
It is sometimes desirable to exclude local javascript files from compilation as Titanium javascript. The best use case is wanting to include a JS file in a WebView's html.
See [Helpdesk 56271](http://developer.appcelerator.com/helpdesk/view/56271)
To work around this problem simply rename your .js files that you don't want processed to something like .jslocal.
The problem here is that local js libraries, such as those used with webviews, are being modified during the build process, which causes them not to work when the app is launched. While Don's suggestion to use .jslocal is a good idea, it doesn't work for multi-file libraries, as they cannot be simply dropped into the project. Thus, all the library's files would need to be renamed. This is causing our team a particular problem because we want to create video tutorials relating to including local js libraries but, as it stands, these will only serve to emphasize the issue. Also, as soon as the ticket is resolved, the tutorials will be outdated. TonyL's suggestion, which seems viable, is for there to be a directory like /local that is always excluded from the build process, and the files that it contains copied over verbatim to the packaged app.
What he said ^^
My problem was that I can't use a different name for those local .js files because it's being used by a compiled iOS library which I have to use in a Titanium iOS module, in order to use it in my app. Such library was looking for .js files in the resources folder and crashing when were not found. I solved it adding a cli hook:
Very nice!
Something working as a .gitignore file for Titanium, a .tignore file
This feature is sorely needed. Have there been any work arounds discovered other than renaming the file extension?
[~christian.j.green@gmail.com] One thing you can do that will work is put the JS files you don't want minified/encrypted into the
platform
directory. Assuming the latest Titanium SDK 5.2.1:[~cbarber] Currently the files are under
[~christian.j.green@gmail.com] Actually, I have to take it all back. I just noticed in the code that we treat all files in the
platform/android
directory the same as theResources
directory. If you look at https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/commands/_build.js#L2495-L2511 you'll see line 2505 callscopyDir
just the same asResources
on line 2438 and line 2450. This means that all JS files in the platform directory would be minified and encrypted too. We probably shouldn't be doing that to files in theplatform
directory.[~cbarber] Would it be possible to hook into the command line during build and work with the cli.ignoreFiles config property?
No, I don't think so. You could write a hook that moves all the JS files out of the project during pre-compile, then moves them back in during post-compile while also copying them to the compiled app output directory
build/android/bin/assets/Resources
. Or, you could just edit theandroid/cli/commands/_build.js
in your local Titanium SDK and just hack something in. That's probably the easiest solution, though you'll have to re-add your hack if you change the SDK you want to use.This was a breaking issue for us and so an official .tiignore file of some sort would be welcomed. We have a project which uses a large number of web resources that we copy in from another source project. Our workaround is similar to Chris's suggestion in that it deals with writing a hook. We have a build.pre.compile plugin hook which already does a lot of work copying over our files from the other project into this project, and so we added a step to create a dummy.html file containing