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

[Help] How to fork this repo? #1704

Closed
charles-goode opened this issue Mar 26, 2020 · 2 comments
Closed

[Help] How to fork this repo? #1704

charles-goode opened this issue Mar 26, 2020 · 2 comments

Comments

@charles-goode
Copy link

Issue Description

There's some problems with GC in my use case that are supposedly not going to be fixed, so I'd like to fork and fix them myself. However I'm having a really hard time with this due to the complications of npm prepublish and postinstall scrips and also likely to do with the use of TS. I tried to follow along some previous related issue: [#1265 ] but in the end it still didn't work. There seems to be a decent amount of confusion around this: [#1245 ] and [#1603] (where a user mentions not being able to get a fork to work). Obviously a lot of people are getting this to work so its certainly doable, but I think the difficulties are specific to this library (searching/googling has been unhelpful).

At this point I made the following changes (based on [#1265]):
In my own project, I added the postinstall script suggested to package.json.
In my fork of GC, I changed main: to "lib/index.js" in package.json

I install my fork with the command: npm install --save "charles-goode/react-native-gifted-chat" and when running my app via expo, I get the following variant of the error in the title of #1265:

While trying to resolve module react-native-gifted-chat from file C:\Users\goode\Dive\screens\GiftedChatScreen.js, the package C:\Users\goode\Dive\node_modules\react-native-gifted-chat\package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (C:\Users\goode\Dive\node_modules\react-native-gifted-chat\lib\index.js. Indeed, none of these files exist:

  • C:\Users\goode\Dive\node_modules\react-native-gifted-chat\lib\index.js(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)

  • C:\Users\goode\Dive\node_modules\react-native-gifted-chat\lib\index.js\index(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)

  • Nodejs version: 12.14.0

  • Expo SDK 36

  • react-native-gifted-chat version: Just forked, so the most recent (says 0.14 in the package.json).

  • Platform(s) (iOS, Android, or both?): Both but also N/A

  • TypeScript version: I don't use TS in my project.

@charles-goode
Copy link
Author

If I try to install my fork with yarn add charles-goode/react-native-gifted-chat. It fails in the build of my fork on the build command: rm -rf lib/ && node_modules/.bin/tsc && cp flow-typedefs/*.js.flow lib/ because of 24 TS errors. This is the same problem that a user has in the last comment on [#1265].

@charles-goode
Copy link
Author

charles-goode commented Mar 27, 2020

Ok after manually "fixing" the errors produced by tsc, it would seem that my fork installed into my app correctly. By the way most of the errors have to do with incorrect prop types for instances where a style prop is defined with as an object with a left property and right property.

So I would say the full solution is the following steps:

  1. press fork on GC
  2. clone your fork
  3. Change main in package.json to lib/index.js (this might not be necessary if rest of commands execute without error)
  4. Try to build (with yarn) so you get a list of TS errors
  5. Fix them
  6. make desired changes, commit, and push
  7. In main app add the following to script in package.json: "postinstall": "cd node_modules/react-native-gifted-chat && yarn install && yarn lint && yarn build && yarn config:npm && rm -rf node_modules"
  8. yarn add <githubrepo>

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

No branches or pull requests

1 participant