Building Three.js Bundle with Shader Code as Separate Files?

Hello Three.js community!

Firstly, for anyone whose contributed I want to express my gratitude for your work on this fantastic library. It has been instrumental in many of my 3D projects!

I’m writing this issue to propose / get a temperature check on a potential enhancement to the build process of Three.js. Currently, the GLSL shader code for built-in materials like MeshBasicMaterial is included directly in the Three.js bundle. This approach, while straightforward, increases the size of the final JavaScript bundle and makes it harder for developers to manage and optimize their application’s performance.

I propose considering a way to build the Three.js bundle such that the shader code is included as separate files. This could potentially reduce the size of the main Three.js bundle and allow developers to load only the shaders they need for their specific use case.

I understand that this would be a significant change to the build process and could potentially introduce complexities. However, I believe that it could provide benefits in terms of performance optimization and flexibility for developers.

I would love to hear peoples thoughts on this proposal. If there’s any way I can assist in exploring this idea further, please let me know. If it seems feasible I’d persue this by opening up a GH issue on the topic.

Thanks,
Luke