You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gatsby parses a project's source files multiple times:
To load the possible configuration files (e.g. gatsby-node.js)
To parse the GraphQL queries
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.
Summary
Gatsby parses a project's source files multiple times:
gatsby-node.js
)Cases 1. and 2. use
@babel/parser
with a hardcoded set of parser plugins (different frombabel-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 thepreprocessSource
api.Here's a similar discussion in the babel-eslint project: babel/babel-eslint#573
The text was updated successfully, but these errors were encountered: