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

Usage of top-level calls #72

Closed
Andarist opened this issue Aug 23, 2018 · 2 comments
Closed

Usage of top-level calls #72

Andarist opened this issue Aug 23, 2018 · 2 comments

Comments

@Andarist
Copy link

Top level calls are hard to treeshake because tree-shakers/minifiers are often "afraid" of removing them because of potential side-effects of those calls.

Culprits:

var ascendingBisect = bisector(ascending);

d3-array/src/ticks.js

Lines 1 to 3 in 36edab3

var e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);

Possible solution:
Add #__PURE__ annotations before those calls to reassure UglifyJS that those calls can be dropped if their results stay unused - either manually or with help of https://github.com/Andarist/babel-plugin-annotate-pure-calls

Intent to implement:
yes - would only have to know if you want to tackle this one

@mbostock
Copy link
Member

I’ll tackle this when Rollup adds support for pure annotations rollup/rollup#1293.

@conartist6
Copy link

I just opened rollup/rollup#2429 against Rollup adding that functionality. Feel free to weigh in.

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

No branches or pull requests

3 participants