mobx and create-react-app

Created on 29 Aug 2016  路  8Comments  路  Source: mobxjs/mobx

It would be great to see an example that works with create-react-app without having the need to eject immediately in order to support the babel transform-decorators-legacy.
Looks like create-react-app won't support legacy plugins (https://github.com/facebookincubator/create-react-app/issues/214) so it might be worth demonstrating using mobx with the OOTB create-reach-app configuration instead.

Most helpful comment

All 8 comments

You can add the transform-decorators-legacy yourself in node_modules/react-scripts/config/babel.dev.js

image

Excellent, that will do the job!

@EQuimper would you mind adding that to the README of create-react-app-mobx as alternative?

@mweststrate Yes should be a good idea

@EQuimper Good workaround, but I'd rather have more examples that demonstrate using mobx with standard syntax. Projects like e.g Aurelia have been suffered in the past by using experimental feature of jspm and babel, which later changed or where withdrawn. I'd rather have an option to not go down the same route.

Now, you can push require.resolve('babel-plugin-transform-decorators-legacy') in node_modules/babel-preset-react-app/index.js plugins array

This article clearly explains how to solve this issue.

Basically it all boils down to two simple steps:

1.npm install --save-dev babel-plugin-transform-decorators-legacy

  1. Add babel configuration to your package.json.
    "plugins": [
      "transform-decorators-legacy"
    ],

screen shot 2018-06-19 at 8 31 05 pm

Was this page helpful?
0 / 5 - 0 ratings