geometry-processing-js icon indicating copy to clipboard operation
geometry-processing-js copied to clipboard

[FEAT] Update to ES6 Modules

Open zalo opened this issue 3 years ago • 1 comments

This PR updates geometry-processing-js to use the ES6 Module Syntax.

ES6 Modules offer several notable benefits. They

  • Eliminate the redundant node codebase by unifying both Browser and Node implementations
  • Significantly Improve VS Code's Intellisense and Type Hinting
  • Simplify the script import front-loading
  • Maintain the "build-less" Library paradigm
  • Maintain support in all (priorly supported) browsers

Changelist:

  1. Switch the library to ES6 Syntax.
  2. Remove the redundant "node" subdirectory.
  3. Update the examples in "Projects" to accept the new ES6 code (also updating Three.js at the same time).
  4. Update the tests, adding a Github Action to automatically run them upon each push.
  5. Moved Documentation Building into a Github Action (run on each push (for now, this can be changed)).
  6. Replaced the libs folder with a three.js CDN.

All of the examples still work: https://zalo.github.io/geometry-processing-js/ https://zalo.github.io/geometry-processing-js/projects/geometric-flow/index.html https://zalo.github.io/geometry-processing-js/projects/discrete-curvatures-and-normals/index.html https://zalo.github.io/geometry-processing-js/projects/geodesic-distance/index.html https://zalo.github.io/geometry-processing-js/projects/parameterization/index.html https://zalo.github.io/geometry-processing-js/projects/vector-field-decomposition/index.html https://zalo.github.io/geometry-processing-js/projects/poisson-problem/index.html https://zalo.github.io/geometry-processing-js/projects/discrete-exterior-calculus/index.html https://zalo.github.io/geometry-processing-js/projects/direction-field-design/index.html

The documentation rebuilds properly automatically inside of a Github Action: https://zalo.github.io/geometry-processing-js/docs/index.html

And commits get a spiffy new checkmark when they pass the unit tests and documentation builds: image


Note:

You'll see that "use strict"; has been removed from most files. This is because ES6 Modules are always loaded in strict mode, so it became redundant.


I took special care in preserving the overall structure and intent of the code. It is my hope that you will see these changes as an unopinionated attempt towards improving the broader accessibility and maintainability of this library.

I'm a big fan of this library and the work that you guys do. Thank you for putting this all together. @MarkGillespie @rohan-sawhney @keenancrane @GeometryCollective

zalo avatar Feb 13 '21 04:02 zalo

@zalo Thank you for putting in all this effort! This really looks great, the dependencies in the library haven't been updated in a while. We'll test it out soon!

rohan-sawhney avatar Feb 15 '21 00:02 rohan-sawhney