more child-process (#18688)

Co-authored-by: pfgithub <6010774+pfgithub@users.noreply.github.com>
This commit is contained in:
pfg
2025-05-06 22:12:24 -07:00
committed by GitHub
parent d291b56f8b
commit 00a3cbd977
70 changed files with 2990 additions and 917 deletions

View File

@@ -73,6 +73,7 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
let contents = await Bun.file(filename).text();
contents = applyGlobalReplacements(contents);
const originalContents = contents;
// first approach doesnt work perfectly because we actually need to split each function declaration
// and then compile those separately
@@ -93,7 +94,36 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
if (!contents.length) break;
const match = contents.match(consumeTopLevelContent);
if (!match) {
throw new SyntaxError("Could not process input:\n" + contents.slice(0, contents.indexOf("\n")));
const pos = originalContents.length - contents.length;
let lineNumber = 1;
let columnNumber = 1;
let lineStartPos = 0;
for (let i = 0; i < pos; i++) {
if (originalContents[i] === "\n") {
lineNumber++;
columnNumber = 1;
lineStartPos = i + 1;
} else {
columnNumber++;
}
if (i === pos) {
break;
}
}
const lineEndPos = lineStartPos + originalContents.slice(lineStartPos).indexOf("\n");
throw new SyntaxError(
"Could not process input:\n" +
originalContents.slice(lineStartPos, lineEndPos) +
"\n" +
" ".repeat(pos - lineStartPos) +
"^" +
"\n at " +
filename +
":" +
lineNumber +
":" +
columnNumber,
);
}
contents = contents.slice(match.index!);
if (match[1] === "import") {