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

Problem with "paths" in tsconfig configuration #126

Closed
michelecocuccio opened this issue Jan 15, 2022 · 4 comments
Closed

Problem with "paths" in tsconfig configuration #126

michelecocuccio opened this issue Jan 15, 2022 · 4 comments

Comments

@michelecocuccio
Copy link

michelecocuccio commented Jan 15, 2022

Hello. Thank for the awesome library.
I am currently using paths in my tsconfig as I have a very complex structure folder. The project itself compiles perfectly but when it's bundled I get imports error (I am using the example folder to test the project).

Error: The following dependencies are imported but could not be resolved:

  store (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  store/reducers/srlSlice (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  utils (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  hooks (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  styledComponents/SRLLightboxSC (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  SRLComponents/SRLContainer (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)

Is there a way to make sure the paths are compiled correctly when the project is bundled?

Paths in tsconfig
Project structure
Dist folder

Your environment

  System:
    OS: macOS 12.0.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 39.71 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /usr/local/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 95.0.2
    Safari: 15.1
  npmPackages:
    dts-cli: ^1.1.5 => 1.1.5
    typescript: ^4.5.4 => 4.5.4

@aladdin-add
Copy link

have you tried @rollup/plugin-alias?

@aladdin-add
Copy link

aladdin-add commented Jan 15, 2022

and it also would be great if dts can auto read aliases from tsconfig.json => paths.

@michelecocuccio
Copy link
Author

@aladdin-add thank you very much. I just tried but no luck :( I have also renamed all the path to be @/components/ adding the @ for example in order to avoid compatibility issues but I still have the same issues :(

@aladdin-add
Copy link

looks like rpt2 will read the paths in your tsconfig.json, while jest will not. so you just need to add your jest config. 😄

see the branch: https://github.com/weiran-zsd/dts-cli/tree/issue126

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

2 participants