I know. Node.js is to bloated to justify using other than for preference. And there is no way that I am aware of to build `node` executable with only standard JavaScript implementation, Process, File system modules
I must test and ask if the requirement is possible before abandoning the concept. It should be possible.
This is what I have so far, which exits early without sending the message to client.
d8.js
#!/usr/bin/env -S ./d8 --enable-os-system --experimental-web-snapshots ./test.js
test.js
const json = JSON.stringify("test");
let header = Uint32Array.from({
length: 4,
}, (_, index) => (json.length >> (index * 8)) & 0xff
);
let output = new Uint8Array(header.length + json.length);
output.set(header, 0);
write(JSON.stringify(header));
write(json);