-
Notifications
You must be signed in to change notification settings - Fork 142
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
[feat] decrease bundle size #399
Comments
@loynoir Heya, The compiler only imports the modules it needs to operate. These aren't tree shake-able (afaik) (as all functionality may be invoked at runtime depending on the schema). These are the imports taken by the compiler. https://github.com/sinclairzx81/typebox/blob/master/src/compiler/compiler.ts#L29-L32 Bundle SizesThe following are the current compiled / minified sizes when pulling individual submodules (under the esbuild profile used by this tool) (just to give an indication of what size cost there is to importing a sub module).
This list is maintained with each NPM publish here Considerations on Value submoduleCurrently there is some consideration going towards splitting the Outside of this, there isn't too much that can be done to reduce bundle sizes at this stage. However, reducing code overhead is a long term goal for the project though, but carrying out refactoring's to reduce code size also has a maintainability cost. For now, TypeBox is favoring maintainability over reduce code. I am open to suggestions to reduce bundled output, there may be places where cross module imports can be reduced or split. |
Before $ npm exec -- esbuild --format=esm --bundle --outfile=reproduce.output.mjs reproduce.mjs
reproduce.output.mjs 148.7kb After "type": "module", "target": "ES2022",
"module": "ES2022", $ npm exec -- esbuild --format=esm --bundle --outfile=reproduce.output.mjs reproduce.mjs
reproduce.output.mjs 123.4kb |
Closing and deferring this work until 0.28.x has stabilized and type compositing and value infrastructure has been refactored accordingly. Marking labels for future enhancement. |
Feat
Have a glance at the output, seems a lot of unused logic is not tree-shake-able, and thus not tree-shake away.
Reproduce: Care about detail
$ du -h reproduce.mjs 4.0K reproduce.mjs $ npm exec -- esbuild --format=esm --bundle --outfile=reproduce.output.mjs reproduce.mjs reproduce.output.mjs 148.7kb
Reproduce: Not care about detail, with compile
#396 (comment)
The text was updated successfully, but these errors were encountered: