Skip to content

Fix ESM module detection to use pathToFileURL for cross-platform compatibility#1282

Draft
Copilot wants to merge 2 commits into
claude/fix-issue-1127-01PCszX1jdWVVsH7e1qptjyifrom
copilot/sub-pr-1255-again
Draft

Fix ESM module detection to use pathToFileURL for cross-platform compatibility#1282
Copilot wants to merge 2 commits into
claude/fix-issue-1127-01PCszX1jdWVVsH7e1qptjyifrom
copilot/sub-pr-1255-again

Conversation

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

PR Checklist:

  • Provide a meaningful description to this PR or mention which issues this fixes.
  • Ensure the project builds with npm run build
  • Add tests for your change. This includes negative tests (i.e. inputs that need to fail) as well as baseline tests (i.e. how should the directory structure look like?).
  • Run the test suite with npm test
  • If there are baseline changes, review them and make a separate commit for them with the comment "accept baselines" if they are desired changes
  • If you added a required option, also add it to the template creation (.github/create_templates.ts)
  • Add a detailed migration description to docs/updates explaining what the user needs to do when manually updating an existing project
  • Add your changes to CHANGELOG.md (referencing the migration description and this PR or the issue you fixed)

Description:

The ESM module detection condition was unreliable on Windows due to manual file URL construction. On Windows, file URLs must include the drive letter (e.g., file:///C:/path), but the template used file://${process.argv[1]} which produces incorrect URLs.

Changes:

  • Import pathToFileURL from Node.js url module for ESM templates
  • Replace manual URL construction with pathToFileURL(process.argv[1]).href

Before:

if (import.meta.url === `file://${process.argv[1]}`) {
    new AdapterClass();
}

After:

import { pathToFileURL } from 'url';

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
    new AdapterClass();
}

This ensures proper file URL format across all platforms.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…atibility

Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ESM module detection issue in create-adapter Fix ESM module detection to use pathToFileURL for cross-platform compatibility Jan 10, 2026
Copilot AI requested a review from Apollon77 January 10, 2026 21:30
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