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

earcut worker #20

Merged
merged 3 commits into from
Dec 1, 2023
Merged

earcut worker #20

merged 3 commits into from
Dec 1, 2023

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Dec 1, 2023

Change list

  • Add build process via esbuild to generate worker
  • Change arrow imports to be from the file that exports them, not the top level. I found that this significantly reduced bundle size.

In particular, comparing the tree shaking output of

import { BufferType, Type } from "apache-arrow/enum";
import { Data } from "apache-arrow/data";
import { Vector } from "apache-arrow/vector";
import { Field } from "apache-arrow/schema";

with

import { BufferType, Type } from "apache-arrow";
import { Data } from "apache-arrow";
import { Vector } from "apache-arrow";
import { Field } from "apache-arrow";

Just that one change (from the latter to the former) reduced the minified earcut worker from 205kb to 74kb.

  • Remove full data type reconstruction from the earcut worker. Eliminating imports of DataType and Field classes and related functionality reduced bundle size from 74kb to 15kb!!
  • Note that all of these bundle sizes are uncompressed!! The brotli-compressed final bundle drops to just 6kb!! 🤯
  • I also published 0.3.0-beta.1 from this branch

@kylebarron kylebarron merged commit 736e8c3 into main Dec 1, 2023
1 check passed
@kylebarron kylebarron deleted the kyle/earcut-worker branch December 1, 2023 20:32
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

Successfully merging this pull request may close these issues.

1 participant