{"record":{"id":"eb9ae8b9f9ef72e3","repo":"sveltejs/svelte","slug":"svelte-compiler-no-longer-exports-a-walk-utili","errorCode":null,"errorMessage":"'svelte/compiler' no longer exports a `walk` utility — please import it directly from 'estree-walker' instead","messagePattern":"'svelte/compiler' no longer exports a `walk` utility — please import it directly from 'estree-walker' instead","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/compiler/index.js","lineNumber":196,"sourceCode":"}\n\n/**\n * Remove the byte order mark from a string if it's present since it would mess with our template generation logic\n * @param {string} source\n */\nfunction remove_bom(source) {\n\tif (source.charCodeAt(0) === 0xfeff) {\n\t\treturn source.slice(1);\n\t}\n\treturn source;\n}\n\n/**\n * @deprecated Replace this with `import { walk } from 'estree-walker'`\n * @returns {never}\n */\nexport function walk() {\n\tthrow new Error(\n\t\t`'svelte/compiler' no longer exports a \\`walk\\` utility — please import it directly from 'estree-walker' instead`\n\t);\n}\n\nexport { VERSION } from '../version.js';\nexport { migrate } from './migrate/index.js';\n","sourceCodeStart":178,"sourceCodeEnd":203,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/compiler/index.js#L178-L203","documentation":"Svelte 5 removed the `walk` AST traversal utility that was previously exported from `svelte/compiler`. The export is kept only as a stub that throws unconditionally on call, so legacy imports fail loudly instead of silently breaking. The replacement is the identical API from the `estree-walker` package, which Svelte itself uses internally.","triggerScenarios":"Calling `import { walk } from 'svelte/compiler'` and then invoking it. The throw happens the moment the function body executes — there is no DEV guard or condition. Code that imports the symbol but never calls it will not throw.","commonSituations":"Upgrading a project from Svelte 4 (or earlier) to Svelte 5 where tooling, plugins, ESLint rules, or custom preprocessors import `walk` from `svelte/compiler`. Codemods and AST analyzers written against the old export are the most common source.","solutions":["Change the import to `import { walk } from 'estree-walker'` — the signature and behavior are compatible.","Add `estree-walker` to your project's dependencies if it is not already present (it is a transitive dep, so pin it explicitly for stability).","Run a repo-wide search for `from 'svelte/compiler'` usages of `walk` and update each call site.","If you depend on Svelte-flavored walking (e.g. the `node`/`context` visitor shape from zimmerframe), use `import { walk } from 'zimmerframe'` instead, which is what Svelte's own migrate step uses."],"exampleFix":"// before\nimport { walk } from 'svelte/compiler';\nwalk(ast, { enter(node) {} });\n\n// after (plain estree traversal)\nimport { walk } from 'estree-walker';\nwalk(ast, { enter(node) {} });\n\n// or, for Svelte-style visitors\nimport { walk } from 'zimmerframe';\nwalk(ast, state, { Identifier(node, { state }) {} });","handlingStrategy":"validation","validationCode":"// Before relying on the import, check whether the export is the deprecated stub.\nimport * as compiler from 'svelte/compiler';\nif (typeof compiler.walk === 'function' && compiler.walk.toString().includes(\"'estree-walker'\")) {\n  // walk is the throwing stub — do not call it\n  throw new Error('svelte/compiler walk is removed; import from estree-walker instead');\n}","typeGuard":"// Narrow an imported symbol to a usable walker before calling.\nimport * as compiler from 'svelte/compiler';\n\n/** @returns {compiler.walk is (ast: unknown, visitor: object) => void} */\nfunction isUsableWalk(fn) {\n  return typeof fn === 'function' && !fn.toString().includes(\"'estree-walker'\");\n}\n\nif (isUsableWalk(compiler.walk)) {\n  compiler.walk(ast, visitor);\n} else {\n  throw new Error('Use estree-walker directly');\n}","tryCatchPattern":null,"preventionTips":["Codemod all imports during the Svelte 4→5 upgrade: replace `import { walk } from 'svelte/compiler'` with `estree-walker`.","Add an ESLint rule banning named `walk` imports from `svelte/compiler`.","Pin `estree-walker` as a direct dependency rather than relying on it transitively."],"tags":["svelte5","migration","compiler","estree-walker","deprecated"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}