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

Work around webpack trying to bundle react-native #206

Closed
wants to merge 1 commit into from

Conversation

b123400
Copy link
Contributor

@b123400 b123400 commented Apr 25, 2017

connect #160

This PR is not exactly doing what the issue is saying, but should solve the problem.

@oursky-travis
Copy link

@b123400, thanks for your PR! By analyzing the history of the files in this pull request, we identified @limouren to be a potential reviewer.

@louischan-oursky
Copy link
Contributor

I tried this patch but it seems that it does not work with react native packager.

Here are the steps

  1. Build this patch and commit the build
  2. Initialize a react native project and configure skygear to point to the above commit
  3. Run the react native app

It should fail with the following log

2017-04-26 19:09:26.808690 MyApp[16449:6446190] 'Failed to get user', { [ReferenceError: Can't find variable: document]
  line: 98986,
  column: 32,
  sourceURL: 'http://192.168.1.127:8081/index.ios.bundle?platform=ios&dev=false&minify=false' }

I went through the line and column in the log and discovered that the storage is incorrectly recognized as CookieStorage (used in lib/store.js) which makes use of document which does not exist in react native.

@b123400
Copy link
Contributor Author

b123400 commented Apr 26, 2017

TLDR: I give up working around webpack.


  • webpack translates all modules' name into number, then require them by the numbers in run time. Something like this:

    require('a') // becomes require(1);
    require = id => {1:module_a()}[id]()
    
  • React native is using webpack with aliasing plugin, it changes the name of a bundle according to @providesModule

    • react-native is aliased to react-native-implementation
  • require('react-native') doesn't work because it is aliased

  • By working around webpack, the "string to number" translation is missing, and it is still requiring react-native after built, so it does not work.

  • Tried to require('react-native-implementation'), it works. But then got a message saying loading module with string does not work in production environment.

  • I give up working around webpack

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

Successfully merging this pull request may close these issues.

5 participants