Fix import("bun") in Vite (#16938)

This commit is contained in:
Jarred Sumner
2025-01-31 06:34:14 -08:00
committed by GitHub
parent d4ce421982
commit 22a23add8d
5 changed files with 88 additions and 29 deletions

View File

@@ -539,11 +539,19 @@ JSValue fetchCommonJSModule(
auto tag = res->result.value.tag;
switch (tag) {
// require("bun")
case SyntheticModuleType::BunObject: {
target->setExportsObject(globalObject->bunObject());
target->hasEvaluated = true;
RELEASE_AND_RETURN(scope, target);
}
// require("module"), require("node:module")
case SyntheticModuleType::NodeModule: {
target->setExportsObject(globalObject->m_nodeModuleConstructor.getInitializedOnMainThread(globalObject));
target->hasEvaluated = true;
RELEASE_AND_RETURN(scope, target);
}
// require("process"), require("node:process")
case SyntheticModuleType::NodeProcess: {
target->setExportsObject(globalObject->processObject());
target->hasEvaluated = true;