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

Remove react-native related dependencies #776

Open
nlnw opened this issue Mar 18, 2024 · 2 comments
Open

Remove react-native related dependencies #776

nlnw opened this issue Mar 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@nlnw
Copy link

nlnw commented Mar 18, 2024

Feature Request

The react-native dependencies adds 200MB to npm installs (react-native-webview, react-native, @react-native-async-storage/async-storage). It's more than 10x bigger than any other dependency. This makes anything that uses this package to need 500mb+ in wasted storage. Can you please find a way to include this type of dependency without pulling in react-native packages?

Why it is needed

Reduce slow npm install times and hugely wasted disk space since most projects won't be using react-native.

@nlnw nlnw added the enhancement New feature or request label Mar 18, 2024
@Askadias
Copy link

Askadias commented Aug 31, 2024

Can we rise up this one?
react-native-webview definitely should be in peer dependencies.

We are using web3modal and currently have to patch our pnpm installation like that
.pnpmfile.cjs:

module.exports = {
  hooks: {
    readPackage(pkg) {
      if (pkg.name === 'react-native-webview') {
        pkg.dependencies = {};
        pkg.peerDependencies = {};
        pkg.optionalDependencies = {};
      }
      return pkg;
    },
  },
};

@jd1378
Copy link

jd1378 commented Sep 5, 2024

We are also using web3modal and we had to patch web3modal core (2810) and use a .pnpmfile.cjs similar to Askadias':

function isReactDependency(pkgName) {
  return (
    pkgName.startsWith('react') ||
    pkgName.startsWith('@react') ||
    pkgName === 'use-sync-external-store'
  );
}

function depsWithoutReact(deps) {
  if (!deps) return deps;
  return Object.keys(deps)
    .filter(k => isReactDependency(k) && k !== 'react-native-webview')
    .reduce((accu, pkgName) => {
      delete accu[pkgName];
      return accu;
    }, deps);
}

module.exports = {
  hooks: {
    readPackage(pkg) {
      if (pkg.name === 'react-native-webview') {
        pkg.dependencies = {};
        pkg.peerDependencies = {};
        pkg.optionalDependencies = {};
        pkg.transitivePeerDependencies = {};
      } else {
        pkg.dependencies = depsWithoutReact(pkg.dependencies);
        pkg.peerDependencies = depsWithoutReact(pkg.peerDependencies);
        pkg.optionalDependencies = depsWithoutReact(pkg.optionalDependencies);
        pkg.transitivePeerDependencies = depsWithoutReact(
          pkg.transitivePeerDependencies,
        );
      }
      return pkg;
    },
  },
};

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

No branches or pull requests

3 participants