Repository navigation
Builds: Make three/tsl tree-shakeable. - #34533
Merged
Merged
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
monken
force-pushed
the
tsl-tree-shakeable
branch
from
September 10, 2026 16:37
b469a47 to
76f9e89
Compare
Mugen87
reviewed
Sep 14, 2026
| export { default as WGSLNodeBuilder } from './renderers/webgpu/nodes/WGSLNodeBuilder.js'; | ||
| export { ClippingGroup } from './objects/ClippingGroup.js'; | ||
| export * from './nodes/Nodes.js'; | ||
| export * from './nodes/TSL.js'; |
Collaborator
There was a problem hiding this comment.
Doesn't this PR partially revert #29948?
Exporting every TSL function at top level has been removed on purpose.
Contributor
Author
There was a problem hiding this comment.
I think it's a tradeoff between this and adding a three.tsl.js to the bundle. I pushed a revision that does just that. I know this has been discussed before but the reduced bundle size for application using only a handful of tsl function is worth it.
Collaborator
There was a problem hiding this comment.
The changes look good to me 👍
monken
force-pushed
the
tsl-tree-shakeable
branch
from
September 14, 2026 17:44
76f9e89 to
2e9aff6
Compare
`three.tsl.js` re-exported every TSL function by reading it off the `TSL` namespace object of `three/webgpu` (`export const abs = TSL.abs`). A single import from `three/tsl` therefore kept the whole frozen namespace alive in the consumer's bundle, and with it every node, lighting model, display pass and GPGPU helper, whether or not the application used them. `three.tsl.js` is now built in the same Rollup pass as `three.webgpu.js`, so the node code lives once in `three.tsl.js` and `three.webgpu.js` imports it, the same way both already import `three.core.js`. `Three.TSL.js` re-exports `nodes/TSL.js` directly and the public API of `three/webgpu` is unchanged.
monken
force-pushed
the
tsl-tree-shakeable
branch
2 times, most recently
from
September 14, 2026 17:45
2e9aff6 to
c5d35f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Importing a single function from
three/tslcurrently keeps the wholeTSLnamespace in the bundle. Each export reads from that namespace (export const color = TSL.color), so unused nodes and helpers end up in the application's bundle as well.This PR exposes the TSL functions as named exports from both WebGPU entry points and uses plain re-exports in
Three.TSL.js. That allows bundlers to remove the unused exports. The existingTSLnamespace is kept for backwards compatibility.Both core and TSL export
log, so the core export keeps its name and the TSL function is exposed aslogTSL. It's still exported aslogfromthree/tsl.I added a Rollup test that imports the renderer from the built
three/webgpufile andcolorfromthree/tsl. For this example, the bundle sizes are:This contribution is funded by revanta.bio