peterqliu / threebox

A three.js plugin for Mapbox GL JS, with support for basic animation and advanced 3D rendering.
MIT License
526 stars 320 forks source link

Compatibility Error with Terser (and the simple fix) #95

Open AlexMViver opened 3 years ago

AlexMViver commented 3 years ago

When compiling an angular app that uses terser for production use the following error occurs compiling ThreeBox code:

Error: main.1a5fcd07c173571f6663.js from Terser Unexpected token: name (static) [main.1a5fcd07c173571f6663.js:5215,28] at js_error (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:538:11) at croak (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1251:9) at token_error (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1259:9) at unexpected (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1265:9) at Object.add_parameter (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1736:33) at binding_element (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1993:29) at parameter (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1800:17) at parameters (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1774:25) at _function_body (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:2047:19) at function_ (C:\Users\Alex\Documents\Lapr5\SPA\node_modules\terser\dist\bundle.min.js:1698:20)

Although I do not know terser's behavior the error is simply resolved by changing the variable 'static' name to another (non-reserved token) name.

The referred variable is located in src/objects/objects.js in the addMethods function.

jscastro76 commented 3 years ago

Hi @alexmviver Just FYI, since a year ago I’m maintaining a new fork from Threebox with many new features (that is also in production) such as the following: