如何将 `react-native-reanimated/plugin` 添加到 `babel.config.js` 中?

huangapple go评论52阅读模式
英文:

How to add `react-native-reanimated/plugin` to `babel.config.js`?

问题

我正在尝试将react-native-reanimatedv1.13.3升级到v2.0.1。在安装说明中,他们建议在您的babel.config.js中添加react-native-reanimated/plugin,如下所示:

module.exports = {
  presets: [
    ...
  ],
  plugins: [
    ...
    'react-native-reanimated/plugin',
  ],
};

目前我的babel.config.js如下所示:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  env: {
    production: {
      plugins: [
        'react-native-paper/babel'
      ],
    },
  }
};

如果我像这样添加它:

plugins: [
  'react-native-paper/babel'
  'react-native-reanimated/plugin'
],

我会收到此错误:Transform's input file does not exist: <project>/node_modules/react-native-reanimated/android/react-native-reanimated-65.aar. (See https://issuetracker.google.com/issues/158753935)

我应该如何替代添加它?

英文:

I'm trying to upgrade react-native-reanimated from v1.13.3 to v2.0.1. In the installation instructions they say to add react-native-reanimated/plugin to your babel.config.js as follows:

  module.exports = {
    presets: [
      ...
    ],
    plugins: [
      ...
      &#39;react-native-reanimated/plugin&#39;,
    ],
  };

Currently my babel.config.js looks like this:

module.exports = {
  presets: [&#39;module:metro-react-native-babel-preset&#39;],
  env: {
    production: {
      plugins: [
        &#39;react-native-paper/babel&#39;
      ],
    },
  }
};

If I add it like this:

plugins: [
            &#39;react-native-paper/babel&#39;
            &#39;react-native-reanimated/plugin&#39;
          ],

I get this error: Transform&#39;s input file does not exist: &lt;project&gt;/node_modules/react-native-reanimated/android/react-native-reanimated-65.aar. (See https://issuetracker.google.com/issues/158753935)

How should I add it instead?

答案1

得分: 2

module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'react-native-reanimated/plugin',
],
env: {
production: {
plugins: [
'react-native-paper/babel'
],
},
}
};

英文:

You can try:

module.exports = {
   presets: [&#39;module:metro-react-native-babel-preset&#39;],
   plugins: [
        &#39;react-native-reanimated/plugin&#39;,
   ],
   env: {
      production: {
         plugins: [
           &#39;react-native-paper/babel&#39;
         ],
      },
   }
};

huangapple
  • 本文由 发表于 2023年2月24日 03:35:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75549528.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定