Hey!
I wrote a simple plugin for an Imba (.imba) loader. Following the docs:
// imbaPlugin.js
import { plugin } from "bun";
await plugin({
name: "imba loader",
setup(build) {
const { compile } = await import("imba/dist/compiler.js");
const { readFileSync } = await import("fs");
build.onLoad({ filter: /\.imba$/ }, (args) => {
// read the .imba file
const text = readFileSync(args.path, "utf8");
// compile it with the Imba compiler
const options = {
target: "web",
format: "esm",
es6: true,
standalone: false,
sourceMap: true,
evaling: true,
css: false,
filename: basename(args.path),
sourceRoot: "",
sourcePath: basename(args.path),
targetPath: "",
};
let { js, sourcemap } = compile(text, options);
// and return the compiled source code as "js"
return {
contents: js,
loader: "js",
};
});
},
});
// index.js
import "./imbaPlugin.js";
import index from "./app/index.imba";
console.log(index.render());
This is the error I see:
$ bun run index.js
Unsupported loader file for path: /Users/blokku/bun-quickstart/app/index.imba
uh-oh: Unsupported loader file for path: /Users/blokku/bun-quickstart/app/index.imba
bun will crash now 😭😭😭
----- bun meta -----
Bun v0.7.1 (53cc4df1) macOS Silicon 22.6.0
RunCommand:
Elapsed: 13ms | User: 10ms | Sys: 11ms
RSS: 21.74MB | Peak: 21.74MB | Commit: 35.68MB | Faults: 42
----- bun meta -----
0 0x10202eb4c WTFGetBacktrace
1 ??? Bun__crashReportDumpStackTrace
Crash report saved to:
~/.bun/.bun-crash/v0.7.1-1690796153431.crash
Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord
thread 13757688 panic: Unsupported loader file for path: /Users/blokku/bun-quickstart/app/index.imba
error: script "start" exited with code 6 (SIGABRT)