Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree Shaking #162

Open
jacobp100 opened this issue Oct 23, 2020 · 7 comments
Open

Tree Shaking #162

jacobp100 opened this issue Oct 23, 2020 · 7 comments

Comments

@jacobp100
Copy link

jacobp100 commented Oct 23, 2020

What are your thoughts on making all functions ES6 exports (like add etc), then providing a 'lite' constructor with no functions defined on the prototype or as static functions constructor? This would mean people could use the exported functions directly and can tree shake.

My project uses ReScript (/ReasonML), so I just write bindings to whatever the exports are.

In the app, the calculations are done in a web worker, so pretty much requires the whole of this library. However, once calculated, the results are sent back to the client, but the only functionality I need from this library is toString.

Having this library be tree-shakable would significantly reduce the size of my client file.

@jacobp100
Copy link
Author

Thanks for the offer! I can handle doing this myself - I just wanted to know if you were interested in having it in the library. I'll aim make a copy of this library with the fix in the project I mentioned. You're welcome to copy it back if you want.

@jacobp100
Copy link
Author

jacobp100 commented Oct 24, 2020

My work is over at https://github.com/jacobp100/technicalc-calculator/blob/master/decimal

Still in the process of getting all the tests to pass - but a few of the suites are passing already

I get a 15kb decrease minified. I noticed function names get minified now too. But also some of that reduction comes from reducing the precision of pi and ln10

@MikeMcl
Copy link
Owner

MikeMcl commented Oct 25, 2020

I'm committed to keeping this library ES3 compatible, but I'll take a look. It's a good idea.

@jacobp100
Copy link
Author

Have you looked into adding build tools to this? It should be possible to write just one version (ES3 but with ES6 imports/exports), then produce an ES3-only bundle. That's something I could help with if you need!

@MikeMcl
Copy link
Owner

MikeMcl commented Oct 26, 2020

Yes, that has been considered, but at the moment I prefer to just include a separate ES module file, decimal.mjs.

@jakub791
Copy link

jakub791 commented Sep 13, 2022

I'm committed to keeping this library ES3 compatible, but I'll take a look. It's a good idea.

ES5 is supported everywhere now, including Internet Explorer which is like 10 years old. You do not need to support anything below that. If someone's browser does not support ES5 (or even ES6 now) then that isn't our issuse.

@jakub791
Copy link

Yes, that has been considered, but at the moment I prefer to just include a separate ES module file, decimal.mjs.

Why does it use ES3 compatible syntax? Modules were added in ES6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants