Skip to content
Permalink
Browse files

[js] Add source map support to rakudo-library

  • Loading branch information...
pmurias committed Jan 23, 2019
1 parent a7d7587 commit 6dd723a9268607d9207f3b276e57ebd9f306f1c8
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/vm/js/rakudo-library.js
@@ -25,6 +25,10 @@ module.exports.compile = function(source, options = {}) {

passedArgs = ['perl6-js', '--output', tmpFile, '--target=js', source];

if (options.sourceMap) {
passedArgs.splice(1, 0, '--source-map');
}

if (Object.prototype.hasOwnProperty.call(nqp.op.getstdout(), '$$writefh')) {
throw `Can't overwrite $$writefh on stdout, it's already set`;
}
@@ -66,7 +70,13 @@ module.exports.compile = function(source, options = {}) {
nqp.setGlobalContext(oldGlobalContext);

const fs = require('fs');
return {js: fs.readFileSync(tmpFile, 'utf8'), loaded: loaded};
const returnValue = {js: fs.readFileSync(tmpFile, 'utf8'), loaded: loaded};

if (options.sourceMap) {
returnValue.sourceMap = JSON.parse(fs.readFileSync(tmpFile + '.map', 'utf8'));
}

return returnValue;
};

module.exports.capturedRun = /*async*/ function(source, input, compileArgs, args, passedEnv) {

0 comments on commit 6dd723a

Please sign in to comment.
You can’t perform that action at this time.