私のReactプロジェクトでデコレータを使用しようとしていて、.babelrc
のプラグインを参照しているバベルプラグインをインストールしましたが、私のコンソールに。Babelが正しいプラグインにもかかわらずデコレータ構文をコンパイルできません
package.json
// ...
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"chai": "^3.5.0",
"file-loader": "^0.9.0",
"url-loader": "^0.5.7"
}
// ...
.babelrc - 私は、以前transform-object-rest-spread
プラグインがインストールされていたので、ちょうどplugins
配列に拡張している:で、
{
"plugins": ["transform-object-rest-spread", "transform-decorators-legacy"]
}
とコンソールのエラーを(念のため)フル:
BabelLoaderError: SyntaxError: Decorators are not officially supported yet in 6.x pending a proposal update.
However, if you need to use them you can install the legacy decorators transform with:
npm install babel-plugin-transform-decorators-legacy --save-dev
and add the following line to your .babelrc file:
{
"plugins": ["transform-decorators-legacy"]
}
The repo url is: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy.
私は何をしないのですか?
私はあなたの応答を受け取ったのと同様に、おっと – azium
同様にあなたのWebPACKの設定を投稿私はそれを解決しました:)答えを見て... – Paulos3000