{"record":{"id":"4fde9a8802ea2af2","repo":"sveltejs/kit","slug":"could-not-load-resolved-id","errorCode":null,"errorMessage":"Could not load ${resolved_id}","messagePattern":"Could not load (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/enhanced-img/src/vite-plugin.js","lineNumber":240,"sourceCode":"\t};\n\treturn plugin;\n}\n\n/**\n * @param {string} resolved_id\n * @param {import('vite').Rollup.PluginContext} plugin_context\n * @param {import('vite').Plugin} imagetools_plugin\n * @returns {Promise<import('vite-imagetools').Picture>}\n */\nasync function process_id(resolved_id, plugin_context, imagetools_plugin) {\n\tif (!imagetools_plugin.load) {\n\t\tthrow new Error('Invalid instance of vite-imagetools. Could not find load method.');\n\t}\n\tconst hook = imagetools_plugin.load;\n\tconst handler = typeof hook === 'object' ? hook.handler : hook;\n\tconst module_info = await handler.call(plugin_context, resolved_id);\n\tif (!module_info) {\n\t\tthrow new Error(`Could not load ${resolved_id}`);\n\t}\n\tconst code = typeof module_info === 'string' ? module_info : module_info.code;\n\treturn parse_object(code.replace('export default', '').replace(/;$/, '').trim());\n}\n\n/**\n * @param {string} str\n */\nexport function parse_object(str) {\n\tconst updated = str\n\t\t.replaceAll(/{(\\n\\s*)?/gm, '{\"')\n\t\t.replaceAll(':', '\":')\n\t\t.replaceAll(/,(\\n\\s*)?([^ ])/g, ',\"$2');\n\ttry {\n\t\treturn JSON.parse(updated);\n\t} catch {\n\t\tthrow new Error(`Failed parsing string to object: ${str}`);\n\t}","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/enhanced-img/src/vite-plugin.js#L222-L258","documentation":"enhanced-img delegates image loading/transformation to vite-imagetools' load hook. When calling that hook for a resolved id returns nothing (falsy module info), enhanced-img cannot produce the image module and throws.","triggerScenarios":"`process_id` invokes the imagetools plugin's load handler with the resolved id and receives undefined/null — the imagetools plugin did not handle the id (e.g. wrong extension or missing query params for optimization).","commonSituations":"An incompatible or misconfigured vite-imagetools instance, an image id that imagetools does not consider optimizable, or the imagetools plugin being replaced/absent so its load hook returns nothing.","solutions":["Verify a compatible vite-imagetools version is installed and included in the Vite plugins","Ensure the image URL uses optimizable extensions and expected query parameters (e.g. ?w=800&format=webp)","Reinstall node_modules to clear mismatched plugin hoisting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (String(e.message).startsWith('Could not load')) {\n    console.error('vite-imagetools failed to handle the image; check plugin config/version');\n  }\n  throw e;\n}","preventionTips":["Keep vite-imagetools at the version enhanced-img expects","Use supported image extensions and query params","Reinstall node_modules when plugin errors appear after upgrades"],"tags":["vite","imagetools","image-optimization","plugin"],"backgroundTag":"plugin-load-hook-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}