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

Does not work with Project References that have a rootDir in their tsconfig #145

Open
miguel-leon opened this issue Nov 10, 2022 · 5 comments

Comments

@miguel-leon
Copy link

In my main project tsconfig.json there is:

  "compilerOptions": {
    ...
    "outDir": "../dist/api",
    "baseUrl": ".",
    "paths": {
      "models": ["../models/src/index.ts"]
    }
  },
  "include": ["./src"],
  "references": [
    {
      "path": "../models"
    }
  ]

being models a Project Reference, there's a tsconfig.json file in its directory:

{
  "compilerOptions": {
    "composite": true,
    "outDir": "../dist/models",
    "rootDir": "./src"
  },
  "include": ["./src"]
}

This means the output of tsc will be put directly in ../dist/models skipping the src subdirectory.

When tsc-aliases runs, it is trying to locate the file dist/models/src/index.js, deems it invalid and doesn't replace the import.
But it should have been looking in dist/models/index.js instead.

@raouldeheer
Copy link
Contributor

@miguel-leon can you provide us the console output when running with --debug?

@miguel-leon
Copy link
Author

It contained a lot of unnecessary information, because it wasn't a new empty project.
I took the path it is trying to locate ...dist/models/src/index.js from that output, that's how I know.
Also there wasn't any signs of the models/tsconfig.json being loaded to check up on the rootDir.

I already moved on, so I don't have it anymore.
I was letting you guys know in case you were interested.

@raouldeheer
Copy link
Contributor

This issue could probably be solved by changing
"models": ["../models/src/index.ts"]
to
"models": ["../models/src/index.ts", "../models/index.js"]

@sadofriod
Copy link

I think an update to rootDir's parsing is needed to fully resolve this issue here. Make it possible to parse the directory after the build.

@forgetso
Copy link

This issue could probably be solved by changing "models": ["../models/src/index.ts"] to "models": ["../models/src/index.ts", "../models/index.js"]

This doesn't work.

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

No branches or pull requests

4 participants