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.

Unexpected Babel configuration behavior

See original GitHub issue

The babel config override will override the loaderOptions, presets, and plugins for both of the babel-loader rules CRA has.

It seems like the second loader shouldn’t receive the presets and plugins by default, since the second loader is meant for:

// Process any JS outside of the app with Babel. // Unlike the application JS, we only compile the standard ES features.

I would argue the behavior is unexpected since only files in src/ are supposed to get babel-preset-react-app and previously tools such as react-app-rewired only modified the first loader

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
patricklafrancecommented, Nov 25, 2018

Hi @d3dc

This is indeed an easy fix if you want to customize what’s being configured for the files outside of the src/ directory.

I might wait before updating any code for this one since I don’t want to break anyone setup.

How could craco’s configuration be modified to accommodate your usecase?

Maybe an applyToExternalFiles boolean option with a default value of true ? Not sure though if it wouldn’t be more confusing than helping?

{
   babel: {
        presets: [],
        plugins: [],
        loaderOptions: { }
        applyToExternalFiles: true
   }
}
0reactions
patricklafrancecommented, Dec 5, 2018

Will be fix in #49

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected Babel configuration behavior · Issue #36 - GitHub
My use case is a little out of the ordinary - I'm trying to package my whole toolkit with a customized craco config...
Read more >
FAQ - Babel.js
Babel assumes that all input code is an ES2015 module. ES2015 modules are implicitly strict mode so this means that top-level this is...
Read more >
Babel is examining the package.json of a target module for ...
Babel 6 was very aggressive about reading config files, which was an issue for exactly the reasons you are running into. Babel 7...
Read more >
Babel - Storybook
Storybook's webpack config by default sets up Babel for ES6 transpiling. It has three different modes: CRA - the mode for Create React...
Read more >
syntaxerror unexpected token export babel-jest - You.com
This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax....
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