Skip to content
This repository has been archived by the owner on Dec 29, 2018. It is now read-only.

Provide more helpful stack traces on failure #141

Open
shipstar opened this issue Oct 15, 2016 · 2 comments
Open

Provide more helpful stack traces on failure #141

shipstar opened this issue Oct 15, 2016 · 2 comments

Comments

@shipstar
Copy link

I am trying to get monocle running against an existing code base with ~20 components (and growing). I have run into a handful of issues and had to guess at what might have been causing them. Is it class properties (babel stage 1)? Is it exporting a stateless functional component (e.g. #125)? A simple typo that webpack handles but monocle does not?

Here's an example of the kind of error I am seeing:

Starting to strip comments from bundle file...
Took 7.455 seconds to strip comments input bundle file
/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:2223
    throw err
    ^

SyntaxError: Unexpected token (434:40)
    at Parser.pp$4.raise (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$3.parseIdent (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:2189:12)
    at Parser.pp$3.parsePropertyName (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:2052:101)
    at Parser.pp$3.parseObj (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1988:14)
    at Parser.pp$3.parseExprAtom (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1805:19)
    at Parser.parseExprAtom (/usr/local/lib/node_modules/react-monocle/node_modules/acorn-jsx/inject.js:383:24)
    at Parser.pp$3.parseExprSubscripts (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1692:19)
    at Parser.pp$3.parseExprOps (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1637:21)
    at Parser.pp$3.parseMaybeConditional (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/usr/local/lib/node_modules/react-monocle/node_modules/acorn/dist/acorn.js:1597:21)

I am not sure if it is feasible, but it would be helpful if monocle could produce a bit more information about what file or component it is failing to parse successfully. That might allow me to be make more educated guesses about what to change. Ideally, monocle would be able to handle the code base as-is, but improved feedback would make it easier for me to be self-sufficient.

Thanks!

@mbchoa
Copy link
Member

mbchoa commented Dec 28, 2016

Thanks for the feedback @shipstar. Yes, we definitely do agree that we have a lot of work to do with regards to providing the developer with more helpful feedback on error.

Right now, as it is, Monocle makes a great deal of assumptions about the codebase that it's going to try and parse through and so there are many edge cases that we certainly haven't accounted for.

We tried to mitigate some of these edge cases, for example, by trying to enforce some restrictions on the types of compilers/bundlers that we support.

Still lots of work to do! The tool is still very much in its infancy, but thank you giving it a try! Will try to be more responsive and try to address some of these big issues soon.

@FabianSchurig
Copy link

Facing exactly the same problem. I have also around 20 components.

I am using facebooks create react app and I run my project in developer mode to get the un-minified bundle.js which I then saved in the root of my project.

$ monocle -b bundle.js -j js -d ./src/
Starting to strip comments from bundle file...
Took 93.453 seconds to strip comments input bundle file
C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:2223
    throw err
    ^

SyntaxError: Unexpected token (79:34)
    at Parser.pp$4.raise (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp$3.parseIdent (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:2189:12)
    at Parser.pp$3.parsePropertyName (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:2052:101)
    at Parser.pp$3.parseObj (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:1988:14)
    at Parser.pp$3.parseExprAtom (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:1805:19)
    at Parser.parseExprAtom (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn-jsx\inject.js:383:24)
    at Parser.pp$3.parseExprSubscripts (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:1692:19)
    at Parser.pp$3.parseExprOps (C:\Users\Fabi\AppData\Roaming\npm\node_modules\react-monocle\node_modules\acorn\dist\acorn.js:1637:21)

Is there any progress so far? Or any hint, maybe some of my parameters are wrong?

Is there a possibility to cache the stripped bundle.js?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants