function extractInline
extractInline(
bundle: ArrayBufferView | string | null,
outDir: string
): SourceMapDecoder | null

Extracts and decodes the inline source map that esbuild appends to a bundle as //# sourceMappingURL=data:application/json;base64,…. Returns null when no inline map is present or parsing fails.

Buffer/Uint8Array bundles are scanned in-place from the tail; the bundle itself is never decoded to a full UTF-8 string.

import * as SourceMap from './source-map.ts';

const bundle =
  'console.log(1);\n//# sourceMappingURL=data:application/json;base64,' +
  btoa('{"sources":["src/a.ts"],"mappings":"AAAA"}');

SourceMap.extractInline(bundle, '/proj/tmp')?.sources; // ['src/a.ts']
SourceMap.extractInline('no inline map here', '/proj/tmp'); // null

Parameters

bundle: ArrayBufferView | string | null
outDir: string

Return Type

Usage

import { extractInline } from "lib/utils/source-map.ts";