{"record":{"id":"e5f1a20f23b73dce","repo":"sveltejs/kit","slug":"source-errors-0-message","errorCode":null,"errorMessage":"${source.errors[0].message}","messagePattern":"\\$\\{source\\.errors\\[0\\]\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/vite/static_analysis/index.js","lineNumber":41,"sourceCode":"\n/**\n * Collects page options from a +page.js/+layout.js file, ignoring reassignments\n * and using the declared value (except for load functions, for which the value is `true`).\n * Returns `null` if any export is too difficult to analyse.\n * @param {string} filename The name of the file to report when an error occurs\n * @param {string} input\n * @returns {PageOptions | null}\n */\nexport function statically_analyse_page_options(filename, input) {\n\t// if there's a chance there are no page exports or an unparseable\n\t// export all declaration, then we can skip the AST parsing which is expensive\n\tif (!skip_parsing_regex.test(input)) {\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst source = parseSync(filename, input, { sourceType: 'module' });\n\t\tif (source.errors.length) throw new Error(source.errors[0].message);\n\n\t\t/** @type {Map<string, Extract<ESTree.Expression, { type: 'Literal' }>['value']>} */\n\t\tconst page_options = new Map();\n\n\t\tfor (const statement of source.program.body) {\n\t\t\t// ignore export all declarations with aliases that are not page options\n\t\t\tif (\n\t\t\t\tstatement.type === 'ExportAllDeclaration' &&\n\t\t\t\tstatement.exported &&\n\t\t\t\t!valid_page_options.has(get_name(statement.exported))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tstatement.type === 'ExportDefaultDeclaration' ||\n\t\t\t\tstatement.type === 'ExportAllDeclaration'\n\t\t\t) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/vite/static_analysis/index.js#L23-L59","documentation":"SvelteKit statically analyzes page options (like ssr/prerender exports) by parsing the module with acorn-typescript's parseSync. If the parser reports syntax errors, this error throws with the parser's first error message.","triggerScenarios":"A .svelte.js/.svelte.ts module processed for page options contains syntax that the parser rejects (unsupported syntax, malformed code, invalid syntax for the configured lang), and the skip_parsing_regex did not skip the file.","commonSituations":"Syntax newer than the bundled parser supports; a file with mixed/inconsistent extensions; copy-pasted code with typos in page option modules; invalid regex-filtered module variants.","solutions":["Fix the syntax error reported in the message in the referenced file","Ensure the file extension matches its language (.svelte.js vs .svelte.ts) so it parses correctly","Update @sveltejs/kit and vite plugin so the bundled parser supports your syntax","Temporarily rename the file to exclude it from page-option analysis to confirm the cause"],"exampleFix":"// before (src/routes/+page.svelte.ts)\nexport const prerender = = true; // syntax error\n// after\nexport const prerender = true;","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"null // build-time error; fix syntax rather than catch","preventionTips":["Run a linter/parser over page option files in CI","Keep file extensions consistent with their language","Keep @sveltejs/kit updated for newer syntax support","Avoid complex syntax in +page.svelte.js/.svelte.ts option modules"],"tags":["syntax","build","vite","static-analysis"],"backgroundTag":"javascript-syntax-error","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}