A Rollup plugin for optimising inline GLSL shaders in JavaScript or TypeScript files. Current stable version is 1.5.2, with a moderate release cadence. It processes template literals marked with a GLSL hint (e.g., `/* glsl */`), enabling shader minification and injection of uniform/attribute definitions directly in your bundle. Unlike generic GLSL loaders, this plugin focuses on inline shader strings within existing JS files, integrating seamlessly with Rollup's build pipeline. It supports Rollup 3 and 4, requiring Node.js ^20.19.0, ^22.21.0, or >=24.12.0. The plugin is configurable via include/exclude globs and an enabled flag.
npm install rollup-shader-chunksVerified import paths — ran on the pinned version, not inferred.
Sets up the plugin in a Rollup config, processes inline GLSL shaders marked with /* glsl */ comment.
Upgrade Node.js to a supported version: ^20.19.0, ^22.21.0, or >=24.12.0.
Use import { shaderChunks } from 'rollup-shader-chunks' or use dynamic import if in CommonJS context.Replace import { createShaderChunks } with import { shaderChunks }.Use the exact comment syntax: `/* glsl */` before the template literal.
For external files, use a GLSL loader plugin (e.g., rollup-plugin-glsl) instead.
Check if the package includes types via exports; otherwise define your own or use skipLibCheck.
Use import { shaderChunks } from 'rollup-shader-chunks' or enable ESM in your project (e.g., type: 'module' in package.json).Replace import shaderChunks from 'rollup-shader-chunks' with import { shaderChunks } from 'rollup-shader-chunks'.Call shaderChunks({ include: ['**/*.js'] }) or shaderChunks() with no arguments.