It would be nice, when inject: true, to not have the source files littered around still. One option would be to use an alternate folder, but why bother?
I wrote a quick "plugin" to do this:
{
name: 'Cleanup Plugin',
setup(build) {
build.onEnd(res =>
Promise.all(
Object.keys(res.metafile?.outputs ?? {}).map(file =>
unlink(file).catch(e => logger.warn(`Failed to clean up ${file}: ${e.message}`)),
),
).then(() => {}),
);
},
},