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

ant pro (roadhog) yarn build error: Failed to minify the bundle. Error:from UglifyJs Unexpected token: name (InvalidFormatError) #3697

Closed
strangewolf opened this issue Mar 8, 2019 · 6 comments

Comments

@strangewolf
Copy link

As far as i understood @sorrycc sorrycc/blog#68
i have edited my .webpackrc.js file:

added es5ImcompatibleVersions: true,

const path = require('path');

export default {
  entry: 'src/index.js',
  es5ImcompatibleVersions: true,
  extraBabelPlugins: [
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
  alias: {
    'components': path.resolve(__dirname, 'src/components/'),
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  disableDynamicImport: true,
  publicPath: '/',
  hash: true,
};

After updating webpackrc.js file , deleted Node Modules folder, reinstalled node_modules and yarn cache clean && yarn build

Package.json file:

{
  "name": "Something",
  "version": "1.1.0",
  "description": "some description",
  "private": true,
  "scripts": {
    "start": "cross-env ESLINT=none roadhog dev",
    "start:no-proxy": "cross-env NO_PROXY=true ESLINT=none roadhog dev",
    "build": "cross-env ESLINT=none roadhog build",
    "site": "roadhog-api-doc static && gh-pages -d dist",
    "analyze": "cross-env ANALYZE=true roadhog build",
    "lint:style": "stylelint \"src/**/*.less\" --syntax less",
    "lint": "eslint --ext .js src mock tests && npm run lint:style",
    "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
    "lint-staged": "lint-staged",
    "lint-staged:js": "eslint --ext .js",
    "test": "roadhog test",
    "test:component": "roadhog test ./src/components",
    "test:all": "node ./tests/run-tests.js",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "dependencies": {
    "@antv/data-set": "^0.8.0",
    "@babel/polyfill": "^7.0.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.14",
    "@fortawesome/pro-light-svg-icons": "^5.7.1",
    "@fortawesome/pro-regular-svg-icons": "^5.7.1",
    "@fortawesome/pro-solid-svg-icons": "^5.7.1",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "@material-ui/core": "^3.0.1",
    "@material-ui/icons": "^3.0.1",
    "antd": "^3.12.1",
    "babel-runtime": "^6.26.0",
    "bizcharts": "^3.2.2",
    "bizcharts-plugin-slider": "^2.0.7",
    "chart.js": "^2.7.3",
    "classnames": "^2.2.6",
    "cookie-storage": "^3.2.0",
    "date-fns": "2.0.0-alpha.7",
    "dva": "^2.4.0",
    "dva-loading": "^2.0.5",
    "enquire-js": "^0.2.1",
    "express": "^4.16.3",
    "express-favicon": "^2.0.1",
    "express-subdomain": "^1.0.5",
    "formsy-react": "^1.1.4",
    "global": "^4.3.2",
    "jquery": "^3.3.1",
    "keymaster": "^1.6.2",
    "lodash": "^4.17.10",
    "lodash-decorators": "^6.0.0",
    "material-ui-pickers": "^1.0.0-rc.13",
    "moment": "^2.22.2",
    "numeral": "^2.0.6",
    "omit.js": "^1.0.0",
    "path": "^0.12.7",
    "path-to-regexp": "^2.4.0",
    "prismjs": "1.15.0",
    "prop-types": "^15.6.2",
    "qs": "^6.5.2",
    "raw-loader": "^0.5.1",
    "rc-animate": "^2.4.4",
    "rc-drawer-menu": "^1.1.0",
    "react": "^16.6.3",
    "react-chartjs": "^1.2.0",
    "react-chartjs-2": "^2.7.4",
    "react-container-query": "^0.11.0",
    "react-cookie": "^3.0.4",
    "react-document-title": "^2.0.3",
    "react-dom": "^16.6.3",
    "react-fittext": "^1.0.0",
    "react-router-dom": "^4.3.1",
    "rollbar": "^2.4.5",
    "url-polyfill": "^1.0.14",
    "winston": "^3.2.1"
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.7.1",
    "@fortawesome/fontawesome-pro": "^5.7.1",
    "@storybook/addon-actions": "^3.4.10",
    "@storybook/addon-links": "^3.4.10",
    "@storybook/addon-notes": "^3.4.10",
    "@storybook/addon-storysource": "^3.4.10",
    "@storybook/addons": "^3.4.10",
    "@storybook/react": "^3.4.10",
    "babel-core": "^6.26.3",
    "babel-eslint": "^9.0.0",
    "babel-plugin-dva-hmr": "^0.4.1",
    "babel-plugin-import": "^1.8.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "cross-env": "^5.2.0",
    "cross-port-killer": "^1.0.1",
    "enzyme": "^3.5.0",
    "eslint": "^5.4.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-babel": "^5.1.0",
    "eslint-plugin-compat": "^2.5.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-markdown": "^1.0.0-beta.6",
    "eslint-plugin-react": "^7.11.1",
    "gh-pages": "^1.2.0",
    "husky": "^0.14.3",
    "lint-staged": "^7.2.2",
    "mockjs": "^1.0.1-beta3",
    "pro-download": "^1.0.1",
    "redbox-react": "^1.6.0",
    "regenerator-runtime": "^0.12.1",
    "roadhog": "^2.4.5",
    "roadhog-api-doc": "^1.1.2",
    "stylelint": "^9.5.0",
    "stylelint-config-standard": "^18.2.0"
  },
  "resolutions": {
    "recompose": "^0.28.2"
  },
  "optionalDependencies": {
    "puppeteer": "^1.7.0"
  },
  "lint-staged": {
    "**/*.{js,jsx}": [
      "eslint --fix",
      "git add"
    ],
    "**/*.less": "stylelint --syntax less"
  },
  "engines": {
    "node": ">=8.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 10"
  ]
}

screenshot 2019-03-08 at 1 35 59 pm

Please can anyone help me with this:

If missing something, then guide me
or doing it wrong, then correct me.

Thank you

@strangewolf
Copy link
Author

strangewolf commented Mar 9, 2019

@sorrycc i have updated roadhog version in package.json to
"roadhog": "^2.5.0-beta.4",

still facing same error.

@sorrycc i have followed your https://www.youtube.com/watch?v=z4pWFpPiIoc video too.. bit confusion because of language tried to understand it...

but have a question that bothering me a lot..
https://github.com/umijs/es5-imcompatible-versions do i have to install this package separately or it is included in new roadhog version ???..

Dont know what to do .. please help me with this @sorrycc

@sorrycc
Copy link
Contributor

sorrycc commented Mar 9, 2019

You need to use COMPRESS=none roadhog build to find out which dependency library is causing the problem first, then make a PR to add it to es5-imcompatible-versions.

@strangewolf
Copy link
Author

strangewolf commented Mar 9, 2019

@sorrycc thank you so much for quick response.

yes i tried using COMPRESS=none roadhog build
and compiled successfully!.

Screenshot 2019-03-09 at 6 54 02 PM

@sorrycc didnt get this then make a PR to add it to es5-imcompatible-versions. (do you mean Pull Request for repo es5-imcompatible-versions. ? ... the way you did in video? )
..sorry for giving so much trouble to you.. i am all new to this.

@strangewolf
Copy link
Author

@sorrycc hey i did what you asked for #3697 (comment)

then make a PR to add it to es5-imcompatible-versions.

created pull request ! do check it @sorrycc

@sorrycc
Copy link
Contributor

sorrycc commented Mar 11, 2019

Reinstall your node_modules and try again, ref: umijs/es5-imcompatible-versions@0fcba47

@strangewolf
Copy link
Author

@sorrycc hey its working.. thank you !

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