Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mlly throws [error] The URL must be of scheme file when called with absolute path on windows #297

Open
danielroe opened this issue Jan 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@danielroe
Copy link
Member

danielroe commented Jan 12, 2025

Environment

windows
mlly 1.7.3

Reproduction

danielroe/windows-reproductions#1

Describe the bug

When called with an absolute path on Windows, resolvePathSync fails.

Sample code:

import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

import { resolvePathSync } from 'mlly'

resolvePathSync(
  resolve(fileURLToPath(import.meta.url), '../plugins/router'))
  { extensions: ['.ts', '.js'] }
)

full reproduction

Additional context

originally encountered in nuxt/nuxt#30540

Logs

No response

@danielroe danielroe added the bug Something isn't working label Jan 12, 2025
@pi0
Copy link
Member

pi0 commented Jan 12, 2025

Node.js ESM resolve requires that Windows absolute paths (same limit of imports) have file proto.

I think for resolvePathSync wrapper we could identify windows absolute paths and do renormalization to avoid this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants