Skip to content

Commit

Permalink
ch-ch-ch-ch-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paperclover committed Aug 2, 2023
1 parent 29ed653 commit f145ae2
Show file tree
Hide file tree
Showing 10 changed files with 920 additions and 1,001 deletions.
31 changes: 2 additions & 29 deletions src/bun.js/bindings/CommonJSModuleRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,10 @@ bool JSCommonJSModule::evaluate(
JSC::MarkedArgumentBuffer arguments;
auto& vm = globalObject->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
// TODO: remove second arg, we do not use it ???
// was it object loader?
generator(globalObject, JSC::Identifier::fromString(vm, key), propertyNames, arguments);
RETURN_IF_EXCEPTION(throwScope, false);
// This goes off of the assumption that you only call this `evaluate` using a generator that explicity
// assigns the `default` export first.
JSValue defaultValue = arguments.at(0);
this->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), defaultValue, 0);
this->hasEvaluated = true;
Expand Down Expand Up @@ -754,33 +754,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo
RELEASE_AND_RETURN(throwScope, JSValue::encode(fetchResult));
}

// Used by $requireBuiltin(...) (Module.ts)
JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateAndLoadBuiltinModule, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe))
{
auto* globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
auto& vm = globalObject->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);

JSValue specifierValue = callframe->argument(0);
WTF::String specifier = specifierValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});

BunString specifierStr = Bun::toString(specifier);
BunString referrerStr = Bun::toString(""_s);

JSValue fetchResult = Bun::fetchCommonJSModule(
globalObject,
JSCommonJSModule::create(
jsCast<Zig::GlobalObject*>(globalObject),
specifier,
constructEmptyObject(globalObject), false),
specifierValue,
&specifierStr,
&referrerStr);

RELEASE_AND_RETURN(throwScope, JSValue::encode(fetchResult));
}

void RequireResolveFunctionPrototype::finishCreation(JSC::VM& vm)
{
Base::finishCreation(vm);
Expand Down
1 change: 0 additions & 1 deletion src/bun.js/bindings/CommonJSModuleRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Bun {

JSC_DECLARE_HOST_FUNCTION(jsFunctionCreateCommonJSModule);
JSC_DECLARE_HOST_FUNCTION(jsFunctionLoadModule);
JSC_DECLARE_HOST_FUNCTION(jsFunctionCreateAndLoadBuiltinModule);

class JSCommonJSModule final : public JSC::JSDestructibleObject {
public:
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/bindings/InternalModuleRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ 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, id) \
#define INTERNAL_MODULE_REGISTRY_GENERATE_(globalObject, vm, SOURCE, moduleName) \
auto throwScope = DECLARE_THROW_SCOPE(vm); \
\
SourceCode source = JSC::makeSource(SOURCE, SourceOrigin(WTF::URL("builtin://hi"_s)), "hi.js"_s); \
SourceCode source = JSC::makeSource(SOURCE, SourceOrigin(WTF::URL("builtin://"#moduleName".js"_s)), #moduleName".js"_s); \
\
JSFunction* func \
= JSFunction::create( \
Expand All @@ -42,7 +42,7 @@ namespace Bun {
globalObject, JSC::MarkedArgumentBuffer()); \
\
RETURN_IF_EXCEPTION(throwScope, {}); \
ASSERT_INTERNAL_MODULE(result, id); \
ASSERT_INTERNAL_MODULE(result, moduleName); \
return result;

#if BUN_DEBUG
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/bindings/ProcessBindingConstants.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Modelled off of https://github.com/nodejs/node/blob/main/src/node_constants.cc
// Note that if you change any of this code, you probably also have to change NodeConstantsModule.h
#include "ProcessBindingConstants.h"
#include "JavaScriptCore/ObjectConstructor.h"

Expand Down
13 changes: 0 additions & 13 deletions src/bun.js/bindings/generated.zig

This file was deleted.

Loading

0 comments on commit f145ae2

Please sign in to comment.