#Crash on bun run src/bundle.ts

1 messages · Page 1 of 1 (latest)

jovial galleon
#

I am trying to bundle this worker but bun crashes, if I run bun run src/bundle.ts

import nunjucks from "nunjucks";
nunjucks.configure({ autoescape: true });
self.onmessage = (event: MessageEvent) => {
  postMessage(nunjucks.renderString('Hello {{ username }}', { username: 'James' }));
};
uh-oh: Internal error: missing asset file
bun will crash now 😭😭😭

----- bun meta -----
Bun v1.0.0 (822a00c4) macOS Silicon 22.6.0
RunCommand:
Elapsed: 30ms | User: 39ms | Sys: 28ms
RSS: 54.03MB | Peak: 54.03MB | Commit: 90.31MB | Faults: 39
----- bun meta -----

0   0x104832624 WTFGetBacktrace
1   ??? Bun__crashReportDumpStackTrace
2   ??? src.report.fatal

Crash report saved to:
  ~/.bun/.bun-crash/v1.0.0-1694318260862.crash

Here is the bundle.ts file

async function bundle() {
  await Bun.build({
    entrypoints: ['./src/index.ts', './src/worker.ts'],
    outdir: "./out",
    target: "bun",
  })
}
try {
  bundle();
} catch (e) {
  console.error({ e })
}
console.log("Bundled")

Surprisingly bun run src/index.ts works perfectly.

jovial galleon
jovial galleon
#

commenting out target: "bun" makes it work somehow

jovial galleon
#

If I remove the nunjucks import from the worker, that works too. Something to do with importing the library when target in build is bun