alibaba / beidou

:milky_way: Isomorphic framework for server-rendered React apps
MIT License
2.74k stars 261 forks source link

babel stage2不能再用了 #114

Closed ahungrynoob closed 6 years ago

ahungrynoob commented 6 years ago

Current behavior

在尝试example/typesctipt的方案时发现: 当设置:

isomorphic: {
    babel: false,
  },

并复写app.js时,会报这个错误: https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets, "^7.0.0-beta.55"以后已经不再兼容stage2

Expected behavior

我自己解决了,这是我的app.js:

require('@babel/register')({
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
    '@babel/react',
    '@babel/typescript',
  ],
  plugins: [
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    '@babel/plugin-proposal-function-sent',
    '@babel/plugin-proposal-export-namespace-from',
    '@babel/plugin-proposal-numeric-separator',
    '@babel/plugin-proposal-throw-expressions',
    '@babel/plugin-transform-modules-commonjs',
    '@babel/proposal-class-properties',
    '@babel/proposal-object-rest-spread',
  ],
  babelrc: false,
  extensions: ['.jsx', '.mjs', '.ts', '.tsx'],
  cache: false,
});
ahungrynoob commented 6 years ago

example:react-redux-router-typescript 由于package.json中的@babel/core版本号固定,就不改了。。。如果前缀^也需要修改。。。