{"record":{"id":"bae22baa77054e4c","repo":"remix-run/remix","slug":"loader-failed","errorCode":"LOADER_FAILED","errorMessage":"Module loader failed for ${loaderUrl}. ${formatUnknownError(error)}","messagePattern":"Module loader failed for (.+?)\\. (.+?)","errorType":"error_code","errorClass":"AssetServerCompilationError","httpStatus":null,"severity":"error","filePath":"packages/assets/src/lib/scripts/transform.ts","lineNumber":503,"sourceCode":"  if (options.loaders.length > 0) {\n    let loaderUrl = pathToFileURL(resolvedPath).href\n    let loaderInputSource = sourceMap ? appendInlineSourceMap(rawCode, sourceMap) : rawCode\n    let loaderOutputSource: string\n    try {\n      let loaderResult = runModuleLoaders(loaderUrl, {\n        format: 'module',\n        loaders: options.loaders,\n        moduleUrl: options.moduleUrl,\n        source: loaderInputSource,\n      })\n      loaderOutputSource = moduleLoadSourceToString(getModuleLoadSource(loaderUrl, loaderResult))\n    } catch (error) {\n      if (isAssetServerCompilationError(error)) throw error\n      throw createAssetServerCompilationError(\n        `Module loader failed for ${loaderUrl}. ${formatUnknownError(error)}`,\n        {\n          cause: error,\n          code: 'LOADER_FAILED',\n        },\n      )\n    }\n    if (loaderOutputSource !== loaderInputSource) {\n      let loaderOutput = extractInlineSourceMap(loaderOutputSource)\n      rawCode = loaderOutput.code.trimEnd()\n      sourceMap =\n        loaderOutput.sourceMap && loaderOutput.sourceMap !== sourceMap\n          ? sourceMap\n            ? composeSourceMaps(loaderOutput.sourceMap, sourceMap)\n            : loaderOutput.sourceMap\n          : null\n    }\n  }\n\n  if (options.minify) {\n    let minifyResult = await minifyModule(rawCode, resolvedPath, options.target, options.sourceMaps)\n    rawCode = minifyResult.code.trimEnd()","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assets/src/lib/scripts/transform.ts#L485-L521","documentation":"After the initial transform, module loaders run and any exception escaping them (other than pre-wrapped compilation errors) is rethrown as LOADER_FAILED for the specific loaderUrl. The formatted original error is embedded, so the message tells you which loader stage failed and why.","triggerScenarios":"A registered module loader throwing during load/transform of a module — e.g. a loader that can't fetch its input, a loader with a bug, or a loader applying an incompatible transform (CSS loader on JS, etc.).","commonSituations":"Custom loaders hitting filesystem/network failures; loader version skew after upgrades; loaders assuming a format (TS, JSON, CSS) that doesn't match the file extension; loaders with unhandled edge cases on empty or generated files.","solutions":["Read the full message and error.cause to identify which loader threw and why","Fix the loader's handling for that file type/URL, or narrow the loader's matching pattern so it doesn't apply to the failing module","Verify the input file the loader tried to read exists and is readable at loaderUrl","Pin/upgrade the loader package to a version compatible with this pipeline"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// in dev, smoke-test each loader with a known-good module before wiring into the chain","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (isAssetServerCompilationError(e) && e.code === 'LOADER_FAILED') {\n    // message names loaderUrl and embeds the loader's own error — surface both\n  }\n}","preventionTips":["Scope each loader narrowly by extension/URL pattern","Handle fetch/read failures inside the loader with clear errors instead of letting them escape","Write unit tests per loader over the file types it claims"],"tags":["module-loader","loader-chain","assets"],"backgroundTag":"module-loader-failed","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}