This repository has been archived by the owner. It is now read-only.

Better error message on `unexpected token` when it's because a plugin isn't turned on #169

Closed
hzoo opened this Issue Oct 12, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@hzoo
Member

hzoo commented Oct 12, 2016

Ref #163 (comment)

Example if (!this.hasPlugin("dynamicImport")) this.unexpected(); or

Module build failed: SyntaxError: Unexpected token (1:6)

> 1 | import();
    |       ^
  2 |

If a user is using an experimental syntax and we error then we should tell them a message so it can be fixed.

We don't necessarily know they are using babel/babylon though so the error message can give some hints:

  • ask the user to turn on the corresponding plugin in babylon
  • ask the user to add the syntax/transform plugin in babel
  • ask the user to use parserOpts: { plugins: ['syntax'] }
@motiz88

This comment has been minimized.

Show comment
Hide comment
@motiz88

motiz88 Oct 14, 2016

Contributor

Going to tackle this. I'm thinking of an expectPlugin helper method to replace if (!hasPlugin(...)) unexpected(), and maybe a small map of known Babylon plugins to Babel plugins, to support helpful messages.

Contributor

motiz88 commented Oct 14, 2016

Going to tackle this. I'm thinking of an expectPlugin helper method to replace if (!hasPlugin(...)) unexpected(), and maybe a small map of known Babylon plugins to Babel plugins, to support helpful messages.

@nathanhammond

This comment has been minimized.

Show comment
Hide comment
@nathanhammond

nathanhammond Jun 7, 2017

In-progress PR: #178

nathanhammond commented Jun 7, 2017

In-progress PR: #178

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.