-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Enhanced React Native for Web support #814
Comments
cc @ericvicenti who experimented with this |
Excited to hear @ericvicenti's opinion on this matter :). |
Also cc @lacker |
Ah thanks for ccing me on this issue. Making it reasonable to build a joint React Native + React-web app is definitely something we want to have a recommended way for. I think the root question where we came down differently than this proposal here is whether it's reasonable to expect the same |
There is also a difference between classic code sharing approach and actual attempt to reuse RN primitives on the web (what RNW does). |
Currently most Shouldn't Let me know if this should be a separated issue. |
@brunolemos yeah I typically include entire node_modules to be loaded by babel. Despite how terrible that sounds, it seems to work so far. Checkout the discussion in #1125. |
hey folks, is there any progress planned for this feature? or maybe you could point me to some good examples of combining the Native and Web in a single project, ideally using "react-native-scripts" + "react-scripts" without a need to eject? |
If you find or build one let us know! |
I'm going to close since this is not something we're looking at. |
Regarding my comment above, what I did was to use a custom react-scripts that allowed me to add some webpack config, so there was no need to eject. I used my own https://github.com/brunolemos/extensible-react-scripts |
FYI, we're starting the work to compile deps with Let us know if you have feedback about how this should work. |
Support for React Native for Web apps was added in #316 and it enables building cross platform React Native apps for the web with Create React App.
However, creating this kind of apps with
create-react-app
is not as straightforward yet as creating web apps: #316 (comment). To create a cross platform app, at the moment you need to initialize a React Native app (react-native init
), initialize a React app (create-react-app
) in a separate folder, and then merge the folders andpackage.json
files manually.Being able to bootstrap a cross platform app directly with
create-react-app
would make this a lot easier.To create a cross platform app one would simply run
create-react-app --react-native
. This would do following things:react-scripts
from npm.react-scripts init --react-native
which would:react
,react-dom
,react-native
andreact-native-web
as dependencies.react-native/local-cli/cli.js
like react-native-cli does (this is equivalent to ourreact-scripts init
, and this way it's always up-to-date with RN.)react-native
packager start script, in addition to our usual scripts, topackage.json
.An app created by
react-native init
currently looks like this:An app created with
create-react-app --react-native
would look like this:Additionally we should also add support for
.web.js
file extension to our webpack module resolution so that iffilename.web.js
exists, it will be used instead offilename.js
, allowing for web specific code to be written the same way you can with.android.js
and.ios.js
extensions in React Native.Note: for consistency with React Native, it might be nice to move the
index.js
file to the top level. This would also be more agnostic to different folder structures, such aspackages/
folder (#741). However, I think that change should be considered independently of React Native support discussed in this issue.I would be interested in working on this, if we want to support it in Create React App.
The text was updated successfully, but these errors were encountered: