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

Limited tree-shaking when Temporal is imported but not used #286

Closed
federicocarboni opened this issue Jun 20, 2024 · 1 comment
Closed

Comments

@federicocarboni
Copy link
Contributor

Bundlers are not able to remove the temporal polyfill when it is imported but not used. This produces large bundles even when Temporal functionality is not used.

import {Temporal} from "@js-temporal/polyfill";

export function usesTemporal() {
  // Anything with Temporal
  return Temporal.PlainDateTime.from("1970-01-01");
}

export function notUsingTemporal() {
  return 42;
}

Now even if the user of the library only imports notUsingTemporal a large amount of code from the temporal polyfill is included anyway.

This is very important for library authors who want to use Temporal but allow it to be tree-shaken out if not necessary.

federicocarboni added a commit to federicocarboni/temporal-polyfill that referenced this issue Jun 20, 2024
Allows bundlers to tree-shake out the temporal polyfill when imported but not used.
12wrigja pushed a commit that referenced this issue Jun 24, 2024
Allows bundlers to tree-shake out the temporal polyfill when imported but not used.
@federicocarboni
Copy link
Contributor Author

Fixed in #287

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

1 participant