Skip to content

ezgh obs sourcemaps inject

Give each JS file in a build and its source map a debug ID.

Updated View as Markdown
ezgh obs sourcemaps inject <dir> [--dry-run] [flags]

Give each JS file in a build directory and its source map a debug ID, so errors from that file can be symbolicated with that map. Each .js, .mjs and .cjs file (not in node_modules) is paired with the map its trailing //# sourceMappingURL comment names, else <file>.map. ezgh adds a one-line registration snippet after the file’s directives and a //# debugId=<id> comment, shifts the map’s mappings to match, and sets the map’s debugId. The ID is derived from the files’ content, and a file already injected is left alone, so running inject again is safe.

Run it after your build and before deploying and uploading: the files must ship with the snippet. Files are rewritten in place (--dry-run writes nothing). A JS file without a map is skipped. A pair that can’t be injected (an index map, two different debug IDs) fails the command after the others are done.

Part of ezgh obs sourcemaps.

Examples

ezgh obs sourcemaps inject dist
ezgh obs sourcemaps inject dist --dry-run

Flags

Flag Type Default Description
--dry-run boolean show what would be injected, and write nothing

This command also takes the global flags.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close