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

Don't create tsconfig.json if tsconfig.base.json exists #6199

Closed
vjsingh opened this issue Jan 14, 2019 · 8 comments
Closed

Don't create tsconfig.json if tsconfig.base.json exists #6199

vjsingh opened this issue Jan 14, 2019 · 8 comments
Assignees

Comments

@vjsingh
Copy link

vjsingh commented Jan 14, 2019

Is this a bug report?

no

When running react-scripts start, the script creates a tsconfig.json even though I already have a tsconfig.base.json.

The base file is used because I have multiple projects (client and server) that inherit from this base file. I don't see any reason that it wouldn't be safe to avoid generated a tsconfig.json if tsconfig.base.json exists?

@Timer @ianschmitz

@mrmckeb
Copy link
Contributor

mrmckeb commented Jan 15, 2019

Hi @vjsingh, I did a quick search and found this pattern in a few places, but as far as I could see, tsconfig.base.json is not an officially supported structure. Please correct me if I'm wrong.

Could you extend your config with our tsconfig.json?

A few thoughts on this:

The tsconfig.json file we create is also validated to work with our current TS implementation, to ensure no build-related errors when working with TypeScript. If we allow people to specify a config further up the tree, this becomes much harder to manage.

There is also work underway to make tsconfig.json a more integral part of create-react-app. See: #6116.

@mrmckeb mrmckeb self-assigned this Jan 15, 2019
@vjsingh
Copy link
Author

vjsingh commented Jan 15, 2019

Thanks @mrmckeb, I think you're right that this may not be needed. I did some reading on #6116 yesterday and some other issues around tsconfig.json. The main reason I implemented this structure was for absolute paths, so I'm hoping to use the standard structure if it supports everything I need.

I'm having a lot of trouble going from my current react-native setup with react-native-scripts-ts to trying to use create-react-app so that I can use react-native-web.

Currently, I run my native project with "start": "TSCONFIG_PATH='src/tsconfig.json' react-native-scripts-ts start"

There are I think 3 things that the tsconfig.base.json structure gives me:

  • two independent typescript modules for my server and my client
  • Client and server can specify absolute imports starting at their root, instead of the project root
  • there are two different outdirs in the two extended tsconfig.jsons which I think let's me build these projects separately?

Is there an example repo or recommended setup for create-react-app that is also a react native app, and has a server typescript project in the same repo? I was looking around for something like this yesterday and couldn't find it.

@mrmckeb
Copy link
Contributor

mrmckeb commented Jan 15, 2019

No problem @vjsingh.

So, I am not sure if there's an example repo set up that does this - as we don't provide one.

I understand what your requirement is now, and why you have the tsconfig.base.json. I think the issue you'll face is that we haven't designed our implementation to handle this use case (yet). We're looking to improve our implementation in the near future, as we've had a lot of feedback - people want to do a lot of different and exciting things with CRA, and we want to support that as much as we can.

For your specific use case, you could also consider forking this project, and building your own react-scripts. You wouldn't need too many changes, and forking is quite maintainable (I have a fork running for a client's project).

@vjsingh
Copy link
Author

vjsingh commented Jan 15, 2019

@mrmckeb Thanks again I appreciate the help, having trouble navigating these murky build and compiler waters.

Forking sounds like my best option at this point so I'll go ahead and close this. Since you understand my use case though, I'd really appreciate any resources of any kind or links to existing similar forks that you could share!

@vjsingh vjsingh closed this as completed Jan 15, 2019
@vjsingh
Copy link
Author

vjsingh commented Jan 15, 2019

@mrmckeb I followed this guide to fork react-scripts: https://medium.com/@denis.zhbankov/maintaining-a-fork-of-create-react-app-as-an-alternative-to-ejecting-c555e8eb2b63

I am getting this error after trying to installing my react-scripts fork: Cannot find module 'react-dev-utils/chalk'

I believe it is related to this comment in that article:

It seems that the latest version of react-scripts depends on other local packages supplied in “create-react-app/packages” (react-dev-utils, babel-plugin-named-asset-import). I think this approach could be painful to maintain as create-react-app continues to evolve.

Probably missing something simple here, but what is the recommended procedure for using a custom fork of react-scripts?

@vjsingh
Copy link
Author

vjsingh commented Jan 15, 2019

OK, would still probably be nice to have my own fork, but I managed to get my setup working correctly and with absolute imports using this comment, and also setting NODE_PATH=src in my .env at the root level

@mrmckeb
Copy link
Contributor

mrmckeb commented Jan 16, 2019

Hi @vjsingh, this could be related to this PR: #6150

Can you share your fork with me (even privately)? I can take a quick look.

@vjsingh
Copy link
Author

vjsingh commented Jan 16, 2019

@mrmckeb it does seem like it could be related to that PR. I just cloned the create-react-app repo, made an insignificant change and then published react-scripts to npm. Following the guide in that article

You should be able to repro like this:
npm remove react-scripts; npm install @vjsingh/react-scripts: npm-scripts start-web

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants