Closed mvila closed 9 years ago
Hi @mvila, thanks for the heads-up. I believe this is due to the browserify field in package.json, which instructs browserify what transforms to use: https://github.com/joshwnj/react-visibility-sensor/blob/master/package.json#L34-L40
In the most recent version I've moved reactify from devDependencies
to dependencies
, meaning that reactify is guaranteed to be available when needed. Could you please upgrade to the latest version of react-visibility-sensor
and let me know if the problem is still occurring?
I have not tested yet but I think it should work. However, this is not great to include reactify
in dependencies
. Since it is only used by examples and tests, it should be in devDependencies
. I think the solution is to leave reactify
in devDependencies
and remove the browserify
field in package.json
. Since you explicitly specify the reactify
transform in build-example
and build-test
scripts, you don't need the browserify
field.
Sure, I'll have a look at what some other react components are doing and see if there's a "best practice" to adopt here.
The advantage of including reactify
in the package.browserify
field (and I believe, the reason they recommend it) is that package authors can ensure their packages are bundled with whatever dependencies are necessary to browserify them, and package consumers don't need to have any special knowledge about what transforms they need to install.
I understand the advantage of the browserify
field in package.json
but it is not appropriate in your case since you use reactify
only for tests and examples.
@mvila sorry for the delay - you make a good point and we'll be removing the package.browserify
field in the next release (arriving very soon).
This is resolved in v3.0.0
Since I replaced reactify by babelify, I get the following error when I try to browserify my project using your module:
Error: Cannot find module 'reactify' from '/Users/mvila/Projects-next/avc-online/node_modules/react-visibility-sensor'
I think you should remove the reactify transform from your package.json and find another way to reactify your tests/examples.