-
Notifications
You must be signed in to change notification settings - Fork 0
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
Path map problem with monorepo (ts-pack) #42
Comments
Hi, Thanks for leaving such a detailed issue! It's super appreciated. I'm unfamiliar with how moonrepo co-ordinates it's imports, but by your description, it sounds like there's an inherent mis-match. The tsconfig points me to believe that the path aliasing that's been set up is being resolved to an absolute path (100% intentional), where as through tsc, that path import hasn't been. For now, since it would appear that you have the module installed as a dependency from the workspace (I'm assuming that there is still a node_modules folder in the same directory as the package.json) , have you tried removing the path-aliasing from the tsconfig file and seeing if it builds correctly? |
Yes, removing the configuration of routes and route references works fine, but the problem is that I need that configuration for typescript typing because then it will complain that it does not find the types of that package. That's why I ask if there is a way to disable this behavior by setting a flag or something, to make it optional. |
If that's the case, I would look into how However, if you can do me a favour, if you are able to produce a minimal reproduction of the issue in a repo and share that, I can better investigate the issue and see what behaviour is needed to better support this use case. |
The problem is because of the The TypeScript (tsc) generates a structure like this one from - dist
- main.js
- main.d.ts
- services
- service.js
- service.d.ts
- package.json
- CHANGELOG.md So there is no single type file that has everything. I hope you find this information useful as I am unable to provide you with a repository for its reproduction at this time. |
Directory structures like these are no problem - You might be interested in the reasoning behind the "exports" field in package.json - it's been a talking point from the creators @ Redux Toolkit and they faced a similar issued when it came to consuming the library that they ship. TL;DR - "exports" property in package.json is a powerhouse for this "multiple modules in a single library" approach, examplified here: https://github.com/reduxjs/redux-toolkit/blob/556b20b1f75ef214a34876385626659c5e9b7f57/packages/toolkit/package.json#L28-L50 |
Yes, I understand your point, but it is a very cumbersome thing to do when you have many modules that you need to export. |
I am currently using a monorepo system together with @moonrepo, so moonrepo synchronizes the paths of all the projects where I use other projects, and the structure looks like this:
Then I also install as a dependency the project that is used in the current project to be compiled:
This is how I use it in my code:
The problem is that ts-pack when compiling resolves me the package "@naeko/service" as path, then the compiled file becomes:
Which is incorrect because I don't need it to resolve the path, since I already installed the project as a dependency in the project to compile, so now it throws the following error:
And this is because the path that ts-pack put is the path to the original .ts file of the project. How can I make ts-pack not to change the import for this route? When I compile with tsc using the same tsconfig.json file configuration this behavior does not happen.
The text was updated successfully, but these errors were encountered: