{"record":{"id":"9cf6c094c4f1798d","repo":"swc-project/swc","slug":"failed-to-find-input-source-map-file-in","errorCode":null,"errorMessage":"failed to find input source map file {:?} in {:?} file as either {:?} or with appended .map","messagePattern":"failed to find input source map file (.+?) in (.+?) file as either (.+?) or with appended \\.map","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc/src/lib.rs","lineNumber":494,"sourceCode":"                            };\n\n                            let map_path = match data_url {\n                                Some(data_url) => {\n                                    let mut map_path = dir.join(data_url);\n                                    if !map_path.exists() {\n                                        // Old behavior. This check would prevent\n                                        // regressions.\n                                        // Perhaps it shouldn't be supported. Sometimes\n                                        // developers don't want to expose their source\n                                        // code.\n                                        // Map files are for internal troubleshooting\n                                        // convenience.\n                                        let fallback_map_path =\n                                            PathBuf::from(format!(\"{}.map\", filename.display()));\n                                        if fallback_map_path.exists() {\n                                            map_path = fallback_map_path;\n                                        } else {\n                                            bail!(\n                                                \"failed to find input source map file {:?} in \\\n                                                 {:?} file as either {:?} or with appended .map\",\n                                                data_url,\n                                                filename.display(),\n                                                map_path.display(),\n                                            )\n                                        }\n                                    }\n\n                                    Some(map_path)\n                                }\n                                None => {\n                                    // Old behavior.\n                                    let map_path =\n                                        PathBuf::from(format!(\"{}.map\", filename.display()));\n                                    if map_path.exists() {\n                                        Some(map_path)\n                                    } else {","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/lib.rs#L476-L512","documentation":"The input file's `sourceMappingURL` comment names an external map file; swc resolved it relative to the input file's directory and also tried the legacy fallback `<inputfile>.map`; neither exists on disk, so processing aborts. The message includes the sourceMappingURL value, the input file path, and the candidate map path that was checked.","triggerScenarios":"Compiling a JS file containing `//# sourceMappingURL=foo.js.map` where foo.js.map was deleted or never deployed next to the file; map in a different directory than the referencing file; case mismatches on case-sensitive filesystems.","commonSituations":"Committing or deploying compiled .js without the .map; CI copying only .js artifacts; moving/renaming files after build; consuming transpiled sources from CDNs where maps aren't shipped.","solutions":["Restore the .map file at the exact path the comment references, relative to the input file","Or remove the `//# sourceMappingURL=` comment from the input file","Or tell swc not to read input maps (e.g. `inputSourceMap: false` in @swc/core options) when they are intentionally absent"],"exampleFix":"// before\n//# sourceMappingURL=./maps/index.js.map   /* file missing */\n// after: either ship ./maps/index.js.map, or drop the comment / disable reading it\nconst out = await transformFile('index.js', { inputSourceMap: false });","handlingStrategy":"validation","validationCode":"// JavaScript - verify referenced external map exists before compiling\nimport fs from 'node:fs';\nimport path from 'node:path';\nfunction assertInputSourceMapExists(source, filePath) {\n  const m = source.match(/\\/\\/[#@]\\s*sourceMappingURL=(\\S+)/);\n  if (!m || m[1].startsWith('data:')) return;\n  const candidates = [\n    path.resolve(path.dirname(filePath), m[1]),\n    `${filePath}.map`,\n  ];\n  if (!candidates.some((p) => fs.existsSync(p))) {\n    throw new Error(`missing source map for ${filePath}: ${m[1]}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deploy .map files together with the .js files that reference them","Strip sourceMappingURL comments in artifacts that ship without maps","Set inputSourceMap: false when input maps are intentionally absent"],"tags":["swc","source-map","missing-file","sourcemappingurl"],"backgroundTag":"missing-source-map-file","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}