Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1698] Compile: Errors thrown during sourcemap step are not visible to a user

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-08-20T21:48:43.000+0000
Affected Version/sAlloy 1.14.0
Fix Version/sCLI Release 7.1.1, Alloy 1.14.1
Componentsn/a
Labelsregression
ReporterEwan Harris
AssigneeSamuel Haig
Created2019-07-22T14:48:59.000+0000
Updated2019-08-20T21:48:43.000+0000

Description

Description

*This is a regression due to ALOY-1629, as babel became stricter on syntax being "more correct. There's nothing we can do to stop this being thrown, other than backing that out which imo we shouldnt do. We should prefer correctness* When we hit an error in the parsing of code in the sourcemap step we currently log it a trace level and rethrow it. This doesn't really help a user figure out what's wrong, we should handle it similarly to other babel processing errors where we construct a codeframe for the error and log that to give a user some context as to what the error is We should be able to achieve this by using the [dieWithCodeFrame](https://github.com/appcelerator/alloy/blob/c63914c87610bcd1bc0e8be3426b160783a0991e/Alloy/utils.js#L535) function from utils, as the error is thrown by babel we should have the required info

Steps to reproduce

1. Add the below to a file under lib
function getStoredAnswers() {

}

function getStoredAnswers() {
	
}
2. Run a build for any platform

Actual

The build errors with a stacktrace, but no real useful info

Expected

The build should error with a codeframe to try and point a user to the right location and what the error is

Comments

  1. Ewan Harris 2019-08-14

    PR: https://github.com/appcelerator/alloy/pull/935
  2. Lokesh Choudhary 2019-08-20

    FR Passed. Better error is shown with the fix: e.g
       [ERROR] :  Error parsing code in app/lib/test.js. Identifier 'getStoredAnswers' has already been declared (9:9)
       [ERROR] :  7 |
       [ERROR] :  8 |
       [ERROR] :  >  9 | function getStoredAnswers() {
       [ERROR] :  |         ^
       [ERROR] :  10 |
       [ERROR] :  11 |
       [ERROR] :  12 |
       [ERROR] :  Alloy compiler failed
       [ERROR] Application Installer abnormal process termination. Process exit value was 1
       
    Closing. Studio Ver: 5.1.3.201907112159 SDK Ver: 8.1.1.v20190820115323 OS Ver: 10.14.5 Xcode Ver: Xcode 11.0 Appc NPM: 4.2.14 Appc CLI: 7.1.1-master.5 Daemon Ver: 1.1.3 Ti CLI Ver: 5.2.1 Alloy Ver: 1.14.1 Node Ver: 10.16.1 NPM Ver: 6.9.0 Java Ver: 10.0.2 Devices: ⇨ google Pixel (Android 9)

JSON Source