Skip to content

feat(es): Add source map support for --cg javascript backend#3714

Open
shogochiai wants to merge 1 commit intoidris-lang:mainfrom
shogochiai:feature/es-source-maps
Open

feat(es): Add source map support for --cg javascript backend#3714
shogochiai wants to merge 1 commit intoidris-lang:mainfrom
shogochiai:feature/es-source-maps

Conversation

@shogochiai
Copy link
Contributor

@shogochiai shogochiai commented Jan 15, 2026

Summary

Add source map generation for the JavaScript/Node.js code generator, enabling better debugging of Idris2 code in browser DevTools and Node.js.

  • Add Compiler.ES.SourceMap module with VLQ encoding and source map generation
  • Integrate source map generation into ES codegen pipeline
  • Add sourcemap directive to enable source map output
  • Add SourceMap module to idris2api.ipkg for external tool access

Usage

idris2 --cg node --directive sourcemap -o output Main.idr
idris2 --cg javascript --directive sourcemap -o output Main.idr

Tests

All tests are implemented in Idris2, following existing test patterns (e.g., tests/codegen/enum):

  • tests/node/sourcemap001: Basic source map generation for node backend
  • tests/node/sourcemap_e2e001: E2E verification with complex Idris2 code
  • tests/node/sourcemap_accuracy001: Mapping accuracy verification
  • tests/codegen/sourcemap_js001: Basic source map for javascript backend
  • tests/codegen/sourcemap_js_e2e001: E2E verification for browser target

Test plan

  • All sourcemap tests pass locally
  • CI passes on all platforms

Add source map generation for the JavaScript/Node.js code generator,
enabling better debugging of Idris2 code in browser DevTools and Node.js.

Changes:
- Add Compiler.ES.SourceMap module with VLQ encoding and source map generation
- Integrate source map generation into ES codegen pipeline
- Add "sourcemap" directive to enable source map output
- Add SourceMap module to idris2api.ipkg for external tool access

Tests (implemented in Idris2 following existing test patterns):
- tests/node/sourcemap001: Basic source map generation for node backend
- tests/node/sourcemap_e2e001: E2E verification with complex Idris2 code
- tests/node/sourcemap_accuracy001: Mapping accuracy verification
- tests/codegen/sourcemap_js001: Basic source map for javascript backend
- tests/codegen/sourcemap_js_e2e001: E2E verification for browser target

Usage: idris2 --cg node --directive sourcemap -o output Main.idr

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@shogochiai shogochiai force-pushed the feature/es-source-maps branch from bc8d0e9 to b27ae31 Compare January 15, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant