mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 13:51:47 +00:00
Bunch of fixes (#3516)
* Fix #3497 * Fix #3497 * Run prettier * Fix package.json * remove this too * yeah * Fix missing tests * Use native for utf-8-validate * Add module ID names to builtins * Defer evaluation of ESM & CJS modules until link time * Use builtin name for exports in plugins * Add module IDs to builtins * Update JSC build with new flag * WebKit upgrade fixes * Update WebKit * prettier * Upgrade WebKit * bump * Update once again * Add visitAdditionalChildren, remove .fill() usage * Update process.test.js * Update fs.test.ts --------- Co-authored-by: dave caruso <me@paperdave.net> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -16,33 +16,34 @@ namespace Bun {
|
||||
// JS builtin that acts as a module. In debug mode, we use a different implementation that reads
|
||||
// from the developer's filesystem. This allows reloading code without recompiling bindings.
|
||||
|
||||
#define INTERNAL_MODULE_REGISTRY_GENERATE_(globalObject, vm, SOURCE, moduleName) \
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm); \
|
||||
\
|
||||
SourceCode source = JSC::makeSource(SOURCE, SourceOrigin(WTF::URL("builtin://" #moduleName ".js"_s)), #moduleName ".js"_s); \
|
||||
\
|
||||
JSFunction* func \
|
||||
= JSFunction::create( \
|
||||
vm, \
|
||||
createBuiltinExecutable( \
|
||||
vm, source, \
|
||||
Identifier(), \
|
||||
ImplementationVisibility::Public, \
|
||||
ConstructorKind::None, \
|
||||
ConstructAbility::CannotConstruct) \
|
||||
->link(vm, nullptr, source), \
|
||||
static_cast<JSC::JSGlobalObject*>(globalObject)); \
|
||||
\
|
||||
JSC::MarkedArgumentBuffer argList; \
|
||||
\
|
||||
JSValue result = JSC::call( \
|
||||
globalObject, \
|
||||
func, \
|
||||
JSC::getCallData(func), \
|
||||
globalObject, JSC::MarkedArgumentBuffer()); \
|
||||
\
|
||||
RETURN_IF_EXCEPTION(throwScope, {}); \
|
||||
ASSERT_INTERNAL_MODULE(result, moduleName); \
|
||||
#define INTERNAL_MODULE_REGISTRY_GENERATE_(globalObject, vm, SOURCE, moduleName) \
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm); \
|
||||
auto&& origin = SourceOrigin(WTF::URL(makeString("builtin://"_s, moduleName))); \
|
||||
SourceCode source = JSC::makeSource(SOURCE, origin, moduleName); \
|
||||
\
|
||||
JSFunction* func \
|
||||
= JSFunction::create( \
|
||||
vm, \
|
||||
createBuiltinExecutable( \
|
||||
vm, source, \
|
||||
Identifier(), \
|
||||
ImplementationVisibility::Public, \
|
||||
ConstructorKind::None, \
|
||||
ConstructAbility::CannotConstruct) \
|
||||
->link(vm, nullptr, source), \
|
||||
static_cast<JSC::JSGlobalObject*>(globalObject)); \
|
||||
\
|
||||
RETURN_IF_EXCEPTION(throwScope, {}); \
|
||||
\
|
||||
JSC::MarkedArgumentBuffer argList; \
|
||||
JSValue result = JSC::call( \
|
||||
globalObject, \
|
||||
func, \
|
||||
JSC::getCallData(func), \
|
||||
globalObject, JSC::MarkedArgumentBuffer()); \
|
||||
\
|
||||
RETURN_IF_EXCEPTION(throwScope, {}); \
|
||||
ASSERT_INTERNAL_MODULE(result, moduleName); \
|
||||
return result;
|
||||
|
||||
#if BUN_DEBUG
|
||||
@@ -129,11 +130,15 @@ JSValue InternalModuleRegistry::requireId(JSGlobalObject* globalObject, VM& vm,
|
||||
// so we want to write it to the internal field when loaded.
|
||||
JSC_DEFINE_HOST_FUNCTION(InternalModuleRegistry::jsCreateInternalModuleById, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe))
|
||||
{
|
||||
auto& vm = lexicalGlobalObject->vm();
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
auto id = callframe->argument(0).toUInt32(lexicalGlobalObject);
|
||||
|
||||
auto registry = static_cast<Zig::GlobalObject*>(lexicalGlobalObject)->internalModuleRegistry();
|
||||
auto module = registry->createInternalModuleById(lexicalGlobalObject, lexicalGlobalObject->vm(), static_cast<Field>(id));
|
||||
registry->internalField(static_cast<Field>(id)).set(lexicalGlobalObject->vm(), registry, module);
|
||||
return JSValue::encode(module);
|
||||
auto mod = registry->createInternalModuleById(lexicalGlobalObject, vm, static_cast<Field>(id));
|
||||
RETURN_IF_EXCEPTION(throwScope, {});
|
||||
registry->internalField(static_cast<Field>(id)).set(vm, registry, mod);
|
||||
return JSValue::encode(mod);
|
||||
}
|
||||
|
||||
} // namespace Bun
|
||||
|
||||
Reference in New Issue
Block a user