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

Add bundle visualizer to test-treeshake script #21657

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

marcofugaro
Copy link
Contributor

Related issue: #19986 (comment)

Description

This PR adds rollup-plugin-visualizer to the test-treeshake script. When running the script, this message will appear:

Screenshot 2021-04-15 at 10 51 33

After opening the file in a browser, you will be able to explore the analysis of the visualizer on the tree-shaken bundle.

Screenshot 2021-04-15 at 10 50 22

⚠️ NOTE: It's important to notice that filesizes don't correspond to the actual output filesizes, but rather to the size of the source files. The plugin works on source files, for this reason as well it was necessary to import three.js from the source. The proportions are correct though, and only files not tree-shaken are present.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 15, 2021

I guess a class like Ray or Triangle can't be tree-shaken since both are modified in Three.Legacy.js?

If we want to improve this, we should consider to a) remove the entries or b) move them into the respective classes (e.g. Ray or Triangle).

@marcofugaro
Copy link
Contributor Author

Ray is used by Mesh.raycast(), Triangle is used by checkBufferGeometryIntersection() which is called in Mesh.raycast().

You can understand this by searching in the treeshake/index.bundle.js file 🙂

Prototype properties like Ray.prototype.isIntersectionBox don't hold the class from being tree-shaken, function calls like Object.defineProperties() do, but we removed most of those.

Ray.prototype.isIntersectionBox is there just because Ray is there, see this barebones example.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 15, 2021

Okay, thanks for the clarification!

@mrdoob mrdoob added this to the r128 milestone Apr 15, 2021
@mrdoob mrdoob merged commit 6bab8bd into mrdoob:dev Apr 15, 2021
@mrdoob
Copy link
Owner

mrdoob commented Apr 15, 2021

Thanks!

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.

3 participants