Merge import.meta.require and require to be the same thing (#3732)

* Merge import.meta.require and require to be the same thing

* support `require` and BunPlugin (runtime plugin)

* plugins

* unused code

* revert launch.json
This commit is contained in:
dave caruso
2023-07-24 19:32:04 -07:00
committed by GitHub
parent 1f1d0bfcfb
commit 8a0152e129
17 changed files with 234 additions and 290 deletions

View File

@@ -2,6 +2,7 @@
#include "./NodeModuleModule.h"
#include "CommonJSModuleRecord.h"
#include "ImportMetaObject.h"
#include "JavaScriptCore/JSBoundFunction.h"
#include "JavaScriptCore/ObjectConstructor.h"
@@ -126,14 +127,13 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleCreateRequire,
if (callFrame->argumentCount() < 1) {
throwTypeError(globalObject, scope,
"createRequire() requires at least one argument"_s);
return JSC::JSValue::encode(JSC::jsUndefined());
RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::jsUndefined()));
}
auto val = callFrame->uncheckedArgument(0).toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined()));
auto clientData = WebCore::clientData(vm);
RELEASE_AND_RETURN(
scope, JSValue::encode(Zig::ImportMetaObject::createRequireFunction(
scope, JSValue::encode(Bun::JSCommonJSModule::createBoundRequireFunction(
vm, globalObject, val)));
}
extern "C" EncodedJSValue Resolver__nodeModulePathsForJS(JSGlobalObject *,