Skip to content

Commit 70bdb9d

Browse files
committed
fix: Migration handler not found in published package, fixes void-sdk/void#21
1 parent 147f2e8 commit 70bdb9d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/void/src/cli/wrapper.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ export async function generateWrapper(
102102
migrations = collectMigrations(migrationsDir);
103103
// Copy the migration handler runtime into the worker directory.
104104
// Pick the PG handler when the dialect is PostgreSQL, otherwise use the D1 handler.
105-
// Primary path: ../runtime/ relative to import.meta.dirname (dist/cli/ → dist/runtime/).
105+
// Bundled CLI chunks are emitted directly in dist/, while an unbundled CLI
106+
// entry would live in dist/cli/. Support both layouts plus source tests.
106107
const handlerFilename_ =
107108
features.migrationDialect === 'postgresql'
108109
? 'migration-handler-pg.mjs'
109110
: 'migration-handler.mjs';
110-
let handlerPath = join(import.meta.dirname, '..', 'runtime', handlerFilename_);
111+
let handlerPath = join(import.meta.dirname, 'runtime', handlerFilename_);
112+
if (!existsSync(handlerPath)) {
113+
handlerPath = join(import.meta.dirname, '..', 'runtime', handlerFilename_);
114+
}
111115
if (!existsSync(handlerPath)) {
112116
// Fallback for running from source (src/cli/) in tests — dist/runtime/ is two levels up.
113117
handlerPath = join(import.meta.dirname, '..', '..', 'dist', 'runtime', handlerFilename_);

0 commit comments

Comments
 (0)