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

Imports breaking on >1.4.0 #79

Closed
ThiagoNP opened this issue Dec 15, 2021 · 6 comments
Closed

Imports breaking on >1.4.0 #79

ThiagoNP opened this issue Dec 15, 2021 · 6 comments

Comments

@ThiagoNP
Copy link

ThiagoNP commented Dec 15, 2021

I'm upgrading the dependencies on my projects, and after upgrading tsc-alias (to 1.4.1 or 1.5.0), some of my imports are breaking.

The paths on my tsconfig is like this:

"paths": {
      "~/*": ["./*"]
    },

But this

import { Dispatch } from 'redux';

Is becoming

import { Dispatch } from '../../redux';

I think it's because there is a redux folder on the folder it's compiling, but it should not be parsed, as it does not begins with ~/


Another problem I had, was because some paths were not being parsed if an asset was not present (on the release script they were added afterwards)

This import was not parsed if the svg file was not present in the dist folder

export { default as iconx } from '~/assets/icons/iconx.svg';
@raouldeheer
Copy link
Contributor

@ThiagoNP
What version are you using now?
Are you using tsc-alias with command-line?

@raouldeheer
Copy link
Contributor

raouldeheer commented Dec 15, 2021

@ThiagoNP

I think it's because there is a redux folder on the folder it's compiling, but it should not be parsed, as it does not begins with ~/

This is probably because it's resolving to the baseUrl. This could be solved by add a small config to tsconfig.json.
More info on this is in issue #71

{
  "compilerOptions": {
    ...
  },
  "tsc-alias": {
    "replacers": {
      "base-url": {
        "enabled": false
      }
    }
  }
}

The second problem happens because tsc-alias checks if the file exists, because if it doesn't it will use the next path in the array (in the tsconfig each path has an array of solutions).
But this problem can be easily fixed by added dummy files so that the file exists and resolves.

@raouldeheer
Copy link
Contributor

@justkey007 There has been no activity on this issue for over 14 days now. So, I assume the problem has been fixed or this issue could be marked as stale.

@Dezzymei
Copy link

This should be written about in the readme as this really messed me up!

@raouldeheer
Copy link
Contributor

@justkey007 Maybe we should add a link to the F.A.Q. #110 in the readme?

@justkey007
Copy link
Owner

@justkey007 Maybe we should add a link to the F.A.Q. #110 in the readme?

@raouldeheer I also think it will help a lot.

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