Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified bin/asinit
100644 → 100755
Empty file.
27 changes: 8 additions & 19 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,27 +704,16 @@ exports.main = function main(argv, options, callback) {
if (args.binaryFile.length) {
let sourceMap = JSON.parse(wasm.sourceMap);
sourceMap.sourceRoot = exports.sourceMapRoot;
sourceMap.sources.forEach((name, index) => {
let text = null;
if (name.startsWith(exports.libraryPrefix)) {
let stdName = name.substring(exports.libraryPrefix.length).replace(/\.ts$/, "");
if (exports.libraryFiles.hasOwnProperty(stdName)) {
text = exports.libraryFiles[stdName];
} else {
for (let i = 0, k = customLibDirs.length; i < k; ++i) {
text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);
if (text !== null) break;
}
}
} else {
text = readFile(name, baseDir);
}
if (text === null) {
return callback(Error("Source file '" + name + "' not found."));
console.log(sourceMap.sources)
for (const index in sourceMap.sources) {
let internalPath = sourceMap.sources[index].replace(/\.ts$/, "");
let source = program.sources.find(source => source.internalPath === internalPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calls into the compiler without using a C-like API, hence is non-portable once we can compile the compiler itself to Wasm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I had a feeling this was too easy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But wait. This already happened before:

stderr.write(program.sources.map(s => s.normalizedPath).sort().join(EOL) + EOL);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, appears this made it through review before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol my bad. I think instead we should just keep a local map of internal paths to texts and external paths for the resolver.

if (!source) {
return callback(Error("Source file '" + internalPath + ".ts' not found."));
}
if (!sourceMap.sourceContents) sourceMap.sourceContents = [];
sourceMap.sourceContents[index] = text;
});
sourceMap.sourceContents[index] = source.text;
}
writeFile(path.join(
path.dirname(args.binaryFile),
path.basename(sourceMapURL)
Expand Down