[pull] main from tinacms:main#217
Merged
Merged
Conversation
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @tinacms/app@2.4.8 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## @tinacms/cli@2.3.1 ### Patch Changes - [#6850](#6850) [`629af08`](629af08) Thanks [@18-th](https://github.com/18-th)! - Fix the generated `client.ts` / `databaseClient.ts` `./types` import so it satisfies both TypeScript strict mode and Node native ESM. The generated import is now `import { queries } from "./types.js"` unconditionally, and the CLI emits a co-resident `types.js` alongside `types.ts` for TypeScript projects. Modern TS module resolution (`bundler` / `node16` / `nodenext`) rewrites the `.js` import back to `types.ts` at compile time, so type checking still sees the `.ts` source and `allowImportingTsExtensions` is not required, while Node ESM consumers resolve the on-disk `.js` file at runtime. - Updated dependencies \[[`890108d`](890108d)]: - @tinacms/graphql@2.4.1 - @tinacms/search@1.2.15 - tinacms@3.8.1 - @tinacms/app@2.4.8 ## @tinacms/datalayer@2.0.21 ### Patch Changes - Updated dependencies \[[`890108d`](890108d)]: - @tinacms/graphql@2.4.1 ## @tinacms/graphql@2.4.1 ### Patch Changes - [#6853](#6853) [`890108d`](890108d) Thanks [@kulesy](https://github.com/kulesy)! - fix(graphql): preserve absolute external URLs in image-type resolvers ## @tinacms/search@1.2.15 ### Patch Changes - Updated dependencies \[[`890108d`](890108d)]: - @tinacms/graphql@2.4.1 ## @tinacms/vercel-previews@0.2.8 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## next-tinacms-azure@13.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## next-tinacms-cloudinary@25.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## next-tinacms-dos@22.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## next-tinacms-s3@22.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## tinacms@3.8.1 ### Patch Changes - Updated dependencies \[]: - @tinacms/search@1.2.15 ## tinacms-authjs@22.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## tinacms-clerk@22.0.1 ### Patch Changes - Updated dependencies \[]: - tinacms@3.8.1 ## tinacms-gitprovider-github@4.1.8 ### Patch Changes - Updated dependencies \[]: - @tinacms/datalayer@2.0.21 Co-authored-by: Tina Release Bot <bot@tina.io>
Closes #6675 Part of #6750 ## Problem TinaCMS v3's CLI bundles `tina/database.ts` with esbuild and dynamically imports the result. Since the December 2025 ESM migration, this is wedged between two failure modes: 1. **Bundling** native modules (`better-sqlite3` via `sqlite-level`) crashes — `bindings` reads `__filename`/`__dirname`, which don't exist in ESM scope. See #6675. 2. **Externalizing** native modules from `os.tmpdir()` doesn't work either — Node's resolver walks up from the importing file's directory and never reaches the project's `node_modules`. ## Fix Two architectural changes plus the API + ergonomics work that comes out of them: ### Build cache moved into the project tree - `loadDatabaseFile` and `loadConfigFile` now write to `<project>/tina/__generated__/.cache/<timestamp>/` instead of `os.tmpdir()`, so Node can resolve `node_modules` from the bundle's location at runtime. - Each load removes its own subdir after the dynamic-import resolves, and `ConfigManager.processConfig()` sweeps `.cache/` on startup to clean up residue from crashed prior runs (Ctrl+C mid-build, OOM kills). - The empty `<timestamp>/` parent is also reaped after both loads complete (using `rmdirSync`, so concurrent in-flight loads don't conflict). - Read-only project mounts (Docker `:ro`, AWS Lambda `/var/task`, sandboxed CI runners) now fail with an actionable error explaining the cause and how to resolve it, instead of a cryptic mid-build `EACCES` from esbuild. ### Externalize curated baseline + user-extensible - `loadDatabaseFile` externalizes `better-sqlite3` so Node loads it as CJS where `__filename` exists. The `sqlite-level` wrapper stays bundled so esbuild handles its CJS named-export interop. - New `defineConfig` field: `build.externalDependencies?: string[]`. Users with custom native adapters outside the baseline can extend the externalize list from their config — discoverable, type-safe, version-controlled. Supersedes the env-var approach proposed in #6683. - The merge logic and baseline live in `external-resolver.ts` with 9 unit tests. ### `tina init` template - New projects (and existing projects without it) get `tina/__generated__` added to `.gitignore`. Belt + suspenders for the cache cleanup. ## Verification Manually verified end-to-end against `examples/next/tina-self-hosted-demo` temporarily reconfigured to use `SqliteLevel`: - Bundle lands in `<project>/tina/__generated__/.cache/<timestamp>/database/database.build.mjs` (not `/tmp/`) - Node loads `bindings.js`'s `__filename`-based path successfully - `better-sqlite3` native binary loads - SqliteLevel instantiates, opens the DB file, and gets through to content indexing - Cache directory is empty after the build The remaining indexing crash is a known SQL-injection bug in sqlite-level **v1**, fixed by [tinacms/sqlite-level#24](tinacms/sqlite-level#24) — tracked as a follow-up in #6848. Not in scope for this PR. The pre-existing mongo demo is unchanged so its CI coverage is preserved. A standalone SQLite example with full CI matrix is filed as #6786. ## Tests - 9 new unit tests on the externalize merge logic (`external-resolver.test.ts`) - All 180 CLI tests pass (was 171 pre-PR — 9 new) - Build clean, type-check clean (via `pnpm types`), format clean ## Follow-ups (filed) - #6786 — Add self-hosted SQLite example + PR-blocking CI matrix - #6787 — Add unit tests for `config-manager.ts` (output location, cache cleanup, watch list, etc.) - #6788 — Adapter compatibility test matrix - #6789 — Promote starter-template smoke subset to PR-blocking - #6847 — Migrate `mongodb-level` to ESM - #6848 — Bump `sqlite-level` to v2.x in `@tinacms/search` - #6849 — Expand the externalize baseline as adapters migrate --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JackDevAU <57518417+JackDevAU@users.noreply.github.com> Co-authored-by: kulesy <kulewidak@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Eli Kent [SSW] <69125238+kulesy@users.noreply.github.com> Co-authored-by: JackDevAU <jpr178@live.com.au>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: kulesy <kulewidak@gmail.com> Co-authored-by: Eli Kent [SSW] <69125238+kulesy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )