mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Fix regression with TOML & JSONC (#10573)
This commit is contained in:
@@ -627,6 +627,19 @@ JSValue fetchCommonJSModule(
|
||||
RELEASE_AND_RETURN(scope, {});
|
||||
}
|
||||
|
||||
target->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), value, 0);
|
||||
target->hasEvaluated = true;
|
||||
RELEASE_AND_RETURN(scope, target);
|
||||
|
||||
}
|
||||
// TOML and JSONC may go through here
|
||||
else if (res->result.value.tag == SyntheticModuleType::ExportsObject) {
|
||||
JSC::JSValue value = JSC::JSValue::decode(res->result.value.jsvalue_for_export);
|
||||
if (!value) {
|
||||
JSC::throwException(globalObject, scope, JSC::createSyntaxError(globalObject, "Failed to parse Object"_s));
|
||||
RELEASE_AND_RETURN(scope, {});
|
||||
}
|
||||
|
||||
target->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), value, 0);
|
||||
target->hasEvaluated = true;
|
||||
RELEASE_AND_RETURN(scope, target);
|
||||
@@ -807,6 +820,23 @@ static JSValue fetchESMSourceCode(
|
||||
JSC::ensureStillAliveHere(value);
|
||||
return rejectOrResolve(JSSourceCode::create(globalObject->vm(), WTFMove(source)));
|
||||
}
|
||||
// TOML and JSONC may go through here
|
||||
else if (res->result.value.tag == SyntheticModuleType::ExportsObject) {
|
||||
JSC::JSValue value = JSC::JSValue::decode(res->result.value.jsvalue_for_export);
|
||||
if (!value) {
|
||||
return reject(JSC::JSValue(JSC::createSyntaxError(globalObject, "Failed to parse Object"_s)));
|
||||
}
|
||||
|
||||
// JSON can become strings, null, numbers, booleans so we must handle "export default 123"
|
||||
auto function = generateJSValueModuleSourceCode(
|
||||
globalObject,
|
||||
value);
|
||||
auto source = JSC::SourceCode(
|
||||
JSC::SyntheticSourceProvider::create(WTFMove(function),
|
||||
JSC::SourceOrigin(), specifier->toWTFString(BunString::ZeroCopy)));
|
||||
JSC::ensureStillAliveHere(value);
|
||||
return rejectOrResolve(JSSourceCode::create(globalObject->vm(), WTFMove(source)));
|
||||
}
|
||||
|
||||
return rejectOrResolve(JSC::JSSourceCode::create(vm,
|
||||
JSC::SourceCode(Zig::SourceProvider::create(globalObject, res->result.value))));
|
||||
|
||||
Reference in New Issue
Block a user