Re:If you write JavaScript tools or libraries, bundle your c...
by exogen on Wednesday March 23, 2016 @08:20PM
(#11349554)
FooBarComponent shouldn't have been packaged that way (it can include such a dist file for some people to use, but the npm package shouldn't export that). The typical way is for it to not include React as a `dependency` at all but a `peerDependency`. Then everything will be importing the same instance.
Re:If you write JavaScript tools or libraries, bundle your c...
by joeframbach on Wednesday March 23, 2016 @08:34PM
(#11349630)
> (it can include such a dist file for some people to use, but the npm package shouldn't export that)
I think that is exactly what the article is suggesting we do.
Re:If you write JavaScript tools or libraries, bundle your c...
by lollipop25 on Friday March 25, 2016 @03:21AM
(#11358864)
The root of the problem is why FooBarComponent is a giant index.js. Also, why does it have React bundled if it expects to be a reusable component? Also, frameworks like React etc. shouldn't be a bundled dependency. They should be an external dependency or a top-level dependency.
- My app requires React.
- My app also requires FooBarComponent whose dist is just a giant index.js which includes its own copy of React.
- Now I get a bunch of errors because FooBarComponent and MyApp can't share anything between themselves. React really doesn't like it when two copies are running.