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

Disable certain unused modules on build #68

Open
nicolasfranck opened this issue Feb 1, 2024 · 2 comments
Open

Disable certain unused modules on build #68

nicolasfranck opened this issue Feb 1, 2024 · 2 comments

Comments

@nicolasfranck
Copy link

As a

developer

I want

a way to reduce the built project size by removing unused components.

For example, we do not use the youtube or 3D components, but they
are part of the generated output. I know that all modules are exported
in separated files, but I am not sure if deleting them is safe,
or leads to internal loading errors. Also not always sure which ones
to delete.

@demiankatz
Copy link
Collaborator

Based on my (admittedly quite limited) understanding of Webpack, I believe that modules should only be downloaded by the user when they are actually needed. The problem is defining what "actually needed" means, since this is based on Webpack's analysis of the code (and particularly the way modules require one another). If everything is perfectly designed, and Webpack works perfectly, then you should be able to delete bundles for unwanted modules, and no one will ever notice the difference. (Probably the best way to achieve this would be to delete the unwanted source folders prior to the build, to ensure that Webpack doesn't output anything related to those modules, rather than trying to figure out which files to delete after the fact). However, it's rare for everything to be perfect, so it's very possible that there are some interdependencies that can't be so easily broken (I would imagine, for example, it's possible that the bootstrapping code includes enough references to all of the modules that Webpack would fuss if you deleted things). In any case, it might be interesting to do some experiments and see what happens, but there's probably not a totally easy and straightforward answer to this at present.

@demiankatz
Copy link
Collaborator

I would definitely be interested, at least theoretically, in having a UV architecture that was more pluggable, so modules could be dropped in and out seamlessly without the need to explicitly reference them in bootstrapping logic. But I'm not really sure how we could achieve that in a Typescript project. (I have a lot more experience with PHP architecture, which has a significantly different set of capabilities and limitations).

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

No branches or pull requests

2 participants