altjs / utils

A collection of utils for alt.js
37 stars 25 forks source link

decorators and webpack #11

Closed darul75 closed 8 years ago

darul75 commented 8 years ago

hi,

I can not figure out how to use decorator with webpack, I mean if I want to use

@createStore
@immutable
class AppStore {

I put this in my webpack config

{ test: /\.js?$/, loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015,plugins[]=syntax-decorators'], exclude: /(node_modules|__tests__)/ },

But webpack is not aware of annotation I guess and decorator not interpreted, so I came to old way of doing

// no matter if makeHot not used but only createStore decorator
let appStore = makeHot(alt, immutable(class AppStore {
  constructor() {

thx

Jul

taion commented 8 years ago

Babel 6 doesn't support decorators yet: https://phabricator.babeljs.io/T2645

You can try the legacy transform plugin if you want: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy.