Registry / devops / rollup-shader-chunks

rollup-shader-chunks

JSON →
library1.5.2jsnpmunverified

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-chunks
INSTALL
IMPORT
SIG · ROLLUP-SHADER-CHUN
R
rollup-shader-chunks
devopsjavascriptv1.5.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

shaderChunks
✓ import { shaderChunks } from 'rollup-shader-chunks'
✗ import shaderChunks from 'rollup-shader-chunks'
The plugin exports a named function, not a default export. Use named import syntax.
ShaderChunksOptions
✓ import type { ShaderChunksOptions } from 'rollup-shader-chunks'
✗ import { ShaderChunksOptions } from 'rollup-shader-chunks'
TypeScript users should use 'import type' to avoid runtime side effects. This is a type-only export.
createShaderChunks
✓ import { createShaderChunks } from 'rollup-shader-chunks'
✗ const createShaderChunks = require('rollup-shader-chunks')
The package is ESM-only. CommonJS require() will throw an error. Use dynamic import if needed.

Sets up the plugin in a Rollup config, processes inline GLSL shaders marked with /* glsl */ comment.

// Install: npm i rollup-shader-chunks --save-dev // rollup.config.js import { shaderChunks } from 'rollup-shader-chunks'; export default { input: 'src/index.js', plugins: [ shaderChunks({ include: ['**/*.js'], exclude: ['**/*.min.js'], enabled: true }) ], output: { dir: 'dist', format: 'es' } }; // src/index.js const vertexShader = /* glsl */ ` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `;
Debug
Known issues
breakingNode.js version requirement changed in v1.5.0: requires ^20.19.0, ^22.21.0, or >=24.12.0. Older Node versions (e.g., 18.x, 20.0-20.18) are no longer supported.
fix
Upgrade Node.js to a supported version: ^20.19.0, ^22.21.0, or >=24.12.0.
affects: >=1.5.0
breakingPackage is ESM-only. Using require('rollup-shader-chunks') throws ERR_REQUIRE_ESM.
fix
Use import { shaderChunks } from 'rollup-shader-chunks' or use dynamic import if in CommonJS context.
affects: >=1.0.0
deprecatedThe 'createShaderChunks' export was deprecated in v1.4.0 and may be removed. Use 'shaderChunks' instead.
fix
Replace import { createShaderChunks } with import { shaderChunks }.
affects: >=1.4.0
gotchaShader comments /* glsl */ must be exactly as shown. Variations like /*glsl*/ (no space) or // glsl will not be recognized.
fix
Use the exact comment syntax: `/* glsl */` before the template literal.
affects: >=1.0.0
gotchaThe plugin does not support external GLSL files; it only processes inline strings within JavaScript/TypeScript files.
fix
For external files, use a GLSL loader plugin (e.g., rollup-plugin-glsl) instead.
affects: >=1.0.0
gotchaTypeScript types are not bundled; you must install @types/rollup-shader-chunks separately or use the package's own types if provided.
fix
Check if the package includes types via exports; otherwise define your own or use skipLibCheck.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/rollup-shader-chunks/index.js not supported.
The package is ESM-only and cannot be loaded with CommonJS require().
fix
Use import { shaderChunks } from 'rollup-shader-chunks' or enable ESM in your project (e.g., type: 'module' in package.json).
TypeError: shaderChunks is not a function
Default import used instead of named import.
fix
Replace import shaderChunks from 'rollup-shader-chunks' with import { shaderChunks } from 'rollup-shader-chunks'.
Module build failed: Error: The plugin 'shaderChunks' must be called with a options object or nothing.
Calling shaderChunks() with a function or null argument.
fix
Call shaderChunks({ include: ['**/*.js'] }) or shaderChunks() with no arguments.
Upgrade
Version history
1.5.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency - the plugin works as a Rollup plugin and requires Rollup 3 or 4.
Agent activity
6 hits · last 30 days
node
6
Resources