Skip to content

Conversation

@abdotop
Copy link
Member

@abdotop abdotop commented Jan 7, 2026

fix: remove unused imports and update dynamic import handling in migration

@abdotop abdotop self-assigned this Jan 7, 2026
Copilot AI review requested due to automatic review settings January 7, 2026 16:21
@abdotop abdotop merged commit 32a2ba9 into master Jan 7, 2026
5 checks passed
@abdotop abdotop deleted the fix-dynamic-imports-in-the-migration branch January 7, 2026 16:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix dynamic import handling in database migrations by removing the dependency on @std/path and simplifying the module URL construction. However, the implementation contains critical issues that will break functionality.

Key changes:

  • Removed @std/path imports (join, toFileUrl) from db/migration.ts
  • Simplified dynamic import URL construction to use string concatenation
  • Added explanatory comment and @ts-ignore directive for the dynamic import

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
db/migration.ts Removes @std/path imports and replaces path resolution logic with manual string concatenation for module URLs
db/deno.json Removes @std/path dependency from imports
deno.lock Updates lockfile to reflect removal of unused dependencies and upgrades several @std packages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


const absolutePath = join(Deno.cwd(), migrationsPath, migration.name)
const moduleUrl = toFileUrl(absolutePath).href
const moduleUrl = `file://${migrationsPath}/${migration.name}`
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The module URL construction is incorrect for relative paths. When migrationsPath is a relative path like './migrations', the resulting URL will be 'file://./migrations/001-initial.ts', which is not a valid file URL. This will cause the dynamic import to fail.

The previous implementation using join(Deno.cwd(), migrationsPath) and toFileUrl() correctly handled both absolute and relative paths. The new implementation doesn't normalize the path or ensure it's absolute before creating the file URL.

Copilot uses AI. Check for mistakes.
const moduleUrl = toFileUrl(absolutePath).href
const moduleUrl = `file://${migrationsPath}/${migration.name}`
// Dynamic import is intentional - migration files are provided by consumers at runtime
// @ts-ignore: JSR cannot analyze runtime-determined imports
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The ts-ignore directive should use a colon without a space. The correct syntax is @ts-ignore followed by an optional description separated by a single space, not a colon. The current syntax may not be properly recognized by TypeScript.

Suggested change
// @ts-ignore: JSR cannot analyze runtime-determined imports
// @ts-ignore JSR cannot analyze runtime-determined imports

Copilot uses AI. Check for mistakes.
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