{"id":22311,"library":"rollup-shader-chunks","title":"rollup-shader-chunks","description":"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.","status":"active","version":"1.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/epreston/rollup-shader-chunks","tags":["javascript","renderlayer","rollup-plugin","glsl","plugin"],"install":[{"cmd":"npm install rollup-shader-chunks","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-shader-chunks","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-shader-chunks","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency - the plugin works as a Rollup plugin and requires Rollup 3 or 4.","package":"rollup","optional":false}],"imports":[{"note":"The plugin exports a named function, not a default export. Use named import syntax.","wrong":"import shaderChunks from 'rollup-shader-chunks'","symbol":"shaderChunks","correct":"import { shaderChunks } from 'rollup-shader-chunks'"},{"note":"TypeScript users should use 'import type' to avoid runtime side effects. This is a type-only export.","wrong":"import { ShaderChunksOptions } from 'rollup-shader-chunks'","symbol":"ShaderChunksOptions","correct":"import type { ShaderChunksOptions } from 'rollup-shader-chunks'"},{"note":"The package is ESM-only. CommonJS require() will throw an error. Use dynamic import if needed.","wrong":"const createShaderChunks = require('rollup-shader-chunks')","symbol":"createShaderChunks","correct":"import { createShaderChunks } from 'rollup-shader-chunks'"}],"quickstart":{"code":"// Install: npm i rollup-shader-chunks --save-dev\n// rollup.config.js\nimport { shaderChunks } from 'rollup-shader-chunks';\n\nexport default {\n  input: 'src/index.js',\n  plugins: [\n    shaderChunks({\n      include: ['**/*.js'],\n      exclude: ['**/*.min.js'],\n      enabled: true\n    })\n  ],\n  output: {\n    dir: 'dist',\n    format: 'es'\n  }\n};\n\n// src/index.js\nconst vertexShader = /* glsl */ `\n  void main() {\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n  }\n`;","lang":"typescript","description":"Sets up the plugin in a Rollup config, processes inline GLSL shaders marked with /* glsl */ comment."},"warnings":[{"fix":"Upgrade Node.js to a supported version: ^20.19.0, ^22.21.0, or >=24.12.0.","message":"Node.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.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Use import { shaderChunks } from 'rollup-shader-chunks' or use dynamic import if in CommonJS context.","message":"Package is ESM-only. Using require('rollup-shader-chunks') throws ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Replace import { createShaderChunks } with import { shaderChunks }.","message":"The 'createShaderChunks' export was deprecated in v1.4.0 and may be removed. Use 'shaderChunks' instead.","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"Use the exact comment syntax: `/* glsl */` before the template literal.","message":"Shader comments /* glsl */ must be exactly as shown. Variations like /*glsl*/ (no space) or // glsl will not be recognized.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For external files, use a GLSL loader plugin (e.g., rollup-plugin-glsl) instead.","message":"The plugin does not support external GLSL files; it only processes inline strings within JavaScript/TypeScript files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check if the package includes types via exports; otherwise define your own or use skipLibCheck.","message":"TypeScript types are not bundled; you must install @types/rollup-shader-chunks separately or use the package's own types if provided.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import { shaderChunks } from 'rollup-shader-chunks' or enable ESM in your project (e.g., type: 'module' in package.json).","cause":"The package is ESM-only and cannot be loaded with CommonJS require().","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/rollup-shader-chunks/index.js not supported."},{"fix":"Replace import shaderChunks from 'rollup-shader-chunks' with import { shaderChunks } from 'rollup-shader-chunks'.","cause":"Default import used instead of named import.","error":"TypeError: shaderChunks is not a function"},{"fix":"Call shaderChunks({ include: ['**/*.js'] }) or shaderChunks() with no arguments.","cause":"Calling shaderChunks() with a function or null argument.","error":"Module build failed: Error: The plugin 'shaderChunks' must be called with a options object or nothing."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}