Skip to main content

Module structured

Module structured 

Source
Expand description

A source map kept in structured form until it is actually emitted, so that rewriting or embedding a map shares its ropes instead of copying its bytes. sourcesContent in particular (the full original source text) would otherwise be copied for every chunking context that rewrites the sources URLs and for every chunk source map that embeds the module’s map.

Fields are stored as verbatim raw JSON snippets (Ropes) and only decoded when something actually needs their values: sources is decoded lazily by StructuredSourceMap::rewrite_sources when a rewrite changes an entry, and sourcesContent of maps built from swc objects is a list of individually pre-escaped Ropes that are shared into every map that embeds them.

StructuredSourceMap::to_rope emits fields in the same order as swc_sourcemap’s serializer, so maps built via StructuredSourceMap::from_swc_map serialize byte-for-byte identically to what swc_sourcemap::SourceMap::to_writer would have produced (pinned by the golden tests below).

Structs§

StructuredSourceMap
A single source map in structured form. See the module documentation.