nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
21.33k stars 1.37k forks source link

[BUG] - react-rsc-utils bundles a copy of React #3531

Open hikiko4ern opened 1 month ago

hikiko4ern commented 1 month ago

NextUI Version

@nextui-org/react-rsc-utils@2.0.13

Describe the bug

react-rsc-utils currently bundles a copy of React, increasing the size of the bundle and making NextUI incompatible with Preact

For example, in version 2.0.13, a copy of React is included as dist/chunk-2GZPFWUB.mjs (the link to unpkg is for example, the same package is downloaded from npm):

import {
  __commonJS
} from "./chunk-UYSIEMEK.mjs";

// ../../../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.production.min.js
var require_react_production_min = __commonJS({
  "../../../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.production.min.js"(exports) {
    "use strict";
    var l = Symbol.for("react.element");
    var n = Symbol.for("react.portal");
    /* ... the rest of the production build ... */
  }
});

// ../../../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.development.js
var require_react_development = __commonJS({
  "../../../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.development.js"(exports, module) {
    "use strict";
    if (process.env.NODE_ENV !== "production") {
    /* ... the rest of the development build ... */
    }
  }
});

// ../../../node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
var require_react = __commonJS({
  "../../../node_modules/.pnpm/react@18.2.0/node_modules/react/index.js"(exports, module) {
    "use strict";
    if (process.env.NODE_ENV === "production") {
      module.exports = require_react_production_min();
    } else {
      module.exports = require_react_development();
    }
  }
});

export {
  require_react
};

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

N/A

Expected behavior

React should be imported as a peer dependency like in other packages, not included as a copy

It seems react should be specified in peerDependencies, like in react-utils? https://github.com/nextui-org/nextui/blob/be507e0c418299600c609d9101fc4a2ac1c35d38/packages/utilities/react-utils/package.json#L36-L38

Screenshots or Videos

No response

Operating System Version

Linux

Browser

Chrome

linear[bot] commented 1 month ago

ENG-1190 [BUG] - react-rsc-utils bundles a copy of React