babel / babylon

PSA: moved into babel/babel as @babel/parser -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to enable debug output?

jslz opened this issue · comments

commented

This is all in the context of using React Native.

Expected Behavior

When babylon hits an error, it should give enough information in the error for humans to trace back to the problem in the sources.

  1. any way to show the original file name and source line?
  2. show the code around the error like +/- 20 lines.
  3. show the token encountered, not just the expected one.

Current Behavior

Error from babylon doesn't given enough context to know where the error is in the original source files.

transform[stderr]: SyntaxError: Unexpected token, expected , (104:13)
transform[stderr]:     at Parser.pp$5.raise (/Users/x/node_modules/babylon/lib/index.js:4454:13)
transform[stderr]:     at Parser.pp.unexpected (/Users/x/node_modules/babylon/lib/index.js:1761:8)
transform[stderr]:     at Parser.pp.expect (/Users/x/node_modules/babylon/lib/index.js:1749:33)
transform[stderr]:     at Parser.pp$3.parseObj (/Users/x/node_modules/babylon/lib/index.js:3978:12)
transform[stderr]:     at Parser.pp$3.parseExprAtom (/Users/x/node_modules/babylon/lib/index.js:3719:19)
transform[stderr]:     at Parser.pp$3.parseExprSubscripts (/Users/x/node_modules/babylon/lib/index.js:3494:19)
transform[stderr]:     at Parser.pp$3.parseMaybeUnary (/Users/x/node_modules/babylon/lib/index.js:3474:19)
transform[stderr]:     at Parser.pp$3.parseExprOps (/Users/x/node_modules/babylon/lib/index.js:3404:19)
transform[stderr]:     at Parser.pp$3.parseMaybeConditional (/Users/x/node_modules/babylon/lib/index.js:3381:19)
transform[stderr]:     at Parser.pp$3.parseMaybeAssign (/Users/x/node_modules/babylon/lib/index.js:3344:19)
transform[stderr]: /Users/x/node_modules/babylon/lib/index.js:4457
transform[stderr]:   throw err;
transform[stderr]:   ^

Your Environment

I am using

    "react-native": "~0.46.0",
    "babel-cli": "^6.26.0",
    "babel-eslint": "^7.2.3",
    "babel-jest": "20.0.3",
    "babel-preset-flow": "^6.23.0",
    "babel-preset-react-native": "^1.9.2",
    "babel-preset-react-native-stage-0": "^1.0.1",
software version
node v6.11.1
npm 5.3.0
Operating System Mac OS X 10.12.6
{
  "presets": [
    "react-native-stage-0/decorator-support"
    // "react-native" // this is required for debugging with react-native/packager/transformer    
  ],
  "plugins": [
    // "transform-decorators"    
  ]
  // "sourceMaps": true // must be true react-native/packager/transformer using with node-module-debug
  // because of some bugs from vscode-node-debug & vscode-react-native, "sourceMaps" cannot be "inline" or "both"
}
commented

Hey @jslz! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

This looks like an error in Babylon itself. Could you please provider the input source?

commented

@xtuc thank you for your attention & offer to look. Unfortunately I can't share the full code. Our guess is that it was due to this below, but I don't now for sure.

const s = StyleSheet.create({		
 host__separator: {		
   left: 10 + 85,		
 		
   marginTop: 10,		
 		
   width: width - (10 - 85),	// this line	
   height: 1,		
 		
   backgroundColor: '#E5E5EA',		
 },
});