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.

Custom .babelrc config does not work on 9.4.0

See original GitHub issue

Bug report

When using custom configs in next.config.js and a custom .babelrc file, the custom babel config is not applied.

Describe the bug

I have custom configs in next.config.js and am using a custom .babelrc and this plugin to load it. On next@9.3.6, this worked perfectly fine for me. However, when I upgraded to version 9.4.0, it stopped working.

I made some structural changes to my app and realized that I could just use the built-in custom .babelrc approach as outlined in the docs here. However, when I used this method on version 9.3.6, it no longer applies my custom babel config. It also does not work on version 9.4.0.

All I do is add some plugins in the .babelrc.

When I run the development server, I see the following in my terminal. It states that a custom .babelrc is being used; however, it states it after the app begins compiling.

Screen Shot 2020-05-11 at 11 54 54 AM

When I add this line to next.config.js, it works again.

defaultLoaders.babel.options.configFile = path.resolve(__dirname, '.babelrc');

To Reproduce

  1. Create a next app with next.config.js and .babelrc at root
  2. Add a plugin like @babel/plugin-transform-flow-strip-types to .babelrc and add a file with flow types
  3. Run the app in dev mode
  4. See that the custom .babelrc is not applied (i.e. flowtypes are not stripped, resulting a compilation error)

Expected behavior

Custom .babelrc should be applied and, in the above example, flowtypes should be stripped and the app should compile successfully.

System information

  • OS: macOS
  • Version of Next.js: 9.4.0
  • Version of Node.js: 12.16.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ldthornecommented, May 11, 2020

I’m having a seemingly similar issue, though my project was working in 9.3.6 and stopped working when I upgraded to 9.4.0. I have a custom .babelrc with the following contents:

{
  "plugins": ["lodash"],
  "presets": [
    [
      "next/babel",
      {
        "preset-env": {
          "targets": "> 0.25%, Safari >= 10, iOS >= 10"
        },
        "styled-jsx": {
          "plugins": ["styled-jsx-plugin-postcss"]
        }
      }
    ]
  ]
}

With that configuration, when I run yarn dev, which runs my custom server (can provide code if you need it, but it’s very basic), it hangs with wait - compiling.... If I remove the following from the .babelrc the app compiles, but obviously most of my styling breaks:

"styled-jsx": {
  "plugins": ["styled-jsx-plugin-postcss"]
}

Using Next.js 9.4.0 / Node 12.13.0. Let me know what other information you need.

0reactions
balazsorban44commented, Jan 30, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom .babelrc config does not work on 9.4.0 #12740 - GitHub
Bug report When using custom configs in next.config.js and a custom .babelrc file, the custom babel config is not applied.
Read more >
Configure Babel
Create a file called babel.config.json with the following content at the root of your project (where the package.json is). ... Check out the...
Read more >
babel-preset-env not changing build size - Stack Overflow
I have an ES6 React app that is being bundled with webpack and using babel. I am configuring babel-preset-env, for node everything is...
Read more >
Changelog - Cypress Documentation
Fixed an issue where the Cypress migration wizard would fail to run in ... Angular component testing projects can provide a custom configuration...
Read more >
babel-loader - npm
Install · Usage · Troubleshooting · Customize config based on webpack target · Customized Loader · License · Keywords.
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