{"record":{"id":"dac17e8da0816719","repo":"asgeirtj/system_prompts_leaks","slug":"scheduler-missing-this-ds-s-dist-imports-sched","errorCode":null,"errorMessage":"[SCHEDULER_MISSING] this DS's dist/ imports 'scheduler' directly — usually react-dom leaked into the dist. Check the DS build's externals.","messagePattern":"\\[SCHEDULER_MISSING\\] this DS's dist/ imports 'scheduler' directly — usually react-dom leaked into the dist\\. Check the DS build's externals\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Anthropic/Claude Code/bundled-skills/design-sync/lib/bundle.mjs","lineNumber":115,"sourceCode":"function tt(o){return o!=null&&typeof o===\"object\"?(R.isValidElement(o)?(o.type&&o.type.$$typeof)||o.type:o.$$typeof):undefined}\nexports.typeOf=tt;\nexports.isElement=R.isValidElement;\nexports.isValidElementType=function(t){return typeof t===\"string\"||typeof t===\"function\"||t===R.Fragment||t===R.Suspense||t===R.StrictMode||t===R.Profiler||(t!=null&&typeof t===\"object\"&&t.$$typeof!=null)};\nexports.isFragment=function(o){return R.isValidElement(o)&&o.type===R.Fragment};\nexports.isSuspense=function(o){return R.isValidElement(o)&&o.type===R.Suspense};\nexports.isPortal=function(o){return o!=null&&o.$$typeof===PORTAL};\nexports.isForwardRef=function(o){return tt(o)===FWD};\nexports.isMemo=function(o){return tt(o)===MEMO};\nexports.isLazy=function(o){return tt(o)===LAZY};\nexports.isContextProvider=exports.isContextConsumer=exports.isProfiler=exports.isStrictMode=function(){return false};\nexports.ForwardRef=FWD;exports.Memo=MEMO;exports.Portal=PORTAL;exports.Lazy=LAZY;\nexports.Fragment=R.Fragment;exports.Suspense=R.Suspense;exports.StrictMode=R.StrictMode;exports.Profiler=R.Profiler;`,\n      loader: 'js',\n    }));\n    b.onLoad({ filter: /^scheduler-shim$/, namespace: 'shim' }, () => ({\n      // A DS dist/ rarely imports scheduler directly — when it does, it\n      // means react-dom leaked into the dist. Surface it.\n      contents: `throw new Error(\"[SCHEDULER_MISSING] this DS's dist/ imports 'scheduler' directly — usually react-dom leaked into the dist. Check the DS build's externals.\");`,\n      loader: 'js',\n    }));\n  },\n};\n\n// Build a resolve plugin from tsconfig compilerOptions.paths. esbuild's\n// built-in `tsconfig` option only applies paths to files covered by that\n// tsconfig, which the synth entry (in OUT) isn't — so we resolve explicitly.\nexport function tsconfigPathsPlugin(tsconfigPath) {\n  let paths, baseUrl;\n  try {\n    // Strip // and /* */ comments — tsconfig.json permits them, JSON.parse doesn't.\n    const raw = readFileSync(tsconfigPath, 'utf8')\n      .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n      .replace(/(^|[^:])\\/\\/.*$/gm, '$1');\n    ({ paths, baseUrl = '.' } = JSON.parse(raw).compilerOptions ?? {});\n  } catch { return null; }\n  if (!paths) return null;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/asgeirtj/system_prompts_leaks/blob/93c999115b300a6faac567830b0450a5478800cd/Anthropic/Claude Code/bundled-skills/design-sync/lib/bundle.mjs#L97-L133","documentation":"The design-sync bundler registers an esbuild resolve plugin (bundle.mjs:65) that redirects any import matching /^scheduler(\\/|$)/ to a 'scheduler-shim' module whose body is a bare throw (line 115). scheduler is React's internal scheduling dependency, pulled in transitively by react-dom; a properly externalized design-system dist/ never references it. If the dist/ does import scheduler, it means react-dom was inlined into the dist during the DS's own build rather than kept as an external/peer — shipping a second scheduler instance would break concurrent rendering (per the comment at line 63-64). The shim surfaces this as a loud, named error instead of a silent double-scheduler bug.","triggerScenarios":"The DS was built without react-dom in its externals, so its bundler inlined react-dom (which imports scheduler) into the dist/. When design-sync's esbuild pipeline bundles that dist/ into a preview, the scheduler import hits the shim and the throw fires during module evaluation of the built preview.","commonSituations":"DS build config (rollup/webpack/esbuild/vite) missing 'react-dom' in the `external` array. DS package.json listing react-dom under `dependencies` instead of `peerDependencies`, so the bundler treats it as a regular dep to inline. Migrating a DS from a standalone repo into a monorepo and losing the externals config. A DS build that was accidentally run in full-bundle mode (no externals at all).","solutions":["Add 'react-dom' (and 'react', 'scheduler') to the DS build's `external` array in its rollup/webpack/esbuild config, then rebuild the dist.","Ensure the DS package.json lists react-dom (and react) under `peerDependencies`, not `dependencies` — peer deps are never bundled.","Verify the fix: grep the rebuilt dist output for `scheduler` — a correct externalized dist has zero hits.","If the DS is third-party and you cannot rebuild it, contact the DS maintainer or pin to a DS version whose dist is correctly externalized."],"exampleFix":"// before — DS build config (e.g. rollup.config.js) with no externals\nexport default {\n  input: 'src/index.ts',\n  output: { file: 'dist/index.js', format: 'esm' },\n  // react-dom gets bundled into dist/, pulling in scheduler\n};\n\n// after — mark react/react-dom/scheduler as external\nexport default {\n  input: 'src/index.ts',\n  output: { file: 'dist/index.js', format: 'esm' },\n  external: ['react', 'react-dom', 'scheduler'],\n};\n// package.json: \"peerDependencies\": { \"react\": \">=18\", \"react-dom\": \">=18\" }","handlingStrategy":"validation","validationCode":"import { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n// Scan the DS dist for a direct scheduler import BEFORE running\n// the design-sync bundle step.\nfunction assertNoSchedulerInDist(distDir) {\n  const re = /(?:from\\s+['\"]scheduler['\"]|require\\s*\\(\\s*['\"]scheduler['\"])/;\n  for (const f of readdirSync(distDir)) {\n    if (!f.endsWith('.js') && !f.endsWith('.mjs')) continue;\n    if (re.test(readFileSync(join(distDir, f), 'utf8'))) {\n      throw new Error(`${f} imports scheduler — rebuild DS with react-dom external`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"// This is a build-time fail-fast: the throw lives in bundled output.\n// Catching it at runtime only masks the real problem (double scheduler).\n// Instead, fix the DS externals and rebuild — do NOT wrap in try/catch.","preventionTips":["Keep react, react-dom, and scheduler in the DS build config's `external` array at all times — never remove them.","List react and react-dom under `peerDependencies` (not `dependencies`) in the DS package.json so no bundler inlines them.","Add a CI grep step that fails if the published dist/ contains the string 'scheduler' — a correct externalized dist never does.","When migrating a DS into or out of a monorepo, diff the build config's externals explicitly — this is the most common way they get lost."],"tags":["build","react","react-dom","externals","bundling","esbuild"],"backgroundTag":null,"analyzedSha":"93c999115b300a6faac567830b0450a5478800cd","analyzedAt":"2026-08-13T00:22:15.267Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}