[英]babel-loader not transpiling package in node_modules
我已經將 babel-loader 和 babel/core 更新為最新的。
"babel-loader": "8.2.2",
"@babel/core": "7.14.3",
根據這個問題,它說這與.babelrc有關,應該使用babel.config.js,而不是.babelrc。
我也更新了配置,但仍然沒有運氣。
react-spring,@react-spring,rafz 應該被轉發,但他們沒有。
exports.loadJavaScript = () => {
return {
module: {
rules: [
{
test: [/\.jsx?$/, /\.js$/],
include: [resolve('../src')],
exclude: /node_modules(?!\/(react-spring|@react-spring|rafz))/,
use: [
{
loader: 'thread-loader',
options: jsWorkerPool,
},
{
loader: 'babel-loader',
options: {
babelrc: false,
cacheDirectory: true,
configFile: path.resolve(
__dirname,
'../babel.config.js',
),
}
},
],
},
],
},
}};
module.exports = api => {
const isDevelopment = process.env.NODE_ENV !== 'production';
const enableRefresh = process.env.NOREFRESH !== 'true';
api.cache.using(() => process.env.NODE_ENV);
return {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: { version: 3, proposals: true },
targets: {
browsers: ['last 2 versions', 'safari >= 7', 'ie >= 11'],
},
},
],
'@babel/preset-react',
],
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
],
[
'@babel/plugin-proposal-class-properties',
{
loose: true,
},
],
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-syntax-dynamic-import',
isDevelopment && enableRefresh && require.resolve('react-refresh/babel'),
].filter(Boolean),
};
};
有人可以幫忙嗎?
它與 babel 無關,但與 babel-loader 無關,我使用 include 和 exclude 進行了錯誤的配置,刪除以下行,它可以工作。
- include: [resolve('../src')],
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.