-
-
Notifications
You must be signed in to change notification settings - Fork 34
Unnecessary code in bundles #37
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
Comments
I also experience this with Vite not being able to treeshake tempo. |
@WilcoSp can you identify if those functions are being used in format/parse? In general everything should be able to tree shake pretty well, perhaps with the exception of this issue (Map) which we can annotate. format/parse are the largest functions in the library as you might imagine, and they do use some of the functions in the library. |
with esBuilds 'keepNames' settings I was able to identify the following functions being bundled in:
bold are directly imported by parse/format after doing this it does seem everything gets used when using parse/format. but I do wonder how the bundle size does get around the +-12kb (not gzipped), +-5kb gzipped. sorry about what I had said about not being tree shakable, but what might had happened yesterday is that vite wasn't able to split tempo when using "addSecond" at a file that gets bundled into index.js, while for example date-fns was able to be split by vite |
tomorrow I'll make an example vue project to replicate the splitting issue |
I've created the repo to test splitting of Tempo with Vite and documented what I've observed into the readme @justin-schroeder this may help to get Tempo into smaller bundles with at least Vite |
Due to the lack of PURE annotations, extra code is included in bundles. Example:
var tokens = new Map(...)
is included and immediately thrown away (tokens
var is not used, but the bundler is not sure ifnew Map
can be safely omitted).As I suppose
tokens
is indeed pure, this issue can be fixed by adding a few/* @__PURE__ */
annotations like this:tempo/src/common.ts
Line 89 in 28a9539
More info:
Bundler — vite 5.1.4
The text was updated successfully, but these errors were encountered: