ef4 / ember-browserify

ember-cli addon for easily loading CommonJS packages from npm via browserify.
MIT License
172 stars 28 forks source link

Better error message when we can't parse a file #36

Closed ryanbillingsley closed 9 years ago

ryanbillingsley commented 9 years ago

Updated to Ember 0.12.1 and started seeing this on start up:

Line 3: Missing from after import
Error: Line 3: Missing from after import
    at throwError (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:2134:21)
    at parseImportDeclaration (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:3533:17)
    at parseProgramElement (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:4672:24)
    at parseProgramElements (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:4712:29)
    at parseProgram (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:4759:16)
    at Object.parse (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/node_modules/esprima/esprima.js:5235:23)
    at parseImports (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/lib/stub-generator.js:116:23)
    at gatherStubs (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/lib/stub-generator.js:68:17)
    at /Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/lib/stub-generator.js:31:11
    at Array.forEach (native)

Using 1.0.0

ef4 commented 9 years ago

Esprima is unable to parse one of your files. Look for a malformed import statement.

ryanbillingsley commented 9 years ago

@ef4 Is there anyway to narrow down where the offending import script could be?

ef4 commented 9 years ago

You could patch a console.log into this point of that stack trace that tells you which file it's about to parse.

at parseImports (/Users/ryanbillingsley/Dev/gambit-client/node_modules/ember-browserify/lib/stub-generator.js:116:23)
ryanbillingsley commented 9 years ago

@ef4 cool, i will give that a shot, thanks for the help

ryanbillingsley commented 9 years ago

@ef4 Found it, it was an add-on. Thanks again for the help.

ef4 commented 9 years ago

I'm going to leave this issue open so we can add a better error message here.

ramybenaroya commented 9 years ago

It happened to me too because of ember-cli-mirage upgrade. But it seems that the syntax is valid although the import parsing fails. The line is import baseConfig, { testConfig } from '../mirage/config';

asakusuma commented 9 years ago

Just tried this with 1.0.1 (which now uses acorn instead of esprima) and it appears that acorn throws a much nicer error, complete with filename, line number, and column

File: dummy/components/feed-hero.js
dummy/components/feed-hero.js: Unexpected token (3:10)
SyntaxError: dummy/components/feed-hero.js: Unexpected token (3:10)
  1 | import Ember from 'ember';
  2 | 
> 3 | importzzz from 'bad import statement';
    |           ^
  4 | 
  5 | export default Ember.Component.extend({});

@ramybenaroya, can you upgrade to 1.0.1 and see if that fixes your import parsing error?

ramybenaroya commented 9 years ago

Works great after upgrading. Thanks.

asakusuma commented 9 years ago

Closing as the parsing imports error is fixed and we now have better error messages.