Support for React Native
Opened this issue · 4 comments
React Native doesn't run in Node.js environment (see StackOverflow), therefore requiring the 'fs' module causes an error. Furthermore, it seems React Native doesn't support programmatic require (called in a loop over an array of providers). I was able to fix this by replacing the for loop with individual statements without using the safe_require function which uses 'fs', unfortunately with a fixed en_US locale, e.g.:
casual.register_provider(helpers.extend(
require('./providers/address'),
require('./providers/en_US/address')
));
casual.register_provider(helpers.extend(
require('./providers/text'),
{}
));
Did you try with casual-browserify? https://github.com/Klowner/casual-browserify or read the discussion in #59
It seems that one has exactly the same problem: https://github.com/Klowner/casual-browserify/blob/browserify/src/casual.js
@milhauscz I sent a PR to the library to remove dynamic imports and __dirname
If you want to use it, try the following
yarn add https://github.com/cihadturhan/casual-browserify