Skip to content

[A10] Emit real Source Map v3 mappings with exact line/column provenance #1210

Description

@SisyphusZheng

A10.2

[A10] Emit real Source Map v3 mappings with exact line/column provenance

Problem

Two unacceptable emitters coexist at baseline 2936bf0a:

  1. compile.ts:1949-1959 emits { version: 3, sources, names: [], mappings: '', sourcesContent, x_openElement: program.sourceMap } as an inline map — empty mappings plus custom metadata is not a replacement for standard generated→original segments.
  2. compiler/plugin.ts:88-118 (createCompiledElementSourceMap) builds VLQ mappings by trimmed line-text equality, first match wins (:96-105): line-granularity only, no columns/names; duplicated source lines mis-map; unmatched scaffolding maps to line 1.

Both are wired at src/plugin.ts:364-367 (inline empty map inside code and the naive map), so consumers see two conflicting stories.

Required architecture

structured source spans → compiler emission → Source Map v3 segments → Vite composition → browser/tool consumer. Compiler semantic core owns original spans + generated emission provenance; Vite owns composition with the rest of the pipeline; the core must not depend on Vite.

Required fixtures

Decorators, properties, computed fields, methods, generated event handlers, JSX text, attributes, boolean/property sinks, conditional regions, keyed regions, nested regions, multiline expressions, generated helpers, diagnostics, identical repeated source lines. Mandatory duplicate-location fixture: two this.count++; lines must map to their two distinct original line/column locations.

Acceptance

  • A generic, standard Source Map consumer (not snapshot equality) recovers correct file/line/column for representative generated code.
  • The mappings: '' + x_openElement substitute is gone; x_openElement may remain only as supplementary metadata alongside real segments.

Scope / non-goals

No source-map spec extensions; no perf work beyond correctness.

Risk

Touches dev/HMR pipeline output; Vite composition behavior must be re-qualified end-to-end.

Semantic owner: spans/records in compiler semantic core; v3 composition in Vite integration shell (ADR-0148 boundary). Part of umbrella #1155. Depends on: A10.1 (same emission surface, serialize). Internal Alpha.10 — no publish, no tag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0adapter-vitealpha.10v0.42.0-alpha.10 audit remediation task trainrelease-blockerMust close before the target release can be promotedv0.44v0.44 compiled OpenElement architecture train

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions