Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1597] Use babel-code-frame to provide context when failing to parse code

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-01-08T18:17:14.000+0000
Affected Version/sn/a
Fix Version/sCLI Release 7.0.2
ComponentsTooling
Labelsn/a
ReporterEwan Harris
AssigneeEwan Harris
Created2017-12-20T11:00:18.000+0000
Updated2018-01-19T00:27:47.000+0000

Description

Description

Currently when we are parsing files if we hit a parser error then we output an error that isn't super helpful, it contains an line/column numbers but it would be a much better dev experience if we could show the code using babel-code-frame. We could also expand this to xml/tss parsing errors if the modules we use give us the locations in an easily consumable way
[ERROR] Error generating AST for "/Users/eharris/Documents/projects/repotest/apps/hyperloop-examples/app/controllers/index.js"
[ERROR] Unexpected token (1:5)
[ERROR] position 5
[INFO]   controller: "index.js"
> 1 | x ==== foo
    |     ^
  2 | /**
  3 |  * I wrap code that executes on creation in a self-executing function just to
  4 |  * keep it organised, not to protect global scope like it would in alloy.js
[ERROR] Error generating AST for "/Users/eharris/Documents/projects/repotest/apps/hyperloop-examples/app/controllers/index.js"

Comments

  1. Ewan Harris 2017-12-20

    Started on https://github.com/appcelerator/alloy/pull/865
  2. Ewan Harris 2017-12-21

    Once finished in Alloy I'd like to implement this in Titanium too
  3. Abir Mukherjee 2018-01-19

    Node Version: 8.9.1 NPM Version: 5.5.1 Mac OS: 10.13.1 Appc CLI: 7.0.2-master.5 Appc CLI NPM: 4.2.11 Titanium SDK version: 7.0.1 Validated fix on 7.0.2-master.5.

JSON Source