Files
OmniRoute/tests/unit/sqljs-build-warning-8135.test.ts
Damian Pozimski 9442bdef0f fix(ci): clear the release/v3.8.51 base-reds on the PR fast path (#13635)
* docs: bring the provider count to the live 358 across the reference, diagrams and llm.txt mirrors

* chore(skills): regenerate the cli-tunnel SKILL.md for the tunnel create positional

* test: clear the ESLint errors in the volcengine upsert and resource-pressure tests

* test(autoCombo): complete the mode-pack ProviderCandidate fixtures for the open-sse typecheck

* fix(ci): allow the opencode-plugin-v2 workspace package in the pack artifact policy

* docs: list the WAL, vacuum, sql.js and pressure self-restart env vars in .env.example

* refactor(db): move the synced-model provider purge into its persistence module to break the models/providers cycle

* test(memory): use a plain label for the rerank loopback key fixture so gitleaks stays at zero

* chore(ci): register the eleven covering unit tests in stryker tap.testFiles

* test(grok-cli): run the reset-credit tests on a fixture clock inside the captured token window

* test(combo): seed real provider connections for the reset-aware strategy tests

* fix(db): keep operator custom models out of the listing-only synced catalog reader

* fix(i18n): translate the new settings and combo keys for vi and pt-BR and restore the zh-TW glossary term

* fix(sse): carry the upstream error code and type through the provider execution pipeline

* test(sse): re-point the chatCore and combo source guards at the split modules and refresh the translate-path golden

* fix(oauth): keep the server-only OAuth constants out of the provider detail client bundle

* test: align the sql.js, webpack, injection-scan and error-boundary guards with their merged contracts

* docs(changelog): record the v3.8.51 base-red sweep

* fix(sse): anchor the glued-prefix sk- credential pattern so error redaction scans in linear time

* docs(changelog): note the linear credential scan in the base-red sweep

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
2026-09-15 08:51:45 -03:00

46 lines
1.8 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const adapterPath = join(__dirname, "../../src/lib/db/adapters/sqljsAdapter.ts");
const source = readFileSync(adapterPath, "utf8");
test("#8135: sqljsAdapter must not statically resolve sql.js at build time", () => {
const lines = source.split("\n");
// Find lines containing `await import(` — the actual dynamic import call.
// (Exclude `typeof import(...)` type annotations.)
const dynamicImportLines = lines.filter(
(l) => l.includes("await import(") && !l.includes("typeof import(")
);
assert.ok(
dynamicImportLines.length > 0,
"sqljsAdapter should have at least one dynamic import call"
);
// None of the runtime dynamic import calls should use a literal "sql.js" specifier
for (const line of dynamicImportLines) {
assert.ok(
!line.includes('import("sql.js")'),
"sqljsAdapter should not use a literal import('sql.js') at runtime — use a computed specifier"
);
}
// The webpackIgnore magic comment must be present
assert.ok(
source.includes("/* webpackIgnore: true */"),
"sqljsAdapter dynamic import should include /* webpackIgnore: true */ magic comment"
);
// The standalone assembler ships sql.js as a real runtime package, so the
// adapter must not depend on a build-time createRequire/require.resolve lookup.
assert.doesNotMatch(source, /createRequire\(\s*(?:import\.meta\.url|__filename)/);
assert.doesNotMatch(source, /^const\s+\w+\s*=\s*(?:\w+\.)?createRequire\s*\(/m);
assert.doesNotMatch(source, /\.resolve\(["']sql\.js["']\)/);
assert.match(source, /process\.cwd\(\)[\s\S]*"node_modules"[\s\S]*"sql\.js"/);
});