{"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,"search_vec":"'1.5.2':22 '20.19.0':81 '22.21.0':82 '24.12.0':84 '3':76 '4':78 'build':71 'bundl':50 'cadenc':27 'chunk':4 'configur':88 'current':18 'definit':46 'direct':47 'e.g':37 'enabl':39,94 'exist':63 'file':17,65 'flag':95 'focus':57 'generic':52 'glob':91 'glsl':11,35,38,53,101 'hint':36 'include/exclude':90 'inject':43 'inlin':10,59 'integr':66 'javascript':14,96 'js':64 'liter':31 'loader':54 'mark':32 'minif':41 'moder':25 'node.js':80 'optimis':9 'pipelin':72 'plugin':7,56,86,100,102 'process':29 'releas':26 'renderlay':97 'requir':79 'rollup':2,6,69,75,99 'rollup-plugin':98 'rollup-shader-chunk':1 'seamless':67 'shader':3,12,40,60 'stabl':19 'string':61 'support':74 'templat':30 'typescript':16 'uniform/attribute':45 'unlik':51 'version':20 'via':89 'within':62","created_at":"2026-04-27T17:04:29.759653+00:00","updated_at":"2026-04-27T17:04:29.759653+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/epreston/rollup-shader-chunks","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-shader-chunks","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}