[ALOY-1698] Compile: Errors thrown during sourcemap step are not visible to a user
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-08-20T21:48:43.000+0000 |
Affected Version/s | Alloy 1.14.0 |
Fix Version/s | CLI Release 7.1.1, Alloy 1.14.1 |
Components | n/a |
Labels | regression |
Reporter | Ewan Harris |
Assignee | Samuel Haig |
Created | 2019-07-22T14:48:59.000+0000 |
Updated | 2019-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 infoSteps 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 infoExpected
The build should error with a codeframe to try and point a user to the right location and what the error isComments
- Ewan Harris 2019-08-14 PR: https://github.com/appcelerator/alloy/pull/935
- Lokesh Choudhary 2019-08-20
FR Passed.
Better error is shown with the fix:
e.g
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)[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