регенераторRuntime не определено rete. js - PullRequest
3 голосов
/ 13 февраля 2020

Ну, я могу найти решение для моей проблемы. Я пытаюсь использовать Rete.js в Next.js с Typescript. Я вижу следующую ошибку:

регенераторRuntime не определен

Вот мой пакет конфигурации

. json

"dependencies": {
    "@types/next": "^9.0.0",
    "@types/react": "^16.9.19",
    "next": "^9.2.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "rete": "^1.4.3-rc.1",
    "rete-area-plugin": "^0.2.1",
    "rete-connection-plugin": "^0.9.0",
    "rete-dock-plugin": "^0.2.1",
    "rete-react-render-plugin": "^0.2.0"
  },
"devDependencies": {
    "@babel/plugin-transform-runtime": "^7.8.3",
    "@types/node": "^13.7.1",
    "typescript": "^3.7.5"
  }
}

цконфиг. json

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "jsx": "preserve",
    "lib": [
      "dom",
      "es2017"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "preserveConstEnums": true,
    "removeComments": false,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "esnext",
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "isolatedModules": true
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ]
}

.babelr c

{
    "presets": ["next/babel"],
    "plugins": [
        [
          "@babel/plugin-transform-runtime",
          {
            "absoluteRuntime": false,
            "corejs": false,
            "helpers": true,
            "regenerator": true,
            "useESModules": false,
            "version": "7.0.0-beta.0"
          }
        ]
    ]
 }

I также пытался установить core-js и regenerator-runtime и пробовал это как:

import "core-js/stable";
import "regenerator-runtime/runtime";

Но у меня ничего не получалось. Можете ли вы предложить что-то, что может решить мою проблему.

1 Ответ

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

Нет необходимости устанавливать core-js и regenerator-runtime. @babel/plugin-transform-runtime предоставляет требуемое время выполнения. Я просто пропускал базовую вещь c, не добавляя @babel/preset-env. Я предполагал, что next/babel включает в себя все, что требуется для файла .babelrc, но это не так. Вот последний файл .babelrc, который работал для меня.

{
    "presets": [
        "@babel/preset-env",
        "next/babel"
      ],
      "plugins": [
        ["@babel/plugin-transform-runtime"]
      ]     
}
...