question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose Babel config for Gatsby

See original GitHub issue

Summary

Exposing Gatsby’s Babel configuration would allow Gatsby apps to integrate with 3rd party tooling like linters and testing frameworks. There are two options for accomplishing this, making Gatsby’s config a babel preset, or printing a .babelrc file in root of project (or somewhere else).

Motivation

Currently getting testing or linting configuration requires essentially copying what Gatsby does into your own .babelrc file, at this point it would be much cleaner and easier on the user to just install and include babel-preset-gatsby.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
Tomekmularczykcommented, Aug 22, 2018

Yeah, same here. Some tools require babel-config available like babel-plugin-react-intl. The same if I wanted to create my own tool that relies on babel and I don’t necessarily want it in my build system (by extending webpack config).

I see that most of examples and even documentation suggests copying specific presets and plugins. But this is less than optimal and more like a workaround I believe. It will make harder to migrate app to newer versions. Specifying packages in config that are not installed explicitly by user is also fragile I think.

What I would ideally see is something like they do in NextJS. If you want a custom .babelrc you create a file with a nextjs preset which has all that is necessary to work by a framework:

.babelrc

{
  "presets": [
    "next/babel"
  ]
  ...
}
3reactions
kkemplecommented, Jun 29, 2018

Yeah, I think it makes sense expose it as a preset so it’s really easy to configure with tooling. I hit issues with Storybook as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Babel | Gatsby
Gatsby ships with a default .babelrc setup that should work for most sites. If you'd like to add custom Babel presets or plugins,...
Read more >
Config Files - Babel.js
Babel can be configured using any file extension natively supported by Node.js, as mentioned in Configuration File Types section: babel.config.json and .babelrc ...
Read more >
babel-preset-gatsby - npm
This package contains the default Babel setup for all Gatsby projects.. Latest version: 3.3.1, last published: 14 days ago.
Read more >
Advanced Features: Customizing Babel Config - Next.js
Customizing Babel Config ... Next.js includes the next/babel preset to your app, which includes everything needed to compile React applications and server-side ...
Read more >
Gatsby Changelog | 5.3.0
For many years, CommonJS (CJS) was the de facto standard in Node.js. Before now, gatsby-config and gatsby-node had to be written in CJS....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found