From cb263c7fa1e2eaa37ec65e20ac3322934f708501 Mon Sep 17 00:00:00 2001 From: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Date: Tue, 2 Jun 2026 14:16:25 +0800 Subject: [PATCH] fix(build): externalize lazily-imported optional drivers (unbreak main from #1524) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1524 moved optional internal @objectstack peerDependencies off `peer`; tsup then bundled the lazily await-import()'d driver packages and hit their optional native deps (mysql/oracledb via knex) → build failure for service-datasource & plugin-dev. - service-datasource: tsup `external: [/^@objectstack\/driver-/]` (drivers stay devDeps for tests, never bundled). - plugin-dev: framework packages devDeps → dependencies (tsup auto-externalizes deps; dev-only plugin, force-install is fine). Verified: full `pnpm build` 71/71 green; `changeset status` still 0 major (7.6.0). Co-Authored-By: Claude Opus 4.8 --- .changeset/fix-build-optional-driver-bundling.md | 14 ++++++++++++++ packages/plugins/plugin-dev/package.json | 8 ++++---- .../services/service-datasource/tsup.config.ts | 7 ++++++- pnpm-lock.yaml | 14 +++++++------- 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 .changeset/fix-build-optional-driver-bundling.md diff --git a/.changeset/fix-build-optional-driver-bundling.md b/.changeset/fix-build-optional-driver-bundling.md new file mode 100644 index 000000000..a8c911085 --- /dev/null +++ b/.changeset/fix-build-optional-driver-bundling.md @@ -0,0 +1,14 @@ +--- +"@objectstack/plugin-dev": patch +"@objectstack/service-datasource": patch +--- + +fix(build): don't bundle lazily-imported optional drivers (fixes build break from #1524). + +After moving optional internal `@objectstack/*` peerDependencies off `peer` (to +stop the changesets fixed-group major cascade), tsup no longer auto-externalized +them and began bundling the lazily `await import()`-ed driver packages — pulling +in their optional native clients (`mysql` / `oracledb` via knex) and failing the +build. Fix: `service-datasource` externalizes `@objectstack/driver-*` in tsup +(kept as devDeps for tests); `plugin-dev` moves its framework packages to +`dependencies` (auto-externalized; it's a dev-only plugin). Full build green. diff --git a/packages/plugins/plugin-dev/package.json b/packages/plugins/plugin-dev/package.json index a56aad040..a8711e981 100644 --- a/packages/plugins/plugin-dev/package.json +++ b/packages/plugins/plugin-dev/package.json @@ -19,9 +19,7 @@ "dependencies": { "@objectstack/core": "workspace:*", "@objectstack/spec": "workspace:*", - "@objectstack/types": "workspace:*" - }, - "devDependencies": { + "@objectstack/types": "workspace:*", "@objectstack/driver-memory": "workspace:^", "@objectstack/objectql": "workspace:^", "@objectstack/plugin-auth": "workspace:^", @@ -30,7 +28,9 @@ "@objectstack/plugin-security": "workspace:^", "@objectstack/rest": "workspace:^", "@objectstack/runtime": "workspace:^", - "@objectstack/service-i18n": "workspace:^", + "@objectstack/service-i18n": "workspace:^" + }, + "devDependencies": { "@types/node": "^25.9.1", "typescript": "^6.0.3", "vitest": "^4.1.8" diff --git a/packages/services/service-datasource/tsup.config.ts b/packages/services/service-datasource/tsup.config.ts index b2fbddc4c..665989911 100644 --- a/packages/services/service-datasource/tsup.config.ts +++ b/packages/services/service-datasource/tsup.config.ts @@ -10,5 +10,10 @@ export default defineConfig({ dts: true, format: ['esm', 'cjs'], target: 'es2020', - external: ['vitest'], + // Driver packages are loaded via optional, lazy `await import('@objectstack/driver-*')` + // (default-datasource-driver-factory) — and pull in optional native clients + // (mysql / pg / better-sqlite3 / mongodb). They must stay EXTERNAL so esbuild + // never tries to bundle/resolve those optional natives. (They are devDeps for + // tests; previously they were optional peerDeps, which tsup auto-externalized.) + external: ['vitest', /^@objectstack\/driver-/], }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0209fee86..8724cab55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1279,13 +1279,6 @@ importers: '@objectstack/core': specifier: workspace:* version: link:../../core - '@objectstack/spec': - specifier: workspace:* - version: link:../../spec - '@objectstack/types': - specifier: workspace:* - version: link:../../types - devDependencies: '@objectstack/driver-memory': specifier: workspace:^ version: link:../driver-memory @@ -1313,6 +1306,13 @@ importers: '@objectstack/service-i18n': specifier: workspace:^ version: link:../../services/service-i18n + '@objectstack/spec': + specifier: workspace:* + version: link:../../spec + '@objectstack/types': + specifier: workspace:* + version: link:../../types + devDependencies: '@types/node': specifier: ^25.9.1 version: 25.9.1