Skip to content

Commit 22df9b2

Browse files
authored
Revert "feat(unenv-preset): add support for native node:sqlite module (#11805)" (#11826)
This reverts commit 47e9638.
1 parent 7d63fa5 commit 22df9b2

File tree

4 files changed

+0
-104
lines changed

4 files changed

+0
-104
lines changed

.changeset/native-sqlite-module.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/unenv-preset/src/preset.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export function getCloudflarePreset({
8080
const consoleOverrides = getConsoleOverrides(compat);
8181
const vmOverrides = getVmOverrides(compat);
8282
const inspectorOverrides = getInspectorOverrides(compat);
83-
const sqliteOverrides = getSqliteOverrides(compat);
8483

8584
// "dynamic" as they depend on the compatibility date and flags
8685
const dynamicNativeModules = [
@@ -97,7 +96,6 @@ export function getCloudflarePreset({
9796
...consoleOverrides.nativeModules,
9897
...vmOverrides.nativeModules,
9998
...inspectorOverrides.nativeModules,
100-
...sqliteOverrides.nativeModules,
10199
];
102100

103101
// "dynamic" as they depend on the compatibility date and flags
@@ -115,7 +113,6 @@ export function getCloudflarePreset({
115113
...consoleOverrides.hybridModules,
116114
...vmOverrides.hybridModules,
117115
...inspectorOverrides.hybridModules,
118-
...sqliteOverrides.hybridModules,
119116
];
120117

121118
return {
@@ -638,39 +635,3 @@ function getInspectorOverrides({
638635
hybridModules: [],
639636
};
640637
}
641-
642-
/**
643-
* Returns the overrides for `node:sqlite` (unenv or workerd)
644-
*
645-
* The native sqlite implementation:
646-
* - is experimental and has no default enable date
647-
* - can be enabled with the "enable_nodejs_sqlite_module" flag
648-
* - can be disabled with the "disable_nodejs_sqlite_module" flag
649-
*/
650-
function getSqliteOverrides({
651-
compatibilityFlags,
652-
}: {
653-
compatibilityDate: string;
654-
compatibilityFlags: string[];
655-
}): { nativeModules: string[]; hybridModules: string[] } {
656-
const disabledByFlag = compatibilityFlags.includes(
657-
"disable_nodejs_sqlite_module"
658-
);
659-
660-
const enabledByFlag =
661-
compatibilityFlags.includes("enable_nodejs_sqlite_module") &&
662-
compatibilityFlags.includes("experimental");
663-
664-
const enabled = enabledByFlag && !disabledByFlag;
665-
666-
// When enabled, use the native `sqlite` module from workerd
667-
return enabled
668-
? {
669-
nativeModules: ["sqlite"],
670-
hybridModules: [],
671-
}
672-
: {
673-
nativeModules: [],
674-
hybridModules: [],
675-
};
676-
}

packages/wrangler/e2e/unenv-preset/preset.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -429,28 +429,6 @@ const localTestConfigs: TestConfig[] = [
429429
},
430430
},
431431
],
432-
// node:sqlite (experimental, no default enable date)
433-
[
434-
// TODO: add test for disabled by date (no date defined yet)
435-
// TODO: add test for enabled by date (no date defined yet)
436-
{
437-
name: "sqlite enabled by flag",
438-
compatibilityDate: "2024-09-23",
439-
compatibilityFlags: ["enable_nodejs_sqlite_module", "experimental"],
440-
expectRuntimeFlags: {
441-
enable_nodejs_sqlite_module: true,
442-
},
443-
},
444-
// TODO: update the date past the default enable date (when defined)
445-
{
446-
name: "sqlite disabled by flag",
447-
compatibilityDate: "2024-09-23",
448-
compatibilityFlags: ["disable_nodejs_sqlite_module", "experimental"],
449-
expectRuntimeFlags: {
450-
enable_nodejs_sqlite_module: false,
451-
},
452-
},
453-
],
454432
].flat() as TestConfig[];
455433

456434
describe.each(localTestConfigs)(

packages/wrangler/e2e/unenv-preset/worker/index.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -783,44 +783,6 @@ export const WorkerdTests: Record<string, () => void> = {
783783
assertTypeOf(inspectorPromises.default, "Network", "object");
784784
}
785785
},
786-
787-
async testSqlite() {
788-
// @ts-expect-error TS2307 - node:sqlite is experimental and may not have type declarations
789-
const sqlite = await import("node:sqlite");
790-
791-
// Common exports (both unenv stub and native workerd)
792-
assertTypeOfProperties(sqlite, {
793-
DatabaseSync: "function",
794-
StatementSync: "function",
795-
constants: "object",
796-
default: "object",
797-
});
798-
assertTypeOfProperties(sqlite.default, {
799-
DatabaseSync: "function",
800-
StatementSync: "function",
801-
constants: "object",
802-
});
803-
804-
if (getRuntimeFlagValue("enable_nodejs_sqlite_module")) {
805-
// Native workerd exports `backup` function and non-empty constants
806-
assertTypeOf(sqlite, "backup", "function");
807-
assertTypeOf(sqlite.default, "backup", "function");
808-
assert.strictEqual(
809-
"SQLITE_CHANGESET_OMIT" in sqlite.constants,
810-
true,
811-
"constants should contain SQLITE_CHANGESET_OMIT"
812-
);
813-
} else {
814-
// unenv stub: no backup function and empty constants
815-
assertTypeOf(sqlite, "backup", "undefined");
816-
assertTypeOf(sqlite.default, "backup", "undefined");
817-
assert.deepStrictEqual(
818-
Object.keys(sqlite.constants),
819-
[],
820-
"constants should be empty in unenv stub"
821-
);
822-
}
823-
},
824786
};
825787

826788
/**

0 commit comments

Comments
 (0)