-
-
Notifications
You must be signed in to change notification settings - Fork 36k
TSL: use addMethodsChaining
#30207
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
TSL: use addMethodsChaining
#30207
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@@ -138,5 +138,7 @@ export const context = /*@__PURE__*/ nodeProxy( ContextNode ); | |||
*/ | |||
export const label = ( node, name ) => context( node, { label: name } ); | |||
|
|||
addMethodChaining( 'context', context ); | |||
addMethodChaining( 'label', label ); | |||
addMethodsChaining( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I find the previous more explicit version easier to read.
More compact code is not necessary something we are heading for. If you use a build system with a minifier, the improvements in size do usually not matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to simplily test it out, the code minify looks like:
code
import { addMethodChaining } from "three/tsl";
// this method does not in r171, we add it here.
function addMethodsChaining(object: Record<string, unknown>) {
for (const key in object) {
addMethodChaining(key, object[key]);
}
}
const NOOP = () => {};
addMethodChaining( 'test', NOOP );
addMethodChaining( 'dev', NOOP );
addMethodsChaining({
test: NOOP,
dev: NOOP
});
minify result:
function TN(e){for(const t in e)Fo(t,e[t])}const Yi=()=>{};Fo("test",Yi),Fo("dev",Yi),TN({test:Yi,dev:Yi});
Fo("test",Yi),Fo("dev",Yi)
is longer than TN({test:Yi,dev:Yi})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compared this logic with exporter, sometimes it can be useful to have export { a, b c }
instead of export a; export b; export c;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I find the previous more explicit version easier to read.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please 🙏
Related PR: #30201
Description
Simple test. Probably doesn't help the packing volume.