Skip to content

Commit f9230cd

Browse files
committed
SourceMap reads internal sources instead of from files
- changed asinit to executable.
1 parent a4dd3a9 commit f9230cd

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

bin/asinit

100644100755
File mode changed.

cli/asc.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -704,27 +704,16 @@ exports.main = function main(argv, options, callback) {
704704
if (args.binaryFile.length) {
705705
let sourceMap = JSON.parse(wasm.sourceMap);
706706
sourceMap.sourceRoot = exports.sourceMapRoot;
707-
sourceMap.sources.forEach((name, index) => {
708-
let text = null;
709-
if (name.startsWith(exports.libraryPrefix)) {
710-
let stdName = name.substring(exports.libraryPrefix.length).replace(/\.ts$/, "");
711-
if (exports.libraryFiles.hasOwnProperty(stdName)) {
712-
text = exports.libraryFiles[stdName];
713-
} else {
714-
for (let i = 0, k = customLibDirs.length; i < k; ++i) {
715-
text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);
716-
if (text !== null) break;
717-
}
718-
}
719-
} else {
720-
text = readFile(name, baseDir);
721-
}
722-
if (text === null) {
723-
return callback(Error("Source file '" + name + "' not found."));
707+
console.log(sourceMap.sources)
708+
for (const index in sourceMap.sources) {
709+
let internalPath = sourceMap.sources[index].replace(/\.ts$/, "");
710+
let source = program.sources.find(source => source.internalPath === internalPath);
711+
if (!source) {
712+
return callback(Error("Source file '" + internalPath + ".ts' not found."));
724713
}
725714
if (!sourceMap.sourceContents) sourceMap.sourceContents = [];
726-
sourceMap.sourceContents[index] = text;
727-
});
715+
sourceMap.sourceContents[index] = source.text;
716+
}
728717
writeFile(path.join(
729718
path.dirname(args.binaryFile),
730719
path.basename(sourceMapURL)

0 commit comments

Comments
 (0)