FredrikOseberg / react-chatbot-kit

MIT License
325 stars 156 forks source link

Question: how do you test your framework? #35

Open ojcchar opened 3 years ago

ojcchar commented 3 years ago

Hi Fredrik,

Great framework. It's been quite useful for us.

This is just a question. Not an issue.

We needed to modify the framework to meet our needs. I am wondering how do you build and test your framework in your machine? Disclaimer: we are not experts in npm, yarn, react, etc.

So, if I have an application (as a different project) that uses the framework, how do I build it and use it in my application, as opposed to using the npm package from the web?

So far, we have just copied the generated input.js into the node_modules directory. This seems like a dirty hack.

Any advice would be greatly appreciated.

Thank you.

FredrikOseberg commented 3 years ago

Hi Fredrik,

Great framework. It's been quite useful for us.

This is just a question. Not an issue.

We needed to modify the framework to meet our needs. I am wondering how do you build and test your framework in your machine? Disclaimer: we are not experts in npm, yarn, react, etc.

So, if I have an application (as a different project) that uses the framework, how do I build it and use it in my application, as opposed to using the npm package from the web?

So far, we have just copied the generated input.js into the node_modules directory. This seems like a dirty hack.

Any advice would be greatly appreciated.

Thank you.

Hi Oscar,

There's a few ways you could do this actually. The first way is to copy the source files directly form this project and include them in your own and then build them as a part of your own build pipeline.

The second way, and the one I would recommend is to fork this project, make the adjustments you need and then change the name in package.json and publish it to NPM under a different package name. Then you can include that package in your project.

For local development, you can use npm link in order to point your project to a local version of your package.

ojcchar commented 3 years ago

Thank you for your response, Fredrik.

I tried the third option with yarn.

However, I am running into an issue even if I use react-chatbot-kit unmodified (without my adjustments).

This is what I am doing:

  1. I cloned this repo (for now, I am not forking it)
  2. I built the kit, using yarn install (I believe I should build it this way)
  3. I ran yarn link
  4. In my own project, which uses the kit, I ran yarn link react-chatbot-kit
  5. I ran the project (using yarn start)
  6. I got the following error in the browser:

image

Note that if use the react-chatbot-kit published on npm, my application runs with no problem.

The problem only happens if I build react-chatbot-kit locally. BTW, I am running Windows, and this is what I get from building this package:

image

Maybe I am doing something wrong here. Any help would be appreciated.

FYI, this is the stack trace I am getting in the browser:

image

Thank you very much.

ojcchar commented 3 years ago

BTW, I tried removing yarn.lock, package-lock.json, node_modules, and build and I rebuilt the kit, but, I am having the same problem with my app.

FredrikOseberg commented 3 years ago

BTW, I tried removing yarn.lock, package-lock.json, node_modules, and build and I rebuilt the kit, but, I am having the same problem with my app.

In your local version, try running yarn build and make sure you have a dist folder after that.

ojcchar commented 3 years ago

hmmm I ran yarn build but no dist folder is created.

ojcchar commented 3 years ago

image

FredrikOseberg commented 3 years ago

hmmm I ran yarn build but no dist folder is created.

Looks correct. It should be a build folder, not dist, apologies. Do you have your project on github? I need to take a closer look to figure out what's going on. I just did a test on my machine running yarn link with a fresh create-react-app project without any issues.

ojcchar commented 3 years ago

This is the project.

burt-gui.zip

It uses the modified version of the framework and some local API calls, but the chatbot at least should be shown in the browser.

FredrikOseberg commented 3 years ago

This is the project.

burt-gui.zip

It uses the modified version of the framework and some local API calls, but the chatbot at least should be shown in the browser.

This works fine for me by linking with my local package. Could it be related to the changes you've done?

ojcchar commented 3 years ago

It is not the changes I've done to the framework because it happens even without these changes (with your repo).

I just discovered it is something related to the node_modules of the framework and perhaps the node_modules of my project.

When I delete the node_modules folder of the framework, the linking works, i.e., the app runs successfully. The error only happens when the node_modules folder is there.

Maybe it is some conflict between the node_modules of the framework and my project. Also, maybe it is something related to Windows. I need to test this in a Unix system.

Let me know if this rings the bell for you.

ojcchar commented 3 years ago

Ok, I am having the same problem on a Mac. I solve it if I remove the node_modules folder from the framework.

No idea why this happens. Clearly, the node_modules folder is somehow being used by node when I run my app. There must be some dependency conflicts or so.

The curious thing is that it works for you, so maybe I am doing something wrong.

ojcchar commented 3 years ago

@FredrikOseberg do you mind describing the process that you followed for linking the framework and testing my application?

Also, I don't know if you have experienced conflicts between the node_modules of different local packages, as it seems I have.

FredrikOseberg commented 3 years ago

@FredrikOseberg do you mind describing the process that you followed for linking the framework and testing my application?

Also, I don't know if you have experienced conflicts between the node_modules of different local packages, as it seems I have.

  1. Unzipped your repository
  2. Navigated to the react-chatbot-kit library folder on my local machine
  3. Ran yarn link
  4. Navigated to the folder containing your repository
  5. Ran yarn link react-chatbot-kit
  6. Removed the logic doing API calls to conditionally render the application
  7. Ran yarnand yarn start

I can't say I've ran into this issue before. It's an interesting one. I'll try to replicate with a fresh clone when I find the spare time.