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

[Bug] Paths seems to be required but not sure why #146

Open
dborstelmann opened this issue Nov 3, 2021 · 5 comments
Open

[Bug] Paths seems to be required but not sure why #146

dborstelmann opened this issue Nov 3, 2021 · 5 comments
Labels
Bug Something isn't working

Comments

@dborstelmann
Copy link

I don't use paths in my project, just baseUrl like so:

{
  "extends": "../../tsconfig.packages.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist",
    "baseUrl": "./src"
  }
}

I have to add a blank paths to make this work. Is this avoidable?

Doesn't work:

"plugins": [
  { "transform": "typescript-transform-paths", "useRootDirs": true },
  { "transform": "typescript-transform-paths", "useRootDirs": true, "afterDeclarations": true }
]

Works great:

"paths": {
  "*": ["*"]
},
"plugins": [
  { "transform": "typescript-transform-paths", "useRootDirs": true },
  { "transform": "typescript-transform-paths", "useRootDirs": true, "afterDeclarations": true }
]
@nonara
Copy link
Collaborator

nonara commented Nov 3, 2021

Thanks for the report. That shouldn't happen, no. I recently discovered the same. It applies specifically to useRootDirs if paths isn't set.

I have it covered in the upcoming major release, but I will try to get a patch out in the next few days for you!

@nonara nonara added the Bug Something isn't working label Nov 3, 2021
@dborstelmann
Copy link
Author

Thanks for the quick response! This lib solved me running js in production tonight so it's much appreciated.

@nonara
Copy link
Collaborator

nonara commented Nov 14, 2021

Quick update (It's been a busy couple of weeks!)

As memory serves, I ran into some challenges surrounding this same area of code while working on what was supposed to be another small change. All of it is sorted out in the new upcoming major version, which has some significant internal changes.

That in mind, in the mean time, I'd suggest continuing to use the workaround. I'll leave this issue open and update you as soon as the next major comes out! At that point you won't need any workarounds

@fsmaia
Copy link

fsmaia commented Aug 9, 2022

https://github.com/LeDDGroup/typescript-transform-paths/blob/master/src/utils/resolve-path-update-node.ts#L39

It seems that this if statement is suppressing baseUrl resolution, which happens at resolveModuleName, right below.

I'll open a pull request trying to handle this, and then I would like to have some help identifying some other possible corner cases.

@nonara nonara changed the title Paths seems to be required but not sure why [Bug] Paths seems to be required but not sure why Oct 20, 2022
@holynewbie
Copy link

holynewbie commented Jan 17, 2023

any progress ? 😂 @nonara

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

4 participants