Closed ofzza closed 5 years ago
This PR seems fine to me. Out of curiosity - why are you importing croppie in a nodejs environment?
@thedustinsmith I bundle it as part of client-side React code in my application, and then use this same bundle for both server-side rendering and client-side rendering of the app. For the server-side rendering part, the bundle needs to be included from inside a NodeJS server-side part, which causes the bundled Croppie library to initialize and throw errors.
I could, of course, make 2 bundles - one for client-side and another for server-side with stubbed libraries that cause issues - but this would prolong my build times and so far it wasn't needed; and in this case the fix seems to be easy and should have no adverse impact on Croppie.
Agreed. Just curious. Thanks!
I'll merge this in, but I can't promise any sort of release any time soon.
@thedustinsmith , Is the fix deployed?
Still getting window is not defined
Adds environment checks before using environment specific features during initialization. This allows the library to be required/imported even outside of a browser environment without crashing the environment.
Handles issue #656.