Introduce bytecode caching, polish "cjs" bundler output format (#14232)

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
This commit is contained in:
Jarred Sumner
2024-09-30 22:37:42 -07:00
committed by GitHub
parent 857a472033
commit 2f7ff95e5c
39 changed files with 1284 additions and 234 deletions

View File

@@ -715,6 +715,23 @@ static JSValue fetchESMSourceCode(
return reject(exception);
}
// This can happen if it's a `bun build --compile`'d CommonJS file
if (res->result.value.isCommonJSModule) {
auto created = Bun::createCommonJSModule(globalObject, specifierJS, res->result.value);
if (created.has_value()) {
return rejectOrResolve(JSSourceCode::create(vm, WTFMove(created.value())));
}
if constexpr (allowPromise) {
auto* exception = scope.exception();
scope.clearException();
return rejectedInternalPromise(globalObject, exception);
} else {
return {};
}
}
auto moduleKey = specifier->toWTFString(BunString::ZeroCopy);
auto tag = res->result.value.tag;