Skip to content

Source-map generation for compiled JS output (post-0.6.0) #4

@oubiwann

Description

@oubiwann

Context

Lykn compiles .lykn source to .js output. Currently there is no
mapping between compiled JS line/column positions and original
lykn source positions. This means:

  • Stack traces from compiled code reference JS lines, not lykn
    lines.
  • IDE debuggers can't set breakpoints in lykn source.
  • DD-49 Rule 7's "bridged error-message format"
    ("isValid (valid?): ...") exists specifically because the
    compiled name in stack traces doesn't connect back to the user's
    source name. With source maps, the parenthesized form could be
    dropped — runtime stack traces would resolve to lykn locations
    directly.

What needs to be designed

Generate .js.map files alongside .js files. Standard source-map
v3 format. The compilation pipeline already tracks span
information through SExpr::Span on the Rust side and equivalent
on the JS side — that span data is the input to source-map
generation.

Open design questions:

  • Per-file or bundled source maps?
  • Include surface forms (post-expansion) or only kernel forms?
  • Inline (data: URL) or external file?
  • Build-pipeline integration (lykn build, lykn build --dist)?

Downstream effects when source maps land

  • DD-49 Rule 7 bridging format becomes redundant; can be simplified.
  • IDE / LSP integration becomes feasible (separate, larger work).
  • Debugging UX improves significantly.

Scope

Large. Substantial new infrastructure plus integration across both
compilers. Post-0.6.0 milestone candidate.

References

  • DD-49 Rule 7: docs/design/05-active/0049-identifier-mapping-lykn-js.md
  • M7 closing report fast-follow #8
  • Phase 2 plan "Out of scope" section: "Multi-file source-mapping
    for compiled JS (debugger UX) — Phase 3+"

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerCompiler (Rust and/or JS)enhancementNew feature or requestpost-0.6.0Targeted for after 0.6.0 release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions