You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't create tsconfig.json if tsconfig.base.json exists #6199
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?
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.
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.
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).
@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!
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?
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 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
Activity
mrmckeb commentedon 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.jsonis 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.jsonfile 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.jsona more integral part of create-react-app. See: #6116.vjsingh commentedon 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.jsonstructure gives me:outdirs in the two extendedtsconfig.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 commentedon 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 commentedon 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 commentedon 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:
Probably missing something simple here, but what is the recommended procedure for using a custom fork of react-scripts?
vjsingh commentedon 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=srcin my .env at the root levelmrmckeb commentedon 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 commentedon 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