vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.82k stars 26.85k forks source link

next export getting stuck #4723

Closed sarkistlt closed 6 years ago

sarkistlt commented 6 years ago

Bug report

Describe the bug

when running next export, it does export, it works, but then process never dies, so I'm forced to use something like next export& sleep 300 ; kill $! in my deployment which is not really reliable. I'm not using getInitialProps anywhere besides _document.js.

Current version of nextjs is next@6.0.4-canary.3. I was trying to upgrade nextjs, hopping maybe this issue will be resolved, but If I will upgrade to next@6.0.4-canary.4 and up, getting following error when running next build:

{ Error: (client) [component full path].js from UglifyJs undefined
  errors: 
   [ '(client) [component full path].js from UglifyJs\nundefined',
   ...],
  warnings: [] }
npm ERR! code ELIFECYCLE

To Reproduce

NODE_ENV=production next build && next export

Expected behavior

after export is complete process should stop.

System information

Additional context

package.json

    ...
    "@material-ui/core": "^1.3.0",
    "@material-ui/icons": "^1.1.0",
    "material-ui-chip-input": "next",
    "material-ui-pickers": "^1.0.0-rc.10",
    "moment": "^2.22.0",
    "next": "6.0.4-canary.3",
    "next-redux-wrapper": "^1.3.5",
    "react": "^16.1.0",
    "react-dom": "^16.1.0",
    "react-jss": "^8.1.0",
    "react-redux": "^5.0.6",
    "recompose": "^0.26.0",
    "redux": "^4.0.0",
    "redux-form": "^7.3.0",
    "redux-form-material-ui": "next",
    "redux-promise-middleware": "^5.1.1",
    "redux-thunk": "^2.2.0",
    ...
    "@babel/cli": "7.0.0-beta.42",
    "@babel/core": "7.0.0-beta.42",
    "@babel/node": "7.0.0-beta.42",
    "@babel/plugin-transform-flow-comments": "7.0.0-beta.42",
    "@babel/plugin-transform-react-inline-elements": "7.0.0-beta.42",
    "@babel/polyfill": "7.0.0-beta.42",
    "@babel/preset-env": "7.0.0-beta.42",
    "@babel/preset-flow": "7.0.0-beta.42",
    "@babel/preset-react": "7.0.0-beta.42",
    "@babel/preset-stage-0": "7.0.0-beta.42",
    ...

.babelrc.js

const development = require('./config/default.json');
const staging = require('./config/staging.json');
const production = require('./config/production.json');

module.exports = {
  presets: [
    '@babel/preset-flow',
    ["next/babel", {
      "preset-env": {
        "targets": {
          "browsers": "> 5%"
        }
      }
    }],
    [
      '@babel/preset-stage-0',
      {
        decoratorsLegacy: true,
      },
    ],
  ],
  plugins: [
    '@babel/plugin-transform-react-inline-elements',
    [
      'import',
      {
        libraryName: 'antd',
      },
    ],
  ],
  env: {
    development: {
      plugins: [
        ['transform-define', development],
      ],
    },
    staging: {
      plugins: [
        ['transform-define', staging],
      ],
      comments: false,
      compact: true,
    },
    production: {
      plugins: [
        ['transform-define', production],
      ],
      comments: false,
      compact: true,
    },
  },
};

ref: [next export getting stuck, #2201]

martyla commented 6 years ago

Getting a similar error running next build after upgrading to next@6.0.4-canary.4 or higher

Issue seems to come from removing the uglify compress options in zeit/next.js#4536, and can be temporarily fixed by reverting the changes in that PR

martyla commented 6 years ago

Looks like error message getting mangled from parallel: true in the uglifyjs options.

After setting it to parallel: false my error becomes:

> Failed to build
{ Error: (client) ... from UglifyJs
TypeError: sym.definition is not a function
...

If you're using yarn, I was able to fix it using the solution from mishoo/UglifyJS2#2896:

Add to package.json:

  ...
  "resolutions": {
    "uglify-es": "3.3.9"
  },
  ...

And run yarn install again

sarkistlt commented 6 years ago
...
  "resolutions": {
    "uglify-es": "3.3.9"
  },
  ...

didn't help, getting the same error

timneutkens commented 6 years ago

Fixed by #4749