{"record":{"id":"91fe027efb32c727","repo":"remix-run/remix","slug":"files-globaltransforms-index-must-be-a-functio","errorCode":null,"errorMessage":"files.globalTransforms[${index}] must be a function or object","messagePattern":"files\\.globalTransforms\\[(.+?)\\] must be a function or object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/assets/src/lib/files/config.ts","lineNumber":270,"sourceCode":"      ),\n    })\n  }\n\n  let globalTransforms = files.globalTransforms ?? []\n  if (!Array.isArray(globalTransforms)) {\n    throw new TypeError('files.globalTransforms must be an array')\n  }\n\n  let normalizedGlobalTransforms: ResolvedAssetGlobalTransform[] = []\n\n  for (let [index, transform] of globalTransforms.entries()) {\n    if (typeof transform === 'function') {\n      normalizedGlobalTransforms.push({ transform })\n      continue\n    }\n\n    if (transform === null || typeof transform !== 'object') {\n      throw new TypeError(`files.globalTransforms[${index}] must be a function or object`)\n    }\n\n    if ('name' in transform && transform.name !== undefined && typeof transform.name !== 'string') {\n      throw new TypeError(`files.globalTransforms[${index}].name must be a string`)\n    }\n\n    if (typeof transform.transform !== 'function') {\n      throw new TypeError(`files.globalTransforms[${index}] must define a transform() function`)\n    }\n\n    normalizedGlobalTransforms.push({\n      ...transform,\n      extensions: normalizeTransformExtensions(\n        transform.extensions,\n        `files.globalTransforms[${index}].extensions`,\n      ),\n    })\n  }","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assets/src/lib/files/config.ts#L252-L288","documentation":"Each element of `files.globalTransforms` must be either a bare transform function or an object definition. This error fires when an entry is null, a primitive (string/number/boolean), or otherwise neither function nor object.","triggerScenarios":"`globalTransforms: ['minify']` (string), `[null]`, or `[42]` — e.g. passing a transform name instead of the imported function.","commonSituations":"Passing a plugin name string instead of the imported function; sparse arrays from `.map()` on mis-shaped data; optional imports resolving to undefined.","solutions":["Pass the function itself: `globalTransforms: [minify]` not `['minify']`","Filter out falsy entries if the list is built dynamically: `list.filter(Boolean)`","For object entries, make sure they include a `transform` function (see adjacent error)"],"exampleFix":"// before\nfiles: { globalTransforms: ['minify'] }\n// after\nimport { minify } from './minify.ts'\nfiles: { globalTransforms: [minify] }","handlingStrategy":"validation","validationCode":"files.globalTransforms?.forEach((t, i) => {\n  if (typeof t !== 'function' && (t === null || typeof t !== 'object')) {\n    throw new Error(`globalTransforms[${i}] must be a function or object`)\n  }\n})","typeGuard":"function isTransformEntry(t: unknown): boolean {\n  return typeof t === 'function' || (!!t && typeof t === 'object')\n}","tryCatchPattern":null,"preventionTips":["Pass imported functions, not their names as strings","Filter Boolean on dynamically built lists"],"tags":["config","files","transforms","validation"],"backgroundTag":"config-type-validation","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}