mlly icon indicating copy to clipboard operation
mlly copied to clipboard

fix: tentative fix for absolute paths on windows

Open mrginglymus opened this issue 3 months ago • 4 comments

Given that upstream doesn't want to address this directly (https://github.com/wooorm/import-meta-resolve/issues/31) and downstream is now blocked on this (https://github.com/storybookjs/storybook/issues/32364) here's a tentative workaround for

  • fixes #297

mrginglymus avatar Sep 02 '25 11:09 mrginglymus

let's wait for @pi0 but i wonder if we should be fixing this at the source instead of the call site

https://github.com/unjs/mlly/blob/e9faaf89dae61d3c8baf1ee585cdf5781b116805/src/utils.ts#L14-L19

i feel like maybe this logic should be switcheroo'd?

export function fileURLToPath(id: string | URL): string {
  const idString = typeof id === 'string' ? id : id.href;
  if (id.startsWith("file://")) {
    return normalizeSlash(_fileURLToPath(id)); // pass the original `URL | string` since the built in fileURLToPath accepts both
  }
  return normalizeSlash(idString);
}

43081j avatar Sep 03 '25 08:09 43081j

Thanks for the PR. I haven't read it through but unlikely we make risky changes in mlly resolve utils anymore as should be deprecated.

I suggest migrating to exsolve and report any windows related issues (i think should be less/no issues with exsolve)

pi0 avatar Sep 03 '25 08:09 pi0

I've raised a PR to migrate to exsolve; however, at this late stage in the release cycle they may be unwilling to switch implementations.

mrginglymus avatar Sep 03 '25 09:09 mrginglymus

Added two comments on https://github.com/storybookjs/storybook/pull/32383

pi0 avatar Sep 03 '25 09:09 pi0