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

How to use ES2015 (ES6) Imports to allow Tree Shaking? #2862

Closed
janwendt opened this issue Jul 12, 2023 · 1 comment
Closed

How to use ES2015 (ES6) Imports to allow Tree Shaking? #2862

janwendt opened this issue Jul 12, 2023 · 1 comment

Comments

@janwendt
Copy link

janwendt commented Jul 12, 2023

maplibre-gl-js version: 3.0.1

browser: Firefox 113.0.2

How can i use ES2015 (ES6) Imports to reduce Bundle Size via Tree Shaking (https://webpack.js.org/guides/tree-shaking/)?
I would like to use something like this:

import { Map } from "maplibre-gl";

instead of

import "maplibre-gl";

because this general import increases my bundle size by about 740 KB. I have not found anything about this in the documentation.

With Minisearch for example I can use this import

import MiniSearch from 'minisearch';

and tree shaking works immediately because ES2015 (ES6) imports are supported.

@janwendt janwendt changed the title How to use ES2015 (ES6) Imports? How to use ES2015 (ES6) Imports to allow Tree Shaking? Jul 12, 2023
@HarelM
Copy link
Collaborator

HarelM commented Jul 12, 2023

I don't think you can... Since maplibre uses workers and their code is also bundled, you can't easily import just part of the library...
I think this issue is a duplicate of #977.

@HarelM HarelM closed this as completed Jul 14, 2023
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

2 participants