Skip to content

Source maps and the C-API #1315

@dcodeIO

Description

@dcodeIO

I noticed that there is some source map support but no way to provide the information necessary in the C-API yet. Hence, what if we'd do something like:

  1. Call BinaryenAddFile(const char* name): BinaryenFileRef for each source file being compiled, returning a reference to the file (avoids having to copy file name strings every time in JS)
  2. Call BinaryenSetLoc(BinaryenFileRef file, BinaryenIndex lineStart, BinaryenIndex columnStart, BinaryenIndex lineEnd, BinaryenIndex columnEnd): void, taking the file reference from above plus line and column information of the next function / global / import / export / expression being compiled
  3. Call the respective C-API method as usual that then honors the location info previously set
  4. Generate a source map from this information when creating the module (maybe BinaryenModulePrintSourceMap).

Would something like this be possible as of today?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions