[TIMOB-20346] Cant load certain NPM modules because of Syntax
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2016-02-10T04:45:59.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Creative |
Assignee | Chris Barber |
Created | 2015-12-29T08:17:21.000+0000 |
Updated | 2017-04-04T15:08:52.000+0000 |
Description
Lets take a practical example: we use
mocha.js
using npm, but as soon as we try to compile the project, it fails because of some JS syntax error in the tests
directory of this module (for instance, I got an error like ' # is not a valid expression', or something related).
My npm modules reside in app/lib/node_modules/..
so I can access them in my app. I have another node_modules in the root of my project, for modules like Grunt
(since those didnt compile either because of the JS checking) and I dont need those in the runtime.
Please do not suggest ti-mocha since that is not the issue here.
error example:
Hello, If you don't actually show a simple test case (not your whole app) we can't run that exhibits the problem, the best anyone can do is make guesses. AST errors will generally tell you exactly what line and in what file they occur in. That should show you exactly where the error in your code is. Again, the best anyone can do is guess based on the single line of error log you provided and the fact that you haven't yet shared the full error output. So, Provide a sample test case which causing the error. Provide full platform information and component versions. Provide the full error log. And descrive the problem thoroughly. Thanks.
Do you even read bug reports? Just make a js-file somewhere in your app directory so it gets compiled when you build the app. Make sure the file starts with
or some other expression with a pound/hash-symbol. Basically loading a specific NPM module causes the same issue since that just downloads a pack of js-files into your app. Although this is not valid javascript, a lot of npm modules use this notation for some unix reason. It cant be compiled by uglify. A solution here would be that you can ignore specific files by just copying them over instead of compiling them.
I tried your way. I created a js file with the name of "#test.js". I put it on the resource directory. The app compiles fine. No Error or exceptions. Tested with SDK 5.1.2.GA. Thanks.
yes you dont read bug reports carefully. Now Try again with the line: TESTCASE (put this in any .js file on the 1st line for instance):
This is used in quite some npm modules and it prevents us from compiling. Thanks.
Titanium only supports standard JavaScript files. Files that begin with a shebang/hashbang are not standard JavaScript files. The shebang is a Unix-specific character sequence that is not supported by ECMAScript standard. We have no plans to support this. You will need to strip the shebang line, remove the .js extension, or remove the file altogether.
Closing ticket as Won't Fix with reference to the above comments.
[~uzbbert] Well, Uglify is only part of the problem. I reiterate my comment above. I will take a look at ALOY-1540.