aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.68k stars 3.98k forks source link

Update or replace uglify-js to handle ES6 #4367

Open dmarcos opened 4 years ago

dmarcos commented 4 years ago

Error when minifying DracoLoader source. It looks it's the only part of THREE js shipping ES6

uglify-js failed on node_modules/super-three/examples/js/loaders/DRACOLoader.js : SyntaxError: Unexpected token: operator (>)

Build still generates but DracoLoader code is not minimized.

vincentfretin commented 4 years ago

The replacement of uglify is terser https://github.com/terser/terser I use it myself for my own aframe build like this:

npm run dist:max
npm i terser
npx terser --compress -- dist/aframe-master.js >dist/aframe-master.min.js
dmarcos commented 4 years ago

Thanks. What about source maps?

vincentfretin commented 4 years ago

It creates one, I have the dist/aframe-master.min.js.map file that is modified.

ghost commented 4 years ago

Thanks @vincentfretin, I had the issue last week and found a poor workaround using a specific version of uglify-es. I tried terser today with AFrame 1.0.1 and it works perfectly :)

dmarcos commented 4 years ago

Has anyone terser working on A-Frame repo? Willing to share a PR? Thank you 🙇

vincentfretin commented 4 years ago

Here it is #4588

vincentfretin commented 4 years ago

I tried various combinations of commands and options and I didn't manage to have a browserify build with terser and a correct sourcemap. From the documentation, this is supposed to work:

npm run dist:max
npx terser --source-map "content='dist/aframe-master.js.map'" -m --output dist/aframe-master.min.js dist/aframe-master.js

to generate the sourcemap taking into account the input sourcemap non minified aframe-master.js.map, but this doesn't work.

dmarcos commented 4 years ago

Ok. Thanks for the investigation.

vincentfretin commented 2 years ago

I didn't remember I worked on that already in December 2019 and created another issue #5106 with the PR #5111 to fix it. At that time I didn't know much about the -c and -m options of terser I guess.

vincentfretin commented 2 years ago

@dmarcos you can close this issue.