tmp
Wednesday, January 20, 2016
Babel6 で decorators を使う
Babel6+webpack で decoratorsを含むコードをコンパイルすると以下のエラーが出る (Babel5なら問題無いらしいがそれはそれで面倒なので) ``` ERROR in ./src/entry.js Module build failed: SyntaxError: ./src/entry.js: Decorators are not supported yet in 6.x pending proposal update. 11 | 12 | @backgroundRed > 13 | class App extends Component { | ^ 14 | static propTypes = { 15 | message: PropTypes.string 16 | }; ``` `babel-plugin-transform-decorators-legacy` をinstall ``` $ npm i babel-plugin-transform-decorators-legacy -S ``` `webpack.config.js` の`babel-loader` にpluginsを追加 ``` : module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: { plugins: ['transform-decorators-legacy'], // <-- presets: ['es2015', 'stage-0', 'react'] } } ] } : ``` source code https://github.com/fiahfy/react-examples/tree/master/decorators
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment