[bun:ffi] it works

This commit is contained in:
Jarred Sumner
2022-04-29 23:21:14 -07:00
parent d49ba50289
commit 516b54578d
15 changed files with 1278 additions and 222 deletions

View File

@@ -1078,6 +1078,14 @@ pub const VirtualMachine = struct {
.source_url = ZigString.init("node:path"),
.hash = 0,
};
} else if (strings.eqlComptime(_specifier, "bun:ffi")) {
return ResolvedSource{
.allocator = null,
.source_code = ZigString.init(@embedFile("ffi.exports.js") ++ "export const FFIType = " ++ JSC.FFI.ABIType.map_to_js_object ++ ";\n"),
.specifier = ZigString.init("bun:ffi"),
.source_url = ZigString.init("bun:ffi"),
.hash = 0,
};
}
const specifier = normalizeSpecifier(_specifier);
@@ -1303,11 +1311,14 @@ pub const VirtualMachine = struct {
ret.result = null;
ret.path = "node:fs";
return;
}
if (strings.eqlComptime(specifier, "node:path")) {
} else if (strings.eqlComptime(specifier, "node:path")) {
ret.result = null;
ret.path = "node:path";
return;
} else if (strings.eqlComptime(specifier, "bun:ffi")) {
ret.result = null;
ret.path = "bun:ffi";
return;
}
const is_special_source = strings.eqlComptime(source, main_file_name) or js_ast.Macro.isMacroPath(source);