React-App - Rewired не добавляет плагин Babel - PullRequest
2 голосов
/ 25 января 2020

Итак, я пытаюсь запустить реактив-родной, используя реактив-нативный веб. Требуется добавить некоторые плагины Babel.

Мое приложение было создано с использованием response-app-rewired. Я пробовал несколько способов добавить плагин babel, однако безуспешно.

Я использую файл config-overrides.js, который выглядит следующим образом:

const { override, addBabelPlugins, addDecoratorsLegacy, fixBabelImports } = require('customize-cra');

const addHandleBarsLoader = config => {
    // add handlebars-loader so that handlebars templates in
    // webpack-dev-server's served html files are parsed
    // (specifically the meta tags)
    config.module.rules.push({ test: /\.html$/, loader: 'handlebars-loader' });
    return config;
}


module.exports = override(
    addHandleBarsLoader,
    fixBabelImports('import', {
        libraryName: 'antd',
        libraryDirectory: 'es',
        style: true,
      }),addBabelPlugins('@babel/plugin-proposal-class-properties'),
);

Я знаю другой конфиг переопределение работает, однако babel продолжает игнорировать новый плагин (который установлен, а также все остальное).

Кроме того, я создаю приложение через сборкуact-app-rewired.

Это сообщение об ошибке, которое я получаю при попытке построить

./node_modules/rn-bottom-drawer/src/BottomDrawer.js
SyntaxError: /Users/admin/Documents/Meirim/Workspace/meirim/node_modules/rn-bottom-drawer/src/BottomDrawer.js: Support for the experimental syntax 'classProperties' isn't currently enabled (13:20):

  11 |
  12 | export default class BottomDrawer extends Component{
> 13 |   static propTypes = {
     |                    ^
  14 |     /**
  15 |      * Height of the drawer.
  16 |      */

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel configto enable transformation.

Большое спасибо (:

Гал

1 Ответ

1 голос
/ 06 февраля 2020

Нашли решение, просто используйте функцию с именем addExternalBabelPlugin вместо

...