{"id":"fc9d5f29f19ea87d","repo":"babel/babel","slug":"reading-input-source-map-files-is-not-supported-in","errorCode":null,"errorMessage":"Reading input source map files is not supported in browsers","messagePattern":"Reading input source map files is not supported in browsers","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/babel-core/src/transformation/read-input-source-map-file-browser.ts","lineNumber":2,"sourceCode":"export default function readInputSourceMapFile(): never {\n  throw new Error(\n    \"Reading input source map files is not supported in browsers\",\n  );\n}\n","sourceCodeStart":1,"sourceCodeEnd":6,"githubUrl":"https://github.com/babel/babel/blob/06b6eae39da4ce0689fad64e2c48a6375a464208/packages/babel-core/src/transformation/read-input-source-map-file-browser.ts#L1-L6","documentation":"The browser build of @babel/core replaces the external-source-map file reader with a stub (read-input-source-map-file-browser.ts) that always throws, because reading a .map file from disk is impossible without a filesystem.","triggerScenarios":"Transforming code in a browser build where the source contains a non-inline `//# sourceMappingURL=foo.map` comment AND inputSourceMap is not disabled.","commonSituations":"Shipping @babel/core (not @babel/standalone) to the browser; transforming pre-compiled code that still references external maps.","solutions":["Use @babel/standalone for browser compilation.","Set `inputSourceMap: false` in the transform options to skip the external map lookup.","Strip external sourceMappingURL comments from the input before transforming."],"exampleFix":"// before\ntransform(code, { sourceMaps: true }); // code has //# sourceMappingURL=app.js.map\n\n// after\ntransform(code, { sourceMaps: true, inputSourceMap: false });","handlingStrategy":"validation","validationCode":"function isBrowser() {\n  return typeof window !== 'undefined';\n}\nconst opts = isBrowser()\n  ? { sourceMaps: true, inputSourceMap: false }\n  : { sourceMaps: true };","typeGuard":"const supportsFileSystem = () =>\n  typeof process !== 'undefined' && typeof process.versions?.node === 'string';","tryCatchPattern":"try {\n  transform(code, { sourceMaps: true });\n} catch (err) {\n  if (/Reading input source map files is not supported in browsers/.test(err.message)) {\n    transform(code, { sourceMaps: true, inputSourceMap: false });\n  } else throw err;\n}","preventionTips":["Strip external sourceMappingURL comments before browser transforms.","Default to inputSourceMap: false in browser builds.","Prefer @babel/standalone for browser compilation."],"tags":["babel","browser","sourcemap","environment"],"analyzedSha":"06b6eae39da4ce0689fad64e2c48a6375a464208","analyzedAt":"2026-08-03T20:13:43.465Z","schemaVersion":2}