mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
feat: Support import db from './my.db' with {type: "sqlite"} (#8178)
* Support SQLite imports * Docs * Update executables.md * Update loaders.md * Update js_parser.zig * Update loaders.md * Update CMakeLists.txt * Update Module.ts * JSC got rid of `$trunc`? --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -423,7 +423,8 @@ JSValue fetchCommonJSModule(
|
||||
JSCommonJSModule* target,
|
||||
JSValue specifierValue,
|
||||
BunString* specifier,
|
||||
BunString* referrer)
|
||||
BunString* referrer,
|
||||
BunString* typeAttribute)
|
||||
{
|
||||
void* bunVM = globalObject->bunVM();
|
||||
auto& vm = globalObject->vm();
|
||||
@@ -539,8 +540,7 @@ JSValue fetchCommonJSModule(
|
||||
}
|
||||
}
|
||||
|
||||
auto* loader = globalObject->moduleLoader();
|
||||
JSMap* registry = jsCast<JSMap*>(loader->getDirect(vm, Identifier::fromString(vm, "registry"_s)));
|
||||
JSMap* registry = globalObject->esmRegistryMap();
|
||||
|
||||
auto hasAlreadyLoadedESMVersionSoWeShouldntTranspileItTwice = [&]() -> bool {
|
||||
JSValue entry = registry->get(globalObject, specifierValue);
|
||||
@@ -557,7 +557,7 @@ JSValue fetchCommonJSModule(
|
||||
RELEASE_AND_RETURN(scope, jsNumber(-1));
|
||||
}
|
||||
|
||||
Bun__transpileFile(bunVM, globalObject, specifier, referrer, res, false);
|
||||
Bun__transpileFile(bunVM, globalObject, specifier, referrer, typeAttribute, res, false);
|
||||
|
||||
if (res->success && res->result.value.commonJSExportsLen) {
|
||||
target->evaluate(globalObject, specifier->toWTFString(BunString::ZeroCopy), res->result.value);
|
||||
@@ -606,7 +606,8 @@ static JSValue fetchESMSourceCode(
|
||||
Zig::GlobalObject* globalObject,
|
||||
ErrorableResolvedSource* res,
|
||||
BunString* specifier,
|
||||
BunString* referrer)
|
||||
BunString* referrer,
|
||||
BunString* typeAttribute)
|
||||
{
|
||||
void* bunVM = globalObject->bunVM();
|
||||
auto& vm = globalObject->vm();
|
||||
@@ -708,12 +709,12 @@ static JSValue fetchESMSourceCode(
|
||||
}
|
||||
|
||||
if constexpr (allowPromise) {
|
||||
void* pendingCtx = Bun__transpileFile(bunVM, globalObject, specifier, referrer, res, true);
|
||||
void* pendingCtx = Bun__transpileFile(bunVM, globalObject, specifier, referrer, typeAttribute, res, true);
|
||||
if (pendingCtx) {
|
||||
return reinterpret_cast<JSC::JSInternalPromise*>(pendingCtx);
|
||||
}
|
||||
} else {
|
||||
Bun__transpileFile(bunVM, globalObject, specifier, referrer, res, false);
|
||||
Bun__transpileFile(bunVM, globalObject, specifier, referrer, typeAttribute, res, false);
|
||||
}
|
||||
|
||||
if (res->success && res->result.value.commonJSExportsLen) {
|
||||
@@ -833,17 +834,19 @@ JSValue fetchESMSourceCodeSync(
|
||||
Zig::GlobalObject* globalObject,
|
||||
ErrorableResolvedSource* res,
|
||||
BunString* specifier,
|
||||
BunString* referrer)
|
||||
BunString* referrer,
|
||||
BunString* typeAttribute)
|
||||
{
|
||||
return fetchESMSourceCode<false>(globalObject, res, specifier, referrer);
|
||||
return fetchESMSourceCode<false>(globalObject, res, specifier, referrer, typeAttribute);
|
||||
}
|
||||
|
||||
JSValue fetchESMSourceCodeAsync(
|
||||
Zig::GlobalObject* globalObject,
|
||||
ErrorableResolvedSource* res,
|
||||
BunString* specifier,
|
||||
BunString* referrer)
|
||||
BunString* referrer,
|
||||
BunString* typeAttribute)
|
||||
{
|
||||
return fetchESMSourceCode<true>(globalObject, res, specifier, referrer);
|
||||
return fetchESMSourceCode<true>(globalObject, res, specifier, referrer, typeAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user