paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.5k stars 1.23k forks source link

Tree Shaking #1844

Open Mark12870 opened 4 years ago

Mark12870 commented 4 years ago

Description

Make the library tree-shakable. https://webpack.js.org/guides/tree-shaking/ It would help to reduce package size while not using all features.

willynlabs commented 4 years ago

Maybe, but probably not.

My experience with other (UI) libraries is that their dependency trees are so intertwined that they not much gets shaken out. In addition, webpack and rollup both rely on ES module import/export:

https://webpack.js.org/guides/tree-shaking/

Paperjs was developed before the widespread adoption of ES modules, and uses a direct import (include) mechanism of its own. Look at src/paper.js.

I looked (briefly) at how to support tree shaking in the library, but quickly realized the above, and opted to create a version of the library that did not include modules I did not need (like the Event system). I know there is probably a better way to accomplish this, and suspect the authors will let us know.

Mark12870 commented 4 years ago

Well, it would be pitty to not implement it. It is all about making the library with modules in mind and don't import everywhere everything.

lehni commented 4 years ago

We are discussing this for after v1.0 is released. This will require a modernisation of the full code-base and the way the releases are built, which is is a huge undertaking.