Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @babel/core#parse instead of @babel/parser#parse #6206

Closed
dennari opened this issue Jun 28, 2018 · 1 comment
Closed

Use @babel/core#parse instead of @babel/parser#parse #6206

dennari opened this issue Jun 28, 2018 · 1 comment
Labels
type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change

Comments

@dennari
Copy link
Contributor

dennari commented Jun 28, 2018

Summary

Gatsby parses a project's source files multiple times:

  1. To load the possible configuration files (e.g. gatsby-node.js)
  2. To parse the GraphQL queries
  3. To generate the javascript that's run on the site (through Webpack and babel-loader)

Cases 1. and 2. use @babel/parser with a hardcoded set of parser plugins (different from babel-plugin-x). Ideally, they would use the same configuration mechanism as 3 (custom .babelrc for example). There's a separate, recently added and so far undocumented, parse method in @babel/core which would allow exactly this.

Motivation

This would allow, for example, using TypeScript, or any other compile-to-js language supported by Babel, in the configuration files. It would also simplify plugins like gatsby-plugin-typescript, which wouldn't need to implement the preprocessSource api.

Here's a similar discussion in the babel-eslint project: babel/babel-eslint#573

@pieh pieh added the type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change label Jun 28, 2018
@KyleAMathews
Copy link
Contributor

Done in v2 I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change
Projects
None yet
Development

No branches or pull requests

3 participants