{"id":22044,"library":"rollup-plugin-gltf","title":"rollup-plugin-gltf","description":"A Rollup plugin for optimizing glTF 3D models during the bundling process, version 4.0.0. It integrates with the @gltf-transform ecosystem (core, extensions, functions) to apply transforms such as texture resizing, mesh deduplication, and quantization. Unlike manual CLI tools, it runs as part of a Rollup build, enabling per-file transforms and caching. The plugin is maintained by The New York Times R&D team and is released as-is. Compatible with Rollup 3+ and requires peer dependencies @gltf-transform/core, @gltf-transform/extensions, and @gltf-transform/functions at version 3.x.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/nytimes/rd-bundler-3d-plugins","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-gltf","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-gltf","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-gltf","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for glTF processing; peer dependency at version 3.x","package":"@gltf-transform/core","optional":false},{"reason":"Provides glTF extensions support; peer dependency at version 3.x","package":"@gltf-transform/extensions","optional":false},{"reason":"Provides transformation functions like textureResize; peer dependency at version 3.x","package":"@gltf-transform/functions","optional":false}],"imports":[{"note":"Package is ESM-only; CommonJS require will fail (module not found). Use dynamic import if needed.","wrong":"const gltf = require('rollup-plugin-gltf');","symbol":"default (gltf)","correct":"import gltf from 'rollup-plugin-gltf';"},{"note":"TypeScript users can import the options type for better autocompletion. Not available in CJS.","symbol":"gltf function type (TypeScript)","correct":"import type { GltfOptions } from 'rollup-plugin-gltf';"},{"note":"The gltf function returns a plugin object; do not use 'new'. Options object required, even if empty.","wrong":"new gltf({ transforms: [] })","symbol":"Plugin instance","correct":"gltf({ transforms: [textureResize({size: [1024, 1024]})] })"}],"quickstart":{"code":"// rollup.config.js\nimport gltf from 'rollup-plugin-gltf';\nimport { textureResize } from '@gltf-transform/functions';\nimport { dedup } from '@gltf-transform/functions';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    gltf({\n      transforms: [\n        textureResize({ size: [1024, 1024] }),\n        dedup()\n      ]\n    })\n  ]\n};","lang":"typescript","description":"Rollup configuration that optimizes glTF files by resizing textures to 1024x1024 and deduplicating meshes during build."},"warnings":[{"fix":"Ensure package.json includes '@gltf-transform/core': '^3.0.0'","message":"Peer dependency @gltf-transform/core must be version 3.x; installing version 2.x will cause type errors.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use import syntax or dynamic import() in CJS projects. Convert project to ESM if possible.","message":"ESM-only: require() will throw ERR_MODULE_NOT_FOUND or similar.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always provide transforms as an array, e.g., gltf({ transforms: [myTransform] })","message":"The 'transforms' option must be an array; passing a single function or missing property will cause transform to be silently skipped.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace compress: true with transforms: [/* appropriate functions */]","message":"The 'compress' option was removed in v4, use transforms with @gltf-transform/functions instead.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Switch to import syntax or use dynamic import: const gltf = (await import('rollup-plugin-gltf')).default;","cause":"Using require() in a CommonJS file; package is ESM-only.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'rollup-plugin-gltf'"},{"fix":"Use 'import gltf from 'rollup-plugin-gltf'' and ensure your project is configured for ESM.","cause":"Importing default incorrectly or using CJS require which returns an empty object.","error":"TypeError: gltf is not a function"},{"fix":"Run: npm install --save-dev @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions","cause":"Missing peer dependencies; required at runtime.","error":"Cannot find module '@gltf-transform/core' or '@gltf-transform/functions'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}