8000 build: move the build steps and their drivers into the engine packages by colinhacks · Pull Request #68 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

build: move the build steps and their drivers into the engine packages - #68

Merged
colinhacks merged 9 commits into
mainfrom
engine-restructure
Oct 23, 2026
Merged

colinhacks merged 9 commits into
mainfrom
engine-restructure

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

reylo is what an app installs as a regular dependency and bundles; the engine packages are development dependencies. This moves everything that runs only at build time out of reylo and into the engine packages, gives each engine its own database driver for the type check, and keeps the parameter checks out of app bundles that don't use them.

What moves where

  • The build-time half goes into each engine package as tooling.js. It holds the analysis, the .reylo/ cache, the project file, the content mapper, the module the build steps write, and the CLI, all bundled from src/tooling.ts.
  • reylo keeps the run time, plus a thin entry for each thing a project names: reylo/vite, /esbuild, /webpack, /turbopack, /next, /jest, /register, the content mapper's exec, and the reylo bin.
    • Each entry loads tooling.js from the project's engine on first use, then from reylo's own install, and refuses one of another version (src/engine-package.ts).
    • It loads it with a require of the resolved path, which no bundler follows. A bundler fails on an import() of a package that isn't installed, and Turbopack warns about an import() of a computed URL once tsc wraps it in its helper. The build checks that each tooling.js loads with a require.
    • Every engine carries the same build-time code, so the first one installed serves a project of any database.
  • The type check describes through drivers the engines carry. The Postgres engine uses postgres.js and the MySQL engine uses mysql2, each pinned in its package and bundled into describe.js. Projects no longer need pg, postgres or mysql2 for the type check; those are no longer peers of reylo, and the pg describe path is gone. The analysis loads each describer by dialect. Errors that cross bundles (Unreachable, NotMysql) are recognized by a mark in the global symbol registry (src/connection.ts).
  • mysql2 ships without iconv-lite's East Asian multi-byte tables. MySQL converts results to the connection's character set, and the describer connects in UTF-8, so those tables are never read.
  • The parameter checks move behind one export. The JSON Schema validator and the structured-parameter and cast checks are now checks, exported from reylo. A written module imports it beside defineQuery only when its statement has such a parameter, and the run time reads it from the query (src/checks.ts). A query defined by hand with such a parameter gets an error saying to pass it.

Sizes

main This branch
reylo, unpacked 293 KB 175 KB
reylo, tarball 86 KB 51 KB
The run time an app bundles (esbuild, minified), when no statement needs the checks 62.7 KB (22.2 KB gzipped) 42.0 KB (15.5 KB gzipped)
The same, when a statement needs them 62.7 KB 63.2 KB
Added to each engine package tooling.js 89 KB; describe.js 40 KB (Postgres) and 618 KB (MySQL)

Setup changes

packages/postgres and packages/mysql each have their own install now, for their driver; CI and AGENTS.md add it. The drivers live there rather than at the repository root because a root install links them into nub's global store, outside the repository, and Turbopack refuses such a link in a project whose root is the repository (lab/nextjs). The connection tests no longer read the lab/basic and lab/mysql links, so CI stops making them. The docs and the examples' READMEs no longer tell projects to install a driver for the type check.

Verified

Run locally, all passing:

  • the typecheck, the loader's tests with none skipped, the package build and the docs site;
  • every example: Node, nub, Bun, Vite, Next.js, esbuild, webpack, Rspack, Jest and Cloudflare Workers, each of which links the built packages;
  • the labs: basic, pg-forms, repr, extends, emit, sqlite, jest, bundlers, Next.js on Turbopack and webpack, mysql, json-schema, drivers, and the driver matrix.

The Next.js builds print no warning from reylo. The built CLI and content mapper were also run in a project with no engine installed: each reports the missing engine with its install line, the content mapper as a diagnostic on the file.

The Postgres engine describes through postgres.js and the MySQL engine through mysql2, pinned in the repository and no longer resolved from the project, so the type check needs no driver of the project's and has one path per database.
Each engine package carries the type check, the module the build steps write and the CLI as tooling.js, and the Postgres and MySQL packages their describer with its driver inside. reylo keeps the run time and an entry for each thing a project names, which loads that half from the project's engine on first use.
A module a build step writes imports checks beside defineQuery only when its statement has a typed JSON, structured or cast parameter, so an app with none bundles 42 KB of run time instead of 63 KB.
An import() of a computed URL, which tsc wraps in a helper of its own, made Turbopack warn that it could not resolve the module on every Next.js dev and build; a require of the resolved path is followed by no bundler.
Copilot AI balanced review requested due to automatic review settings October 23, 2026 14:37
@vercel
vercel Bot commented Oct 23, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
reylo Ignored Ignored Preview Oct 23, 2026 3:37pm UTC

Request Review

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Dropping the pg describer sends every Postgres project's type check through postgres.js. A DATABASE_URL that uses libpq's TLS file parameters (sslrootcert=<file>, sslcert, sslkey) could connect before this change through pg, and now fails to connect.

Reviewed changes

I reviewed the full diff: the split of reylo into a run time plus entry points, with the build-time half carried by the engine packages, and the drivers moving into those packages.

  • Build-time half in the engine packages: src/tooling.ts is bundled into each @reylosql/<database>/tooling.js. The entry points in reylo load it with a require of the resolved path (src/engine-package.ts), and that load is version-checked.
  • Describers with their own drivers: packages/postgres/describe.ts (postgres.js) and packages/mysql/describe.ts (mysql2) are each bundled into describe.js and loaded by dialect through describer(). The pg path is gone, and so are the driver peers of reylo.
  • Errors that cross bundles: Unreachable and NotMysql now live in src/connection.ts and are recognized by a mark in the global symbol registry.
  • Parameter checks only where needed: checks is now exported from reylo. A written module imports it only when a parameter has a schema, a cast or a rows type, and execute.ts refuses such a parameter when the query has no checks.
  • CLI and content mapper split: src/commands.ts and src/mapper-server.ts hold the logic. src/cli.ts and src/mapper.ts are thin entries, and the mapper falls back to answering every file with the error when it cannot load the build-time half.
  • Setup, CI and docs: CI now installs in packages/postgres an 8000 d packages/mysql, and the links for lab/basic and lab/mysql are dropped. The docs and example READMEs no longer ask projects to install a driver for the type check.

ℹ️ Comments that still name the removed describer files

Two comments outside the diff still point at files this PR removes. src/engine.ts:123, on enginePath, says the engine is found "as its drivers are found (src/describe.ts)". oracle/src/mysql.rs:3 says the host answers "as the loader's does (src/mysql-describe.ts, through mysql2)". They should now name src/engine.ts (describer) and packages/mysql/describe.ts.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread packages/postgres/describe.ts Resolved
Comment thread src/mapper.ts Resolved
The site type-checks the engines' describe.ts files, whose drivers are installed in the package directories only on a developer's machine; the docs build has just the site's own install.
The fallback mapper answered every file with the missing-engine error until the TypeScript server restarted. Each call now looks for the engine again, opens the projects held meanwhile on it, and hands over. Also name the files that replaced the removed describers in two comments.
postgres.js sends a URL parameter it does not know to the server as a setting, which refuses sslrootcert, sslcert, sslkey and sslpassword. They now become the connection's TLS options, verified as sslmode asks.
@colinhacks
Copy link
Copy Markdown
Owner Author

Both inline comments are fixed on the branch. The two stale comments naming removed describer files now point at describer in src/engine.ts and packages/mysql/describe.ts.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new libpq TLS mapping doesn't verify the server's certificate for sslmode=require&sslrootcert=<file>. libpq checks the chain in that case, and so did pg before this PR.

Reviewed changes

I reviewed the two commits since the last review. Both prior threads are addressed and resolved, and so are the stale comments in src/engine.ts and oracle/src/mysql.rs.

  • Content mapper takes over a newly installed engine: src/mapper.ts now tries tooling() on every call. Once it loads, the mapper replays openProject for the projects the fallback held and hands over to mapperHandlers(), which src/mapper-server.ts now exports.
  • libpq TLS files as postgres.js TLS options: forPostgresJs removes sslrootcert, sslcert, sslkey and sslpassword from the URL and builds a tls.ConnectionOptions from them, with tests in tests/connect.test.ts.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread packages/postgres/describe.ts Resolved
Comment thread packages/postgres/describe.ts Resolved
As libpq does, sslmode=require with an sslrootcert file checks the certificate chain, and sslrootcert=system with a client certificate checks the chain and the host name; the file is read only when one is named.
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Both TLS threads from the last review are fixed, and I've resolved them.

Reviewed changes

I reviewed 6414c51, the only commit since the last review. It changes how forPostgresJs maps libpq's TLS parameters.

  • The chain is verified when a root certificate file is given: with sslmode=require and an sslrootcert file, the connection now checks the certificate chain but not the host name, as verify-ca does. With only sslcert/sslkey, require still checks nothing.
  • sslrootcert=system with a client certificate: read now opens only the keys in files, so the value system is never read as a file path. The connection checks the chain and the host name against Node's default roots, as verify-full does.
  • Doc comment and tests: the rule is stated above forPostgresJs, and tests/connect.test.ts asserts all three cases.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@colinhacks
colinhacks merged commit c8beec5 into main Oct 23, 2026
6 checks passed
@colinhacks
colinhacks deleted the engine-restructure branch October 23, 2026 15:50
8BD0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0