mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
* fix(ci): resolve upstream-inherited check failures
* fix(build): suppress sql.js build warning via non-analyzable import
Replace literal import('sql.js') with a computed specifier and
webpackIgnore magic comment so Next.js/webpack doesn't try to
statically resolve sql.js/package.json during the build phase.
Fixes #8135
---------
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 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"
|
|
);
|
|
});
|