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

--cwd and --tsconfig #939

Closed
make-github-pseudonymous-again opened this issue Mar 24, 2022 · 3 comments · Fixed by #941
Closed

--cwd and --tsconfig #939

make-github-pseudonymous-again opened this issue Mar 24, 2022 · 3 comments · Fixed by #941

Comments

@make-github-pseudonymous-again

Is it expected that tsconfig resolves against the calling directory even when --cwd is specified? I have a use case where I have a browser lib and a node lib in the same repo that have distinct tsconfig.json files. Currently I have to specify the full path to make tsconfig.json discovery work, that is --cwd a/b/c --tsconfig a/b/c/tsconfig.json instead of just --cwd a/b/c --tsconfig tsconfig.json or just --cwd a/b/c. Is there some other configuration that I do not know about that would make this more intuitive?

@rschristian
Copy link
Collaborator

rschristian commented Mar 24, 2022

It's not intentional, no. Just an oversight!

If you're willing to implement this (I can otherwise take a look over the next couple days probably), it should be pretty simple (I believe. TS can quickly become a rabbit hole, so hopefully I'm not too naive for hoping this is simple).

rpt2 resolves a tsconfig.json against the current working dir. So what should happen is that when cwd != '.' and --tsconfig is undefined (default val), we should try to resolve a ​`${cwd}/tsconfig.json`​. If it exists, set options.tsconfig so it can be passed into the plugin here:

tsconfig: options.tsconfig,

Edit: Missed part of your comment. I don't think we want to do --cwd a/b/c --tsconfig tsconfig.json where that tsconfig path is actually a/b/c/tsconfig.json. That seems like it'd be quite confusing. I think --tsconfig can keep it's normal pathing, but we should try to pick up on any tsconfig.json in that directory.

Admittedly it'd be a bit annoying if you had to do --cwd a/b/c --tsconfig a/b/c/something-tsconfig.json, but easier to understand what's happening, IMO.

Edit 2: (Forgot to press "post" on this) Turns out rpt2 has a cwd option that we can use instead. Whoops. I've somehow read over that 3-4 times now.

Very easy fix.

@make-github-pseudonymous-again
Copy link
Author

Thanks @rschristian !

@rschristian
Copy link
Collaborator

Np, not sure when it'll make sense to cut a release but hopefully something like patch-package could hold you over in the mean time.

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

Successfully merging a pull request may close this issue.

2 participants