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.
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.
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.