react-native doesn't handle the /index.js in browser fields #1813

merged 1 commit into from Dec 5, 2016


None yet

2 participants

dantman commented Nov 30, 2016

No description provided.

elhigu commented Dec 3, 2016

@dantman could you explain me a bit more what is this and why it is needed?

dantman commented Dec 3, 2016

@elhigu React Native has its own packager based on browserify responsible for bundling the JS code for native iOS/Android apps. It handles the "browser" field in package.json as well as a "react-native" field with React Native specific overrides to "browser".

React Native isn't a browser or server environment, but it's similar to a browser environment. No node.js runtime, fs, etc... like the browser except no dom and other browser features but some react-native-* packages providing access to native iOS/Android features like native hardware, App storage, Android/iOS sqlite databases, etc...

So when you require knex in a react-native project (say, so you can either use the query builder/toSQL or write your own knex driver for an Android/iOS Sqlite database) it fails in the same way that it fails in the browser. But the browser handling doesn't behave 100% the same as browserify. React Native matches ../migrate in lib/util/make-knex.js against "./lib/migrate" instead of "./lib/migrate/index.js" like the handler browserify uses.

elhigu commented Dec 5, 2016

Sounds good, thanks 👍

@elhigu elhigu merged commit 9e7b57e into tgriesser:master Dec 5, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment