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

webpack4 tree-shaking fail with version 2.25.1 #287

Closed
maplor opened this issue Sep 14, 2023 · 16 comments · Fixed by #288, #291 or #306
Closed

webpack4 tree-shaking fail with version 2.25.1 #287

maplor opened this issue Sep 14, 2023 · 16 comments · Fixed by #288, #291 or #306
Labels
bug Something isn't working released

Comments

@maplor
Copy link

maplor commented Sep 14, 2023

  • three-stdlib version: 2.25.1

Problem description:

I use @react-three/drei for my 3D Scene in a webpack 4 project. after update three-stdlib version 2.25.1, I found that all three-stdlib.js build in the bundle. but it's ok (tree-shaking) in version 2.25.0

Suggested solution:

I found some change in this commit 644d2ad

if this is realy a bug ?

@maplor maplor added the bug Something isn't working label Sep 14, 2023
@JaimeTorrealba
Copy link

JaimeTorrealba commented Sep 20, 2023

Same problem in Tresjs

we use vite is not only with webpack

image

@github-actions
Copy link

🎉 This issue has been resolved in version 2.26.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@CodyJasonBennett
Copy link
Member

Reverted recent changes in #290 since we had bad downstream effects in-between. WRT tree-shaking, is that still an issue in the specific 2.26.2 version of three-stdlib?

@maplor
Copy link
Author

maplor commented Sep 21, 2023

Reverted recent changes in #290 since we had bad downstream effects in-between. WRT tree-shaking, is that still an issue in the specific 2.26.2 version of three-stdlib?

It seen no change
image

@github-actions
Copy link

🎉 This issue has been resolved in version 2.26.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@DmitryUlyanov
Copy link
Contributor

Still present with version 2.26.6

@CodyJasonBennett
Copy link
Member

Can you share a reproduction or how you're encountering this?

@DmitryUlyanov
Copy link
Contributor

Sure, please find attached.

To run:

npx nx run test-treeshake:build --configuration=production

test-tree-shake.zip

See this line.
image

With three-stdlib 1.14mb:
image

With three/examples, it's 700kb.
image

In my project the overhead is higher.

@DmitryUlyanov
Copy link
Contributor

And I just noticed on the screenshots this, but I actually did not import exporter anywhere.
image

@CodyJasonBennett
Copy link
Member

I wasn't able to run the attached test suite due to missing dependencies/config, but I was able to narrow down potential issues I've fixed in v2.26.7. Can you confirm on your end that this tree-shakes precisely to GLTFLoader? Chevrotain I couldn't find anything on since we vendor it to be pure.

@DmitryUlyanov
Copy link
Contributor

Updated the zip, forgot to include hidden files.

test-treeshake2.zip

With 2.26.7 I get
image

@CodyJasonBennett
Copy link
Member

Ah, vendored the wrong version. Put out a hotfix in 2.26.8. I'll double check with the above files.

@alvarosabu
Copy link

Hey there, it might not be only webpack, with vite and v2.26.0 the latest release of @tresjs/cientos was tripled https://bundlephobia.com/package/@tresjs/[email protected] Tresjs/cientos#254

Screenshot 2023-10-17 at 10 46 05

@CodyJasonBennett
Copy link
Member

CodyJasonBennett commented Oct 17, 2023

I have no observability unless you use the latest version. We ship sourcemaps and no longer consume most libraries from NPM by blind chance that helps here since I've received no feedback and cannot reproduce as such. On that note, I additionally have #306 which may crudely help here in bypassing the tree-shaking mechanism altogether.

@github-actions
Copy link

🎉 This issue has been resolved in version 2.27.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@alvarosabu
Copy link

@CodyJasonBennett just updated to v2.27.3 bundle-size back to normal, at least with vite 👍

Screenshot 2023-10-17 at 13 49 48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
5 participants