Registry / devops / rollup-plugin-gltf

rollup-plugin-gltf

JSON →
library4.0.0jsnpmunverified

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.

npm install rollup-plugin-gltf
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-GLTF
R
rollup-plugin-gltf
devopsjavascriptv4.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default (gltf)
import gltf from 'rollup-plugin-gltf';
const gltf = require('rollup-plugin-gltf');
Package is ESM-only; CommonJS require will fail (module not found). Use dynamic import if needed.
gltf function type (TypeScript)
import type { GltfOptions } from 'rollup-plugin-gltf';
TypeScript users can import the options type for better autocompletion. Not available in CJS.
Plugin instance
gltf({ transforms: [textureResize({size: [1024, 1024]})] })
new gltf({ transforms: [] })
The gltf function returns a plugin object; do not use 'new'. Options object required, even if empty.

Rollup configuration that optimizes glTF files by resizing textures to 1024x1024 and deduplicating meshes during build.

// rollup.config.js import gltf from 'rollup-plugin-gltf'; import { textureResize } from '@gltf-transform/functions'; import { dedup } from '@gltf-transform/functions'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ gltf({ transforms: [ textureResize({ size: [1024, 1024] }), dedup() ] }) ] };
Debug
Known issues
breakingPeer dependency @gltf-transform/core must be version 3.x; installing version 2.x will cause type errors.
fix
Ensure package.json includes '@gltf-transform/core': '^3.0.0'
affects: >=4.0.0
breakingESM-only: require() will throw ERR_MODULE_NOT_FOUND or similar.
fix
Use import syntax or dynamic import() in CJS projects. Convert project to ESM if possible.
affects: >=3.0.0
gotchaThe 'transforms' option must be an array; passing a single function or missing property will cause transform to be silently skipped.
fix
Always provide transforms as an array, e.g., gltf({ transforms: [myTransform] })
affects: >=1.0.0
deprecatedThe 'compress' option was removed in v4, use transforms with @gltf-transform/functions instead.
fix
Replace compress: true with transforms: [/* appropriate functions */]
affects: >=4.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'rollup-plugin-gltf'
Using require() in a CommonJS file; package is ESM-only.
fix
Switch to import syntax or use dynamic import: const gltf = (await import('rollup-plugin-gltf')).default;
TypeError: gltf is not a function
Importing default incorrectly or using CJS require which returns an empty object.
fix
Use 'import gltf from 'rollup-plugin-gltf'' and ensure your project is configured for ESM.
Cannot find module '@gltf-transform/core' or '@gltf-transform/functions'
Missing peer dependencies; required at runtime.
fix
Run: npm install --save-dev @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
@gltf-transform/corerequiredCore library for glTF processing; peer dependency at version 3.x
@gltf-transform/extensionsrequiredProvides glTF extensions support; peer dependency at version 3.x
@gltf-transform/functionsrequiredProvides transformation functions like textureResize; peer dependency at version 3.x
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rollup-plugin-gltf — npm install rollup-plugin-gltf · libregistry