X
X
XpeH Petrovich2017-03-24 15:33:39
JavaScript
XpeH Petrovich, 2017-03-24 15:33:39

How to add support for decorators in node.js?

The question is relevant in the context of Babel. The next goal is to connect to the MobX node and use the ESNext decorators (@observer and others like them) (which, as far as I remember, are still only in Stage 2). I run the node with the --harmony flag and write in ES6 right away, without transpiling. Now I need to include babel and its babel-plugin-syntax-decorators and babel-plugin-transform-decorators-legacy plugins. I don't understand what to do next at point-blank range - now to run babel, do you need babel-runtime or babel-polyfill? Given that I need it to compile decorators to ES6? Is this even possible?

$ node -v
v7.5.0

"devDependencies": {
    "babel-cli": "latest",
    "babel-core": "latest",
    "babel-plugin-syntax-decorators": "latest",
    "babel-plugin-transform-decorators-legacy": "latest",
    "babel-plugin-transform-object-rest-spread": "latest",
    "babel-preset-stage-2": "latest",
    "babel-register": "latest",
    "gulp": "latest",
    "gulp-babel": "latest",
    "redis-cli": "latest",
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2017-03-24
@SPAHI4

Specify plugins in .babelrc file and run via babel-node

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question