{"record":{"id":"f61ec2a68d7579c2","repo":"keycloak/keycloak","slug":"unresolved-import-warning-exporter","errorCode":null,"errorMessage":"Unresolved import: ${warning.exporter}","messagePattern":"Unresolved import: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"js/themes-vendor/rollup.config.js","lineNumber":27,"sourceCode":"  nodeResolve(),\n  commonjs({\n    strictRequires: \"auto\",\n  }),\n  replace({\n    preventAssignment: true,\n    // React depends on process.env.NODE_ENV to determine which code to include for production.\n    // This ensures that no additional code meant for development is included in the build.\n    \"process.env.NODE_ENV\": '\"production\"',\n  }),\n  terser(),\n];\n\nconst targetDir = \"target/classes/theme/keycloak/common/resources/vendor\";\n\n/** @type{import(\"rollup\").WarningHandlerWithDefault} */\nfunction onwarn(warning, defaultHandler) {\n  if (warning.code === \"UNRESOLVED_IMPORT\") {\n    throw new Error(`Unresolved import: ${warning.exporter}`);\n  }\n\n  defaultHandler(warning);\n}\n\nexport default defineConfig([\n  {\n    input: [\n      \"node_modules/react/cjs/react.production.min.js\",\n      \"node_modules/react/cjs/react-jsx-runtime.production.min.js\",\n    ],\n    output: {\n      dir: path.join(targetDir, \"react\"),\n      format: \"es\",\n    },\n    plugins,\n    onwarn,\n  },","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/keycloak/keycloak/blob/66c7e15a3788de7764f07dd2558275a02770e16d/js/themes-vendor/rollup.config.js#L9-L45","documentation":"Thrown by the custom Rollup onwarn handler in js/themes-vendor/rollup.config.js when Rollup raises an UNRESOLVED_IMPORT warning. The themes-vendor build bundles the React/React-DOM production minified sources; it treats any module specifier that @rollup/plugin-node-resolve cannot locate in node_modules (and that is not declared as external) as fatal. warning.exporter names the exact offending specifier.","triggerScenarios":"Running the themes-vendor build (npm run build / the Maven frontend goal) when react.production.min.js, react-jsx-runtime.production.min.js, or react-dom.production.min.js pulls in a bare import that is neither present under node_modules nor listed in the bundle's external array.","commonSituations":"node_modules not installed or only partially restored (npm ci skipped, CI cache miss); a transitive/peer dependency removed by deduping or a version bump; lockfile drift; running the build from a clean checkout without restoring js/themes-vendor/node_modules.","solutions":["Run `npm ci` (or `npm install`) inside js/themes-vendor to fully restore node_modules, then rebuild.","Read the full Rollup diagnostics to find the exact exporter, then confirm js/themes-vendor/node_modules/<exporter> exists.","If the missing specifier is intentionally supplied by the host page or another bundle, add it to that bundle's `external` array in rollup.config.js.","Delete node_modules and package-lock.json, reinstall from the committed lockfile to rule out a corrupted partial install."],"exampleFix":"// before: 'some-peer-lib' is referenced but missing and not declared external\n{\n  input: \"node_modules/react-dom/cjs/react-dom.production.min.js\",\n  external: [\"react\"],\n}\n// after: declare it external so Rollup leaves the import intact\n{\n  input: \"node_modules/react-dom/cjs/react-dom.production.min.js\",\n  external: [\"react\", \"some-peer-lib\"],\n}","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nfor (const dep of [\"react\", \"react-dom\"]) {\n  if (!existsSync(`js/themes-vendor/node_modules/${dep}`)) {\n    throw new Error(`Missing dependency '${dep}' -- run: npm ci --prefix js/themes-vendor`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restore node_modules from the committed lockfile (npm ci) in CI instead of trusting a cached/partial tree.","Keep each bundle's `external` list in rollup.config.js in sync with packages you intentionally exclude.","Read warning.exporter first: it is the exact specifier Rollup failed to resolve."],"tags":["rollup","build","bundling","javascript","node-modules"],"backgroundTag":null,"analyzedSha":"66c7e15a3788de7764f07dd2558275a02770e16d","analyzedAt":"2026-08-14T01:36:42.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}