Skip to content

Plugin fails to resolve import aliases defined in tsconfig files that are not in the same directory hierarchy as the importer. #190

@Pentadome

Description

@Pentadome

I'm trying to use the same import aliases in my test files as in my source files in a Nuxt project.

Nuxt generates a tsconfig.json like so:

{
  "files": [],
  "references": [
    {
      "path": "./.nuxt/tsconfig.app.json"
    },
    // ...

And one of those configs might define an alias like so:

{
  "compilerOptions": {
    "paths": {
      "@": [
        "../app"
      ],
      // ...

When the plugin tries to import something, it looks at the importer path, e.g. /my-project/tests/mytest.ts, and tries to look for an ancestors directory in the resolversByDir variable. The problem is is that resolversByDir does not contains a key /my-project/tests or /my-project, but only /my-project/.nuxt and thus failing to resolve the import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions