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

Support ts 5.5 tsconfig.json with ${configDir} #133

Closed
Q16solver opened this issue May 20, 2024 · 10 comments
Closed

Support ts 5.5 tsconfig.json with ${configDir} #133

Q16solver opened this issue May 20, 2024 · 10 comments
Assignees

Comments

@Q16solver
Copy link

Hello! Recently, ts 5.5 was announced in beta with new feature https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#the-configdir-template-variable-for-configuration-files
This lets us share tsconfig across packages, and I wanted to use it for my monorepo, but ctix cannot find the files properly, my guess is that it's still using an older version of typescript, I'm not sure if it's this package? or from the ts-morph package where it wraps the ts compiler API, I can think of perhaps 2 ways to solve it here:

Have a "next" branch that ups the deps to the beta version as well and simply just publish it as an alpha/beta
Have the typescript dep as a peerDep? and have userland install the required version? I'm not sure if that actually works, just a thought
For reference I used with typescript ver: "5.5.0-dev.20240518",
and shared configuration package I'm trying to create: https://github.com/Esposter/Esposter/tree/shared-configuration/packages/configuration
usage: https://github.com/Esposter/Esposter/blob/shared-configuration/packages/shared/package.json

@imjuni
Copy link
Owner

imjuni commented May 21, 2024

Thank you for your feedback, @Q16solver :)

ctix has a strong dependency on the ts-morph package, and ts-morph has TypeScript as a devDependency, so changing TypeScript to a peerDependency is a great idea, but I don't think it would be easy to change it right away because I can't imagine what problems users will have when using a lower version of TypeScript than ctix expects.

However, using a higher version of the TypeScript compiler doesn't seem to be a big problem. As a workaround, could you try using the overrides feature?

@imjuni imjuni self-assigned this May 21, 2024
@Q16solver
Copy link
Author

Q16solver commented May 22, 2024

@imjuni Yep! It serves as a good workaround for now, for others who also want to use this feature, here's my PR which hopefully provides a good enough example of how to use it https://github.com/Esposter/Esposter/pull/249/files
using pnpm workspaces and pnpm overrides. I think we can leave this open until ts 5.5 is released and we should be able to remove the overrides workaround after

Edit: nvm this doesn't work lol

@imjuni
Copy link
Owner

imjuni commented Jun 24, 2024

@Q16solver Hello, thank you for your patience

ctix now supports TypeScript 5.5. I also tested the peerDependencies you suggested and it works fine, so I moved TypeScript to peerDependencies.

@imjuni imjuni closed this as completed Jun 25, 2024
@Q16solver
Copy link
Author

Q16solver commented Jun 25, 2024

Seems to work now, thanks!

Edit: ctix still is unable to detect the files and builds empty index.js files, might be something to do with ts-morph

@imjuni imjuni reopened this Jun 27, 2024
@imjuni
Copy link
Owner

imjuni commented Jun 27, 2024

@Q16solver Can you please provide a reproducible repo, or tell me what I need to do in the repo mentioned in the first issue. Thank you.

@Q16solver
Copy link
Author

Q16solver commented Jun 27, 2024

@imjuni If you fork my repo https://github.com/Esposter/Esposter:

  1. Change to shared-configuration branch
  2. Pnpm i
  3. Cd packages/shared for example
  4. Run pnpm build

You should encounter the issue that dist files are empty. If you then change the tsconfig to be the non config dir one (you can reference main branch), then ctix generates fine

Thanks for being willing to investigate!

@imjuni
Copy link
Owner

imjuni commented Jul 2, 2024

@Q16solver Hello,

Due to my recent personal circumstances, it is difficult for me to analyse the problem at this code level. I looked at the repo you uploaded and saw that the include' and exclude' options are missing from the .ctirc file. Could you please add the include and exclude options to your .ctirc file and try again? The include and exclude options work the same as in the tsconfig.json file.

I think the problem is that the tsconfig.json file in the shared project doesn't have the include and exclude options, so it can't find the project files to add to the index.ts file.

@Q16solver
Copy link
Author

@imjuni oh you're right! seems like doing **/*.ts in include option fixes this. Maybe there's some issue now with ctix trying to use $configDir in tsconfig and would only work with normal paths. But either way, this is a good enough workaround, I'm happy for us to close this now, thanks so much C:

@imjuni
Copy link
Owner

imjuni commented Jul 3, 2024

@Q16solver

ctix looks for the target file in the include option; if there is no include option, it uses the TypeScript Compiler API to read the tsconfig.json file and use the SourceFiles list included in the Config object instead of ctix's include option.

However, if neither the ctix include option nor the include option in the tsconfig.json file is present, it creates an empty index.ts file.

I'll add a feature to tell about this in the next version to make it more obvious, thanks.

@imjuni imjuni closed this as completed Jul 3, 2024
@Q16solver
Copy link
Author

Q16solver commented Jul 3, 2024

Yeah, though it seems like if the include in tsconfig has $configDir, it doesn't read it properly, might be some weird incompatibilities with how I've specified it with $configDir/src/**/*.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants