# Importing WebGL-only or WebGPU-only

**URL:** <https://forum.babylonjs.com/t/importing-webgl-only-or-webgpu-only/60435>\
**Category:** Feature requests\
**Tags:** import, webpack, size\
**Created:** [September 10, 2025, 3:21am UTC](https://forum.babylonjs.com/t/importing-webgl-only-or-webgpu-only/60435 "2025-09-10T03:21:53Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [September 10, 2025, 3:21am UTC](https://forum.babylonjs.com/t/importing-webgl-only-or-webgpu-only/60435/1 "2025-09-10T03:21:53Z")

</div>

## Background

As recent development babylon.js is making dual-version shaders, one for WebGL, and one for WebGPU. But the shaders are imported via side effect and can not be tree-shaked by bundlers, that makes final packaged size grow in recent versions.

Here is a graph from [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) that shows both Shaders and ShadersWGSL are kept in the final package, and takes considerable size.

 ![graph of webpack-bundle-analyzer](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/7/e7e59d257051f7749c6c3ee7d364e7f6d2a2edae.png)

## Proposal

Add WebGL-only and WebGPU-only variants for each index.ts file, taking `Meshes/index.ts` for example:

> <https://github.com/BabylonJS/Babylon.js/blob/447517cdb1e15b7141e5a49a5be070c7ee4755d3/packages/dev/core/src/Meshes/index.ts#L47>

A `Meshes/index-webgl.ts` contains only import/exports from `Shaders`, and a `Meshes/index-webgpu.ts` contains only import/exports from `ShadersWGSL`.  
Also, when importing from other `index` file, like `export * from "./fluidRenderer/index";` would be `export * from "./fluidRenderer/index-webgl";` or `export * from "./fluidRenderer/index-webgpu";`

## Alternative

- Do not import from any `index` file, and manually import only files needed, which could be a major overhead to downstream devs.
- Compile shaders to space-efficient compressed bytecode format and recover at runtime, which could make loading slower.
- Configure bundlers to ignore shader imports globally

---

_[View the full topic](https://forum.babylonjs.com/t/importing-webgl-only-or-webgpu-only/60435)._
