Builds the source-location sidecar that avenx trace view uses.
A trace records the source text of every action and computed it ran, which is already more than a compiled framework can offer. What it cannot know at runtime is where that text came from — the bundle is one concatenated script with no file boundaries left in it.
The compiler does know, so it writes the answer beside the bundle rather
than inside it. bundle.trace.json is emitted next to bundle.js and is not
referenced by it: an application that never records a trace downloads
nothing extra, and a deployment that does not want the file simply does not
upload it.
- Source:
Methods
(static) annotateTrace(trace, sidecar) → {object}
Annotates a trace's nodes with the source locations the sidecar holds.
Applied when a trace is read, not when it is recorded: a trace stays a record of what happened, and the mapping from that to a file and a line is a property of the build it came from.
Parameters:
| Name | Type | Description |
|---|---|---|
trace |
object | The trace to annotate. Mutated in place. |
sidecar |
object | null | The sidecar, or null to leave the trace alone. |
- Source:
Returns:
The same trace.
- Type
- object
(static) buildSidecar(components, bridgesopt, rootDiropt) → {object}
Assembles the sidecar document.
Parameters:
- Source:
Returns:
The sidecar, ready to serialize.
- Type
- object
(static) collectLocations(unit) → {object}
Collects the source locations of one component's declarations.
Parameters:
- Source:
Returns:
The component's sidecar entry.
- Type
- object
(static) sidecarFileName(outputName) → {string}
The file name the sidecar is written under, given a bundle name.
Parameters:
| Name | Type | Description |
|---|---|---|
outputName |
string | The configured bundle name, e.g. |
- Source:
Returns:
The sidecar file name.
- Type
- string
(inner) escape(name) → {string}
Escapes a name for use inside a regular expression.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The declared name. |
- Source:
Returns:
The escaped name.
- Type
- string
(inner) lineOf(source, pattern) → {number|null}
Finds the 1-based line a pattern first occurs on.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | The file contents. |
pattern |
RegExp | What to look for. |
- Source:
Returns:
The line number, or null when absent.
- Type
- number | null