vincentriemer / react-native-dom

An experimental, comprehensive port of React Native to the web.
https://rntester.now.sh
MIT License
3.25k stars 73 forks source link

What is domDependencyConfig.json #90

Open mrtry opened 5 years ago

mrtry commented 5 years ago

I want to use react-native-vector-icon. Tried install, Got the following error.

What is domDependencyConfig.json ...?

$ yarn add react-native-vector
$ react-native link react-native-vector-icons
rnpm-install ERR! ERRPACKAGEJSON No package found. Are you sure this is a React Native project?

Could not find domDependencyConfig.json in your project, please add it.

Error: Could not find domDependencyConfig.json in your project, please add it.
    at findDependencyConfigPath (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native-dom/local-cli/core/dom/findDepConfigPath.js:22:11)
    at Object.projectConfigDom [as projectConfig] (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native-dom/local-cli/core/dom/index.js:9:33)
    at Object.keys.forEach.key (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native/local-cli/core/index.js:100:36)
    at Array.forEach (<anonymous>)
    at Object.getProjectConfig (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native/local-cli/core/index.js:99:28)
    at Object.link [as func] (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native/local-cli/link/link.js:121:22)
    at Promise.resolve.then (/Users/symmt/Program/Study/ReactNative/ReactNativeDomIntoReactNativePaper/node_modules/react-native/local-cli/cliEntry.js:117:22)
    at <anonymous>
anhdle14 commented 5 years ago

Experienced this too, are there any hacks or solutions yet?

iamralpht commented 5 years ago

I did touch domDependencyConfig.json and the error went away. YMMV.

anhdle14 commented 5 years ago

That really not fix the issue, because react-native-dom still depends on native-module to be ported to the web. For the future, we need to somehow do:

  1. react-native link to generate dependencies for the web.
  2. react-native-web to somehow take react-native link to use the web-version instead of native module.
iamralpht commented 5 years ago

Isn't the list of "native modules" in dom/bootstrap.js equivalent to what react-native link does for the iOS and Android build systems?

anhdle14 commented 5 years ago

Haven't got the chance to look into the issue but in short: yes

import { RNDomInstance } from "react-native-dom";
import { name as appName } from "../app.json";

// Path to RN Bundle Entrypoint ================================================
const rnBundlePath = "./entry.bundle?platform=dom&dev=true";

// React Native DOM Runtime Options =============================================
const ReactNativeDomOptions = {
  enableHotReload: false,
  nativeModules: []
};

// App Initialization ============================================================
const app = new RNDomInstance(
  rnBundlePath,
  appName,
  document.body,
  ReactNativeDomOptions
);

app.start();

Haven't try to do index.dom.js to see if we can use react-native-web to do the render with non native modules, and let react-native handle gesture, yoga (flex). That would be a most optimal way for now. I could be wrong, but it is good to try it nonetheless.