Skip to content

Commit

Permalink
[js] Fix --source-map
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Feb 23, 2018
1 parent 98fae8a commit 033aeac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -686,14 +686,15 @@ class JavaScriptCompiler extends NQPObject {
global.nqp = nqp;

if (_NAMED !== null && _NAMED.hasOwnProperty('mapping')) {
sourceMaps[fakeFilename] = createSourceMap(codeStr, _NAMED['p6-source'], _NAMED.mapping.array, fakeFilename, nqp.toStr(_NAMED.file, ctx));
sourceMaps[fakeFilename] = createSourceMap(codeStr, nqp.toStr(_NAMED['p6-source'], ctx), _NAMED.mapping.array, fakeFilename, nqp.toStr(_NAMED.file, ctx));
const node = SourceNode.fromStringWithSourceMap(codeStr, sourceMaps[fakeFilename]);

// HACK
sourceMaps[fakeFilename] = new SourceMapConsumer(node.toStringWithSourceMap({file: fakeFilename}).map.toString());

const jsProps = charProps(codeStr);
const p6Props = charProps(_NAMED['p6-source']);
const p6Props = charProps(nqp.toStr(_NAMED['p6-source'], ctx));

sourceMaps[fakeFilename].eachMapping(m => {
m.generatedPos = jsProps.indexAt({line: m.generatedLine, column: m.generatedColumn});
m.originalPos = p6Props.indexAt({line: m.originalLine, column: m.originalColumn});
Expand Down

0 comments on commit 033aeac

Please sign in to comment.