Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tree-shaking improvement #1865

Closed
daker opened this issue Apr 23, 2021 · 1 comment · Fixed by #1889
Closed

Tree-shaking improvement #1865

daker opened this issue Apr 23, 2021 · 1 comment · Fixed by #1889
Assignees
Labels
module: build released Automated label status: confirmed Could be reproduced by a main contributor type: feature request 💡 Desired capabilities / enhancements

Comments

@daker
Copy link
Collaborator

daker commented Apr 23, 2021

We have an app that uses vtk.js to render meshes and the bundle is produced by webpack, the analyze shows that some pieces of vtk.js are included in the bundle even if they are not used or called in the app.

So basically OpenGL/RenderWindow calls OpenGL/ViewNodeFactory which instantiate classes even if they are not used the app, i can list :

  • vtkGlyph3DMapper
  • vtkPixelSpaceCallbackMapper
  • vtkSphereMapper
  • vtkStickMapper
  • vtkSurfaceLICMapper
  • vtkVolumeMapper

is there something we can do in vtk.js to improve this part?

Also i can see the import of vtkMath which is 20kb

import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';

instead of the individual functions

import { XYZ } from 'vtk.js/Sources/Common/Core/Math';

https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/OpenGL/ViewNodeFactory/index.js#L48-L89

tree-shaking

@jourdain jourdain added module: build status: confirmed Could be reproduced by a main contributor type: feature request 💡 Desired capabilities / enhancements labels Apr 23, 2021
@jourdain jourdain self-assigned this Apr 23, 2021
jourdain added a commit that referenced this issue Apr 30, 2021
This change allow a better management for tree shaking but require the user to explicitly import the
classes that will be required

BREAKING CHANGE: Explicit import needs to be performed to enable rendering implementation. Profiles
have been created to simplify that task. See vtk.js/Sources/Rendering/OpenGL|WebGPU/Profiles/*.

fix #1865
jourdain added a commit that referenced this issue May 7, 2021
This change allow a better management for tree shaking but require the user to explicitly import the
classes that will be required

BREAKING CHANGE: Explicit import needs to be performed to enable rendering implementation. Profiles
have been created to simplify that task. See vtk.js/Sources/Rendering/OpenGL|WebGPU/Profiles/*.

fix #1865
@github-actions
Copy link

github-actions bot commented May 7, 2021

🎉 This issue has been resolved in version 18.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label May 7, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
module: build released Automated label status: confirmed Could be reproduced by a main contributor type: feature request 💡 Desired capabilities / enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants