Search code examples
webpackthree.jsbundlesource-mapsuglifyjs

Webpack build error - Unexpected token: name (OrbitControls)


I have the following error when building webpack for production using the ‘source-map’ devtool:

ERROR in bundle.js from UglifyJs
Unexpected token: name (OrbitControls) [./node_modules/orbit-controls-es6/src/index.js:33,0][bundle.js:57444,6]

The build has been working fine for development using the 'cheap-module-eval-source-map' webpack devtool.

The module that Uglify seems to take issue with is the orbit-controls-es6 module used for Three.js camera control, pointing to the main class declaration:

export default class OrbitControls extends EventDispatcher {…

Can someone explain to me why this might be occurring? I’m not sure if it’s an issue with the module or with my own code base.


Solution

  • Do you happen to have a circular dependency?

    also I use this version from npm and works fine with webpack

    https://www.npmjs.com/package/three-orbitcontrols

    import OrbitControls from 'three-orbitcontrols'