如何启用对实验语法“ decorators-legacy”的支持?

时间:2019-07-08 18:49:00

标签: react-native

每当我运行./gradlew assembleRelease,它就会随之出现

error

我尝试运行npm i --save-dev @babel/plugin-proposal-class-properties @babel/plugin-proposal-decorators./gradlew --stop,但都没有用。

我还在.babelrc文件中添加了["@babel/plugin-proposal-class-properties", { "loose": true}],但没有任何改变。

我的.babelrc:

{
  "presets": ["module:metro-react-native-babel-preset"],
  "env": {
    "production": {
      "plugins": [
        "transform-remove-console", 
        ["@babel/plugin-proposal-decorators", { "legacy": true}],
        ["@babel/plugin-proposal-class-properties", { "loose": true}]
      ]
    },
    "development": {
      "plugins": [
        "transform-remove-console", 
        ["@babel/plugin-proposal-decorators", { "legacy": true}],
        ["@babel/plugin-proposal-class-properties", { "loose": true}]
      ]
    }
  }
}

我的package.json:

{
  "name": "SouthPointPizza",
  "version": "3.8.0",
  "description": "React Native mobile app for WooCommerce",
  "author": "InspireUI",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "build:ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file='index.js' --bundle-output='./ios/mstore/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'",
    "setup": "./scripts/setup.sh",
    "setup:android": "./scripts/setup_android.sh",
    "reset": "./scripts/reset.sh",
    "postinstall": "patch-package",
    "devtools": "react-devtools",
    "reverseADB": "adb reverse tcp:8097 tcp:8097",
    "buildAndroid": "cd android && gradlew assembleRelease"
  },
  "dependencies": { ... },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.5.0",
    "@babel/plugin-proposal-decorators": "^7.4.4",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.8.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.54.0",
    "reactotron-react-native": "3.5.0",
    "reactotron-redux": "3.1.0"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

0 个答案:

没有答案