-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (25 loc) · 827 Bytes
/
index.ts
File metadata and controls
26 lines (25 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { basename } from "path";
import Loader from "../../loader";
import { parseRustTypes } from "./parse-types";
export default class RustLoader extends Loader {
constructor() {
super("Rust Loader",
{
extension: "rs",
buildCommand: (importPath, outDir) => [
"rustc",
"--crate-type",
"cdylib",
importPath,
"--out-dir",
outDir
],
outDir: importPath => `build/${basename(importPath)}`,
parseTypes: async (importPath) => {
const sourceCode = await Bun.file(importPath).text();
return parseRustTypes(sourceCode);
}
}
);
}
}