Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16058] CLI: Perform syntax check of JavaScript files for Simulator/Emulator builds

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-01-09T18:21:02.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2014 Sprint 01, 2014 Sprint 01 Core, Release 3.3.0
ComponentsCLI
Labelscli, qe-closed-3.3.0, qe-testadded
ReporterChris Barber
AssigneeChris Barber
Created2013-12-20T16:21:23.000+0000
Updated2014-07-24T10:26:03.000+0000

Description

During device and distribution builds, we run all JavaScript code through UglifyJS and if there's a syntax error, it will stop the build. The problem is this step is not performed for simulator/emulator builds, so developers won't see the errors until runtime. This fix should also include a tiapp.xml property and CLI config option to turn off this feature.

Comments

  1. Chris Barber 2014-01-09

    Master pull request: https://github.com/appcelerator/titanium_mobile/pull/5196 3.2.x pull request: https://github.com/appcelerator/titanium_mobile/pull/5197 To test: 1. create a project for ios and android 2. replace contents of app.js with chrisrocks{}; 3. run: ti build -p android --build-only 4. observe the javascript error 5. run: ti build -p ios --build-only 6. observe the javascript error
  2. Ivan Skugor 2014-01-09

    Can we disable that option? In case we want to do syntax checking in some other way.
  3. Chris Barber 2014-01-09

    [~ivan.skugor] No, you cannot disable this. We use UglifyJS to parse the AST of your JavaScript code and detect Titanium API symbols. If you have a syntax error, then we cannot detect these symbols and include the appropriate dependencies and permissions. So, if I add a flag to bypass this, then there will probably be severe side effects that prevents your app from running. Besides, you should be writing valid JavaScript, right?
  4. Ivan Skugor 2014-01-09

    Yeah, of course, but we can validate JS code before doing build process (for example, on file save). I was just guessing build process would be a bit faster if we could disable another JS validation in cases like that. But if you need to parse JS code anyway, then I guess there won't be much difference so you can just ignore my comment :) Tnx anyway.
  5. Ivan Skugor 2014-01-09

    Just for example, when packaging large Alloy app (which, when compiled, has lots of files), Ti does syntax checking and code analysis (I guess, not really sure what it does), which in my case lasts for 15 minutes. If I could disable that, I could save a lot of time (and in most cases I'm not interested in that because app just works fine, just want to make sure production configuration/certificates work fine).
  6. Chris Barber 2014-01-09

    [~ivan.skugor] Not sure I follow. The syntax checking I'm doing should be quick. Even if you have hundreds of files, it shouldn't take that long. I suspect you are talking about the code analyzer in Studio. That will take a long time since it's running your code through a virtual JavaScript engine and analyzing it several different ways. That has nothing to do with the build process and should not be invoked.
  7. Ivan Skugor 2014-01-10

    OK then, thanks for clarification.
  8. Satyam Sekhri 2014-02-04

    Javascript error is shown during the build process. Checked on: OSX: 10.9.1 CLI: 3.2.1-beta3 Appcelerator Studio: 3.2.1.201401311225 Titanium SDK: 3.2.1.v20140130101648, 3.3.0.v20140202230850
  9. Olga Romero 2014-04-28

    Tested and verified CLI performance of syntax check of JavaScript files for Simulator/Emulator builds Environment: Mac osx 10.9.2 Mavericks Appcelerator Studio, build: 3.3.0.201404221437 Titanium SDK, build: 3.3.0.v20140425191906 Node.JS Version: v0.10.13 NPM Version: 1.3.2 ├── acs@1.0.14 ├── alloy@1.4.0-dev ├── npm@1.3.2 ├── titanium@3.3.0-dev └── titanium-code-processor@1.1.1-beta1

JSON Source