Skip to content
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

Tree-shaking: ShaderLib and UniformsLib #24221

Merged
merged 3 commits into from
Jun 13, 2022

Conversation

pschroen
Copy link
Contributor

@pschroen pschroen commented Jun 10, 2022

Related issue: #24199

Troubleshooting the remaining side-effects, converted both ShaderLib and UniformsLib to static class fields for discussion added pure annotations.

@pschroen pschroen marked this pull request as ready for review June 10, 2022 21:20
Copy link
Collaborator

@Mugen87 Mugen87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps improving tree-shaking, I'm fine with this PR.

That said, I'm a bit frustrated with cluttering the code base with annotations and refactoring easy-to-read code to something more incomprehensible 😞 . However, seems like there is no way around it if we want smaller bundles.

@pschroen
Copy link
Contributor Author

@Mugen87 I agree, I hate adding /*@__PURE__*/ annotations everywhere, it's a hack, and there are ways to write a library that is tree-shakable with no pure annotations.

It would require a pretty major re-write though, and everything would need to be self-contained classes.

I should also point-out there is a way around it, exporting your source files as the library entry point. These are all flat bundle problems. See #24006 (comment) 😜

@mrdoob mrdoob added this to the r142 milestone Jun 13, 2022
@mrdoob mrdoob merged commit 164e7fe into mrdoob:dev Jun 13, 2022
@mrdoob
Copy link
Owner

mrdoob commented Jun 13, 2022

Thanks!

@pschroen pschroen deleted the tree-shaking-shaderlib-uniformslib branch June 13, 2022 13:16
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
* Tree-shaking: ShaderLib and UniformsLib

* Tree-shaking: ShaderLib and UniformsLib pure annotations

* Tree-shaking: ShaderLib and UniformsLib switch back to object literal
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
* Tree-shaking: ShaderLib and UniformsLib

* Tree-shaking: ShaderLib and UniformsLib pure annotations

* Tree-shaking: ShaderLib and UniformsLib switch back to object literal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants