Skip to content

Mounted Volume in the path causes incorrect resolution output #65

@chenxinyanc

Description

@chenxinyanc

Minimal repro here: https://github.com/chenxinyanc/unrs-resolver-mounted-partition

When resolving for a module, if there is a mount point instead of ordinary folder within the path of the resolved file, unrs-resolver gives incorrect outputs.

I'm reporting this issue because both eslint-import-resolver-typescript and eslint-plugin-import-x are using unrs-resolver.

Image

For example, suppose there is a Mounted Volume named "mount-root" under current directory, the following code

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { ResolverFactory } from "unrs-resolver";

const resolver = new ResolverFactory({
  tsconfig: {
    configFile: 'tsconfig.json',
  },
});
const dir = path.resolve(fileURLToPath(import.meta.url), '..');
// console.log("dir: ", dir);

const resolved = resolver.sync(dir, './mount-root/foo.ts');
console.log(resolved);

currently prints something like

{
  path: '...\\unrs-resolver-mounted-partition\\src\\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\\foo.ts',
  moduleType: 'module',
  packageJsonPath: '...\\unrs-resolver-mounted-partition\\package.json'
}

where "Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}" is supposed to be "mount-root".

Please refer to the README.md of my reproduction repo attached above for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions