{"record":{"id":"599245c13d0f4312","repo":"mdx-js/mdx","slug":"expected-jsx-given-to-evaluate","errorCode":null,"errorMessage":"Expected `jsx` given to `evaluate`","messagePattern":"Expected `jsx` given to `evaluate`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mdx/lib/util/resolve-evaluate-options.js","lineNumber":74,"sourceCode":" *   Split options.\n */\nexport function resolveEvaluateOptions(options) {\n  const {\n    Fragment,\n    baseUrl,\n    development,\n    jsx,\n    jsxDEV,\n    jsxs,\n    useMDXComponents,\n    ...rest\n  } = options || {}\n\n  if (!Fragment) throw new Error('Expected `Fragment` given to `evaluate`')\n  if (development) {\n    if (!jsxDEV) throw new Error('Expected `jsxDEV` given to `evaluate`')\n  } else {\n    if (!jsx) throw new Error('Expected `jsx` given to `evaluate`')\n    if (!jsxs) throw new Error('Expected `jsxs` given to `evaluate`')\n  }\n\n  return {\n    compiletime: {\n      ...rest,\n      development,\n      outputFormat: 'function-body',\n      providerImportSource: useMDXComponents ? '#' : undefined\n    },\n    runtime: {Fragment, baseUrl, jsx, jsxDEV, jsxs, useMDXComponents}\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":88,"githubUrl":"https://github.com/mdx-js/mdx/blob/685627a819567c0788eadb85f5f57065bcc81c2c/packages/mdx/lib/util/resolve-evaluate-options.js#L56-L88","documentation":"In production mode (`development` falsy), the compiled MDX code calls `jsx` for single-child/element creation, so resolveEvaluateOptions requires `jsx` in the evaluate options. Without it the generated program cannot run, and MDX throws this error up front instead of failing later with a ReferenceError.","triggerScenarios":"Calling `evaluate(code, { Fragment, jsxs })` without `jsx`; providing only `jsxDEV` while leaving `development` falsy; spreading a partial runtime object that lacks `jsx`.","commonSituations":"Hand-rolled runtime objects in Node scripts evaluating MDX; tree-shaking or bundling dropping the `jsx` import as unused; mixing dev/prod exports (passing jsxDEV but not jsx/jsxs).","solutions":["Add `jsx` from 'react/jsx-runtime' (or your library's equivalent) to the evaluate options.","Ensure `development` correctly reflects the runtime you imported: prod needs `jsx`+`jsxs`, dev needs `jsxDEV`.","Import the complete runtime object (`Fragment, jsx, jsxs`) together so none can be dropped."],"exampleFix":"// before\nawait evaluate(code, { Fragment, jsxs })\n// after\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime'\nawait evaluate(code, { Fragment, jsx, jsxs })","handlingStrategy":"validation","validationCode":"if (!development && !runtime.jsx) {\n  throw new Error('evaluate options require `jsx` when development is falsy')\n}","typeGuard":"function hasJsx(rt) {\n  return typeof rt === 'object' && rt !== null && typeof rt.jsx === 'function'\n}","tryCatchPattern":"try {\n  const result = await evaluate(code, runtime)\n} catch (err) {\n  if (err.message === 'Expected `jsx` given to `evaluate`') {\n    console.error('Provide jsx from your jsx-runtime in evaluate options')\n  } else throw err\n}","preventionTips":["Always spread a complete runtime: `{ Fragment, jsx, jsxs }` from 'react/jsx-runtime'.","Avoid destructure-and-rebuild patterns that can drop fields.","Add a unit test that evaluates a trivial MDX document in production mode."],"tags":["mdx","evaluate","configuration"],"backgroundTag":"missing-required-option","analyzedSha":"685627a819567c0788eadb85f5f57065bcc81c2c","analyzedAt":"2026-09-02T16:11:18.599Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}