automerge/automerge-repo

Don't bundle React with the hooks package

Closed this issue · 5 comments

I was unable to use the package directly, as you're bundling React with the package itself, and unfortunately, I'm still on React 17. This leads to a situation where the useRepo context provider always returns null. For now, I've copied the hooks into my repo.

In general, as a library author you typically don't want to bundle react with the package. This is typically accomplished via whatever you're using for bundling/building the lib. For Webpack, you can use the externals prop in webpack config. I see you're using Vite, and I believe there are plugins for vite and/or rollup, such as vite-plugin-externals

pvh commented

Hey, good call. Thanks! I'll fix this.

pvh commented

Actually, if you want to send a patch that solves the problem for you, I can test it as well. Otherwise I'll probably end up just guessing at the solution and then asking you to confirm anyway :)

This can be closed, right?

Hey @msakrejda, just got around to testing this. All works as expected, closing!