Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tears743 opened this issue Nov 16, 2019 · 2 comments
Closed

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

tears743 opened this issue Nov 16, 2019 · 2 comments

Comments

@tears743
Copy link

tears743 commented Nov 16, 2019

环境:基于本仓库
.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相关代码没转译

@tears743 tears743 changed the title .babelrc 配制浏览器兼容问题 .babelrc 配置浏览器兼容问题 Nov 16, 2019
@hubcarl
Copy link
Collaborator

hubcarl commented Nov 19, 2019

收到

@hubcarl
Copy link
Collaborator

hubcarl commented Nov 20, 2019

image

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

@hubcarl hubcarl closed this as completed Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants