Skip to content

[Feature Request] Move to separate import paths to allow better tree-shaking / payload size reduction #735

@acorncom

Description

@acorncom

Is your feature request related to a problem? Please describe.
When adding TerraDraw to an existing client app, I was surprised to see gzipped bundle size jump by about 40kb. If combined in with a larger app payload, that size reduces due to compression, but it's still larger than I'd expected. See https://bundlephobia.com/package/terra-draw@1.20.0 for some details. It's also sobering to see a slow but steady rise in bundle size as new features are added

Describe your proposed idea for the solution to this problem
Rather than exporting all potential imports from one central file, we could fairly easily unlock tree-shaking benefits by setting up export paths (import LineStringMode from 'terra-draw/modes/linestring or equivalent) This would also have the added benefit of making public api clearer.

This could be rolled out in such a way that existing consumers aren't affected (we leave the primary export system alone) but could add a note to the changelog about new export paths that folks can opt into if they care. Happy to brainstorm about potential export paths, roll out plan or helping pitch in on the work if desired.

Describe alternatives you've considered
We could leave this unchanged for now, not sure I see other clear alternatives

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions