aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/JSBundler.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api/JSBundler.zig')
-rw-r--r--src/bun.js/api/JSBundler.zig47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index 8e85f1190..44ceaee9d 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -26,7 +26,7 @@ const strings = bun.strings;
const NewClass = Base.NewClass;
const To = Base.To;
const Request = WebCore.Request;
-
+const String = bun.String;
const FetchEvent = WebCore.FetchEvent;
const MacroMap = @import("../../resolver/package_json.zig").MacroMap;
const TSConfigJSON = @import("../../resolver/tsconfig_json.zig").TSConfigJSON;
@@ -844,7 +844,7 @@ pub const JSBundler = struct {
this.value = .{
.success = .{
- .loader = @intToEnum(options.Loader, @intCast(u8, loader_as_int.to(i32))),
+ .loader = @enumFromInt(options.Loader, @intCast(u8, loader_as_int.to(i32))),
.source_code = source_code,
},
};
@@ -871,16 +871,16 @@ pub const JSBundler = struct {
extern fn JSBundlerPlugin__anyMatches(
*Plugin,
- namespaceString: *const ZigString,
- path: *const ZigString,
+ namespaceString: *const String,
+ path: *const String,
bool,
) bool;
extern fn JSBundlerPlugin__matchOnLoad(
*JSC.JSGlobalObject,
*Plugin,
- namespaceString: *const ZigString,
- path: *const ZigString,
+ namespaceString: *const String,
+ path: *const String,
context: *anyopaque,
u8,
) void;
@@ -888,9 +888,9 @@ pub const JSBundler = struct {
extern fn JSBundlerPlugin__matchOnResolve(
*JSC.JSGlobalObject,
*Plugin,
- namespaceString: *const ZigString,
- path: *const ZigString,
- importer: *const ZigString,
+ namespaceString: *const String,
+ path: *const String,
+ importer: *const String,
context: *anyopaque,
u8,
) void;
@@ -905,10 +905,10 @@ pub const JSBundler = struct {
defer tracer.end();
const namespace_string = if (path.isFile())
- ZigString.Empty
+ bun.String.empty
else
- ZigString.fromUTF8(path.namespace);
- const path_string = ZigString.fromUTF8(path.text);
+ bun.String.create(path.namespace);
+ const path_string = bun.String.create(path.text);
return JSBundlerPlugin__anyMatches(this, &namespace_string, &path_string, is_onLoad);
}
@@ -924,11 +924,13 @@ pub const JSBundler = struct {
const tracer = bun.tracy.traceNamed(@src(), "JSBundler.matchOnLoad");
defer tracer.end();
const namespace_string = if (namespace.len == 0)
- ZigString.init("file")
+ bun.String.static("file")
else
- ZigString.fromUTF8(namespace);
- const path_string = ZigString.fromUTF8(path);
- JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @enumToInt(default_loader));
+ bun.String.create(namespace);
+ const path_string = bun.String.create(path);
+ defer namespace_string.deref();
+ defer path_string.deref();
+ JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @intFromEnum(default_loader));
}
pub fn matchOnResolve(
@@ -944,12 +946,15 @@ pub const JSBundler = struct {
const tracer = bun.tracy.traceNamed(@src(), "JSBundler.matchOnResolve");
defer tracer.end();
const namespace_string = if (strings.eqlComptime(namespace, "file"))
- ZigString.Empty
+ bun.String.empty
else
- ZigString.fromUTF8(namespace);
- const path_string = ZigString.fromUTF8(path);
- const importer_string = ZigString.fromUTF8(importer);
- JSBundlerPlugin__matchOnResolve(globalThis, this, &namespace_string, &path_string, &importer_string, context, @enumToInt(import_record_kind));
+ bun.String.create(namespace);
+ const path_string = bun.String.create(path);
+ const importer_string = bun.String.create(importer);
+ defer namespace_string.deref();
+ defer path_string.deref();
+ defer importer_string.deref();
+ JSBundlerPlugin__matchOnResolve(globalThis, this, &namespace_string, &path_string, &importer_string, context, @intFromEnum(import_record_kind));
}
pub fn addPlugin(