mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
RELEASE_AND_RETURN & fix indirect checking
This commit is contained in:
@@ -77,16 +77,18 @@ pub const ModuleInfo = struct {
|
||||
|
||||
/// find any exports marked as 'local' that are actually 'indirect' and fix them
|
||||
pub fn fixupIndirectExports(self: *ModuleInfo) !void {
|
||||
var local_name_to_module_name = std.AutoArrayHashMap(StringID, StringID).init(self.strings.allocator);
|
||||
var local_name_to_module_name = std.AutoArrayHashMap(StringID, *ImportInfo).init(self.strings.allocator);
|
||||
defer local_name_to_module_name.deinit();
|
||||
for (self.imports.items) |*ip| {
|
||||
try local_name_to_module_name.put(ip.local_name, ip.module_name);
|
||||
try local_name_to_module_name.put(ip.local_name, ip);
|
||||
}
|
||||
|
||||
for (self.exports.items) |*xp| {
|
||||
if (xp.* == .local) {
|
||||
if (local_name_to_module_name.get(xp.local.local_name)) |im| {
|
||||
xp.* = .{ .indirect = .{ .export_name = xp.local.export_name, .import_name = xp.local.local_name, .module_name = im } };
|
||||
if (local_name_to_module_name.get(xp.local.local_name)) |ip| {
|
||||
if (ip.kind == .single) {
|
||||
xp.* = .{ .indirect = .{ .export_name = xp.local.export_name, .import_name = ip.import_name, .module_name = ip.module_name } };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,12 +218,11 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj
|
||||
dumpRecordInfo(moduleRecord);
|
||||
zig_log_cstr("\n \x1b[91m</Actual Record Info>\x1b(B\x1b[m", "");
|
||||
|
||||
scope.release();
|
||||
if (compare) {
|
||||
return fallbackParse(globalObject, moduleKey, sourceCode, promise, moduleRecord);
|
||||
RELEASE_AND_RETURN(scope, fallbackParse(globalObject, moduleKey, sourceCode, promise, moduleRecord));
|
||||
} else {
|
||||
promise->fulfillWithNonPromise(globalObject, moduleRecord);
|
||||
return JSValue::encode(promise);
|
||||
RELEASE_AND_RETURN(scope, JSValue::encode(promise));
|
||||
}
|
||||
}
|
||||
static EncodedJSValue fallbackParse(JSGlobalObject* globalObject, const Identifier& moduleKey, const SourceCode& sourceCode, JSInternalPromise* promise, JSModuleRecord* resultValue)
|
||||
|
||||
Reference in New Issue
Block a user