swc-loader
swc-loader copied to clipboard
`swc-loader` seems to ignore `.browserslistrc`
Installed Versions
{
"@swc/core": "^1.2.133",
"@swc/jest": "^0.2.17",
"swc-loader": "^0.1.15"
}
The output of swc-loader
is different between these two configurations:
webpack.config.ts (partial)
{
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
use: [ isProduction ? 'babel-loader' : 'swc-loader'],
exclude
},
]
}
}
.browserslistrc
query1
query2
webpack.config.ts (partial)
{
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
use: [
isProduction
? 'babel-loader'
: {
loader: 'swc-loader',
options: {
// swc-loader doesn't seem to automatically detect .browserslistrc
env: {
targets: 'query1, query2'
},
},
},
],
exclude,
},
]
}
}
Option 1 results in es2015 output whereas option 2 uses the browserslist query correctly and results in the expected output.
As a side question, would @swc/jest
also have the same issue?
Thanks!
Is your webpack file not at root level? I'm having the same issue when my configuration is in a subfolder even when using the path
property.
@vgurkov I am having the same issue even if I put webpack.config.js
at the root level, right next to the .browserslistrc
and pacakge.json
.
@SukkaW All my other loaders can pick up package.json
so I'd love it if one of the devs checks this issue out but in the meantime we can pass the browser targets to the loader like
const packageJson = require('../package.json');
...
loader: 'swc-loader',
options: {
...
env: {
targets: packageJson.browserslist,
...
Is the target option provided by the .browserslistrc
file still not supported? It seems that it can only be provided manually?
Why do you need to left a comment? Issue is not closed