I maintain a Meteor package for which I’d like to add support for React alongside the Blaze templates that are already included.
To do this I need to create a dependency on the React package so that the .jsx file is compiled. However, I really don’t want to force the user to include the React package if they’re not actually using React in their project,
I don’t want to create another version of the package done most of it’s the same, although I support it’s a possibility.
This is an issue that many packages are going to start having if they wish to provide React/Angular support. Can anyone suggest how this can best be handled?
Establish a weak dependency on a package. If package A has a weak dependency on package B, it means that including A in an app does not force B to be included too
You can add react package as weak dependency, that mean you don’t force your users to install react package. Just be sure your package works correctly in case if react doesn’t installed.
The react meta-package comes with everything you need to build your Meteor app with React. You can also add any of the parts individually:
react-runtime: The React library itself
jsx: A compiler that automatically transforms .jsx files into JavaScript, and lets you use some ES6 features
react-meteor-data: A React mixin called ReactMeteorData that lets you easily use data from Meteor collections and other reactive sources in your components