Nearly all MobX samples recommand “transform-decorators-legacy” babel plug-in for supporting the decorator grammar. It works with next@6. When upgrading to Next@7 & Next@8, the babel plug-in “transform-decorators-legacy” is not available anymore. We have to look for the new plug-in(s) for the decorator grammar. So here is the sample.
The key point is in the .bablerc file. We have to use the two plug-ins below with the right arguments. And the order of the two lines cannot be changed.
// .babelrc
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]