JSPM

sourcemap-to-ast

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3127
  • Score
    100M100P100Q133223F

Updates a mozilla AST(produced by acorn/esprima) with location info from a source map

Package Exports

  • sourcemap-to-ast

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sourcemap-to-ast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sourcemap-to-ast

Updates a mozilla AST(produced by acorn/esprima) with location info from a source map

Installation

npm install --save sourcemap-to-ast

Usage

var acorn = require('acorn');
var coffee = require('coffee-script');
var sourceMapToAst = require('sourcemap-to-ast');

var compiled = coffee.compile('x =\n 1', {sourceMap: true});
var ast = acorn.parse(compiled.js, {locations: true});

var func = ast.body[0].expression.callee.object;
var funcBody = func.body.body;
var assignment = funcBody[1].expression;

sourceMapToAst(ast, compiled.v3SourceMap);

assignment.loc.start // {line: 1, column: 0}
assignment.loc.end // {line: 2, column: 1}