Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for React Native #61

Open
milhauscz opened this issue Mar 20, 2017 · 4 comments
Open

Support for React Native #61

milhauscz opened this issue Mar 20, 2017 · 4 comments

Comments

@milhauscz
Copy link

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'),
	{}
));
@fc
Copy link

fc commented Mar 20, 2017

Did you try with casual-browserify? https://github.com/Klowner/casual-browserify or read the discussion in #59

@milhauscz
Copy link
Author

It seems that one has exactly the same problem: https://github.com/Klowner/casual-browserify/blob/browserify/src/casual.js

@milhauscz
Copy link
Author

screen shot 2017-03-21 at 08 54 44

@cihadturhan
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants