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

from UglifyJs Unexpected token: name (Mime) [./~/ali-oss/shims/mime.js:8,0] #396

Closed
antiantian opened this issue Mar 22, 2018 · 8 comments · Fixed by #430
Closed

from UglifyJs Unexpected token: name (Mime) [./~/ali-oss/shims/mime.js:8,0] #396

antiantian opened this issue Mar 22, 2018 · 8 comments · Fixed by #430

Comments

@antiantian
Copy link

from UglifyJs
Unexpected token: name (Mime) [./~/ali-oss/shims/mime.js:8,0]

@binghaiwang
Copy link
Contributor

如果使用的是webpack 请 参考下 example中的webpack.prod.js, 需要对es6/7的语法进行babel转换成es5

@linjieAda
Copy link

linjieAda commented Mar 23, 2018

遇到了差不多的问题
ERROR in js/nav.948ca7c3.js from UglifyJs
Unexpected token: punc ({) [js/nav.948ca7c3.js:24,155671]

想要前端直传oss,加了ali-oss这个库就会报这个

.babelrc是这样的

{
  "presets": [
      "env",
      "react",
      "stage-1"
  ],
  "plugins": [
    "transform-decorators-legacy",
     ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }],
  ]
}
{
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
        }
      },

上面的答案无效

把.babelrc改成

"presets": [
      "env",
      ["es2015", { "modules": false }],
      "react",
      "stage-1"
  ],

也不行

@linjieAda
Copy link

用 require('ali-oss/dist/aliyun-oss-sdk.js') 搞定了

@antiantian
Copy link
Author

这种方式不会错 require('ali-oss/dist/aliyun-oss-sdk.js') 或者直接引用链接

@binghaiwang
Copy link
Contributor

我们计划后边把这个mime.js 进行改造, 彻底解决这个问题, 目前大家可以如果配置webpack的babel不行的话,就通过 require('ali-oss/dist/aliyun-oss-sdk.js')这种方式 构建, 等后边这个mime.js文件改造后就用原来方式就可以了

@sven0726
Copy link

sven0726 commented Apr 5, 2018

我按照上面的建议做了还是报错:

var oss = require('ali-oss/dist/aliyun-oss-sdk.min.js');
var OSS = oss.Wrapper;

我是在antd-pro 项目里使用的 @binghaiwang

@NoraGithub
Copy link

NoraGithub commented Jul 7, 2018

@binghaiwang 改造好了吗?

{
  "presets": [
    ["env", { "modules": false ,
    "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"],
        "node":"current"
      }
    }],
    "stage-0"
  ],
  "plugins": [
              ["component",
                {
                    "libraryName": "weex-ui",
                    "libDir": "packages",
                    "style": false
                }],
                  "syntax-dynamic-import",["transform-runtime", {
                    "helpers": false,
                    "polyfill": false,
                    "regenerator": true,
                    "moduleName": "babel-runtime"
                  }],
                  "transform-object-rest-spread"],
  "env": {
    "test": {
      "presets": ["env"],
      "plugins": ["istanbul"]
    }
  }

}

这个配置应该也是转为es2015的?
目前仍然报错, 4.15.0 版本。
`'ali-oss/dist/aliyun-oss-sdk.min.js'`对象为空哦。

@NoraGithub
Copy link

升级 5.3.1解决

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

Successfully merging a pull request may close this issue.

5 participants