|
41 | 41 | * duplicate: |
42 | 42 | * |
43 | 43 | * - **{@link LoadTursoDriverFactoryOptions.importDriverPackage} — the module |
44 | | - * resolution root.** `@objectstack/driver-turso` is an optional PEER of |
45 | | - * `@objectstack/cli` and is not declared by `@objectstack/runtime` at all. |
46 | | - * A bare `import('@objectstack/driver-turso')` resolves from the node_modules |
47 | | - * tree of the module that *evaluates* it, so moving the CLI's import into |
48 | | - * this file would look for the package under `@objectstack/runtime` — which |
49 | | - * under pnpm's strict layout does not link it. An operator who ran the |
50 | | - * install command the error tells them to run would still be told the package |
51 | | - * is missing. The CLI therefore keeps passing its own thunk; the default |
52 | | - * below is this package's own root, for the standalone stack. |
| 44 | + * resolution root.** `@objectstack/driver-turso` is an OPTIONAL PEER of |
| 45 | + * `@objectstack/cli` and, since #12943, of `@objectstack/runtime` too. An |
| 46 | + * optional peer NAMES the relationship and installs nothing, so the package |
| 47 | + * still sits in whichever tree the operator installed it into — and a bare |
| 48 | + * `import('@objectstack/driver-turso')` resolves from the node_modules tree |
| 49 | + * of the module that *evaluates* it. That is what keeps this a host-supplied |
| 50 | + * input rather than a duplicate: an operator who installed the package next |
| 51 | + * to the CLI put it in the CLI's tree, so moving the CLI's import into this |
| 52 | + * file would look for it under `@objectstack/runtime` and tell them it is |
| 53 | + * missing right after they ran the exact command the error printed. The CLI |
| 54 | + * therefore keeps passing its own thunk; the default below is this package's |
| 55 | + * own root, for the standalone stack. |
| 56 | + * ⚠️ Inside THIS workspace pnpm links an optional peer, so the default thunk |
| 57 | + * resolves here. Every test covering the missing-package arm therefore stages |
| 58 | + * the absence rather than relying on the layout to supply it (#12943). |
53 | 59 | * - **{@link LoadTursoDriverFactoryOptions.missingUrlError} — the error TYPE |
54 | 60 | * for a config with no url.** The CLI raises its own `UnsupportedDriverError` |
55 | 61 | * (a CLI-only semantic: `serve.ts` re-throws it as a fatal boot error), which |
@@ -149,15 +155,17 @@ export interface LoadTursoDriverFactoryOptions { |
149 | 155 | * |
150 | 156 | * NOT merely a test seam: the specifier resolves from the node_modules tree of |
151 | 157 | * whichever module evaluates the `import()`, and the package is an optional |
152 | | - * peer of `@objectstack/cli` while `@objectstack/runtime` does not declare it. |
153 | | - * The CLI passes its own thunk so its operators keep resolving the package |
154 | | - * they installed next to the CLI (see the module docstring). The default is |
155 | | - * this package's own root, which is what the standalone stack wants. |
| 158 | + * peer of BOTH `@objectstack/cli` and `@objectstack/runtime` (#12943) — a |
| 159 | + * declaration that installs nothing, so which tree actually holds the package |
| 160 | + * is still decided by where the operator installed it. The CLI passes its own |
| 161 | + * thunk so its operators keep resolving the package they installed next to the |
| 162 | + * CLI (see the module docstring). The default is this package's own root, |
| 163 | + * which is what the standalone stack wants. |
156 | 164 | * |
157 | 165 | * Tests pass a stub module (dispatch WITH the package) or a rejecting thunk |
158 | 166 | * (dispatch WITHOUT it) — neither needs a real Turso endpoint, and the |
159 | | - * missing-package path must stay testable in a workspace where the package |
160 | | - * happens to be installed. |
| 167 | + * missing-package path must stay testable in a workspace where the package IS |
| 168 | + * installed, which since the optional peer landed is every workspace. |
161 | 169 | */ |
162 | 170 | importDriverPackage?: () => Promise<unknown>; |
163 | 171 | /** |
@@ -193,10 +201,12 @@ export interface LoadTursoDriverFactoryOptions { |
193 | 201 | export async function loadTursoDriverFactory( |
194 | 202 | opts: LoadTursoDriverFactoryOptions = {}, |
195 | 203 | ): Promise<IDatasourceDriverFactory> { |
196 | | - // `as any` on the specifier: the package is deliberately NOT a dependency of |
197 | | - // `@objectstack/runtime` (that is what "optional" means here), so the literal |
198 | | - // must not be type-resolved. Same shape the shared factory uses for the other |
199 | | - // optional drivers (`default-datasource-driver-factory.ts`). |
| 204 | + // `as any` on the specifier: the package is an OPTIONAL PEER of |
| 205 | + // `@objectstack/runtime`, never a dependency (that is what "optional" means |
| 206 | + // here — #12943 declared the relationship, and an optional peer installs |
| 207 | + // nothing), so the literal must not be type-resolved: a consumer who did not |
| 208 | + // install it must still compile. Same shape the shared factory uses for the |
| 209 | + // other optional drivers (`default-datasource-driver-factory.ts`). |
200 | 210 | const load = opts.importDriverPackage ?? (() => import('@objectstack/driver-turso' as any)); |
201 | 211 | const missingUrlError = |
202 | 212 | opts.missingUrlError ?? ((message: string) => new Error(`[StandaloneStack] ${message}`)); |
|
0 commit comments