linaria
linaria copied to clipboard
Linaria not using custom babel config with rootMode: 'upward'
Environment
- Linaria version: 3.0.0-beta.13
- Bundler (+ version): Webpack 5.51.2
- Node.js version: 16.8.0
- OS: macOS Big Sur 11.6
// project root
.babel.config.js
/build/webpack.config.js
// webpack.config.js
{
test: /\.[jt]sx?$/,
use: [
babelLoader,
{
loader: '@linaria/webpack-loader',
options: {
babelOptions: {
rootMode: 'upward',
},
},
},
],
},
Description
I noticed that Linaria's Babel was not using our Babel config, even though we are using even `rootMode: 'upward' at the suggestion of https://github.com/callstack/linaria/issues/334#issuecomment-469725071.
This is because Linaria passes configFile: false
to Babel when running the Babel transform: https://github.com/callstack/linaria/blob/master/packages/babel/src/transform.ts#L180
As a result, Babel will not use the root Babel config because of configFile: false
. See https://github.com/babel/babel/blob/main/packages/babel-core/src/config/config-chain.ts#L155-L169
When I change to configFile: true
by editing Linaria locally, I can see that Babel is using the root config, and the compile works just fine. I'd be happy to make a PR that makes this change in the Webpack 4 and 5 loaders, but I'm not sure of the implications.
Reproducible Demo
Happy to provide if requested
Hi @rgoldfinger-quizlet
We can't use pure user's config in transform
because transform
does some very specific transformations. However, we can try to resolve the config and merge it but I don't sure that Babel provides a way to do it. I have to check.
btw, a demo will help a lot :)
Babel options are loaded differently in v5 and can be completely opted out by a feature flag, #1355.
As the issue does not have a repro, closing for now. Feel free to submit a new issue if the problem still exists.