easy-team / egg-react-webpack-boilerplate

Egg React Server Side Render(SSR) / Client Sider Render(CSR)
https://easyjs.cn/egg-react
MIT License
671 stars 93 forks source link

.babelrc 配置浏览器兼容问题 #45

Closed tears743 closed 4 years ago

tears743 commented 4 years ago

环境:基于本仓库 .babelrc 文件内容如下:

{
  "env":{
    "node": {
      "presets": [
        "react",
        ["env", {
          "modules": false,
          "targets": {
            "node": "current"
          }
        }]
      ],
      "plugins": [
        "react-hot-loader/babel",
        "transform-object-assign",
        "syntax-dynamic-import",
        "transform-class-properties",
        "transform-decorators-legacy",
        "transform-object-rest-spread",
        ["transform-runtime", {
          "helpers": false,
          "polyfill": false,
          "regenerator": true,
          "moduleName": "babel-runtime"
        }],
        ["import", { "libraryName": "antd", "style": "css" }]]
    },
    "web": {
      "presets": [
        "react",
        ["env", {
          "modules": false,
          "targets": {
            "browsers": ["last 2 versions", "not ie <= 7"]
          }
        }]
      ],
      "plugins": [
        "react-hot-loader/babel",
        "transform-object-assign",
        "syntax-dynamic-import",
        "transform-class-properties",
        "transform-decorators-legacy",
        "transform-object-rest-spread",
        ["transform-runtime", {
          "helpers": false,
          "polyfill": true,
          "regenerator": true,
          "moduleName": "babel-runtime"
        }],
        ["import", { "libraryName": "antd", "style": "css" }]]
    }
  },

  "comments": false
}

打包命令为: easy build && easy zip --target ./dist --filename app --deps

打包后有一部分代码没有从es6语法转译: 打包目录 /disp/app/dist/app/public/js/chunk//.js 下面是我打包后查看到的未转译代码: image 结果:无法兼容 期望:targets配制后能够兼容ie9

补充::每个打包后的js文件都有上述截图代码,是否react-hot-load相关代码没转译

hubcarl commented 4 years ago

收到

hubcarl commented 4 years ago

image

@tears743 提供一个可重现的最小demo, 本仓库 master 是 基于 babel 7 的,你的配置是 babel6 还是说你用的其它分支?