Ship an ES module build with sideEffects so apps can tree-shake Reqore

Open
#726 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
react, rollup, typescript, vite, webpack

Research direction

Start by reading package.json and the existing build configuration to find how the CommonJS output is produced and whether global styles have side effects. Then trace the build scripts and verify how package entry points are consumed. Done means publishing an ESM entry alongside CommonJS with an exports map and a correct sideEffects declaration; check that require consumers still resolve the CommonJS build.

Written by the indexing model from the issue text.

Description

What the landing page needs

The Qorus landing page (qorus.cloud) is slow to show its first screen on phones, and most of the time goes to Reqore's JavaScript. In a production build, Reqore and what it brings come to 4.7 MB raw / 1.22 MB gzipped (Vite 7, Reqore 0.78.0). In a throttled phone trace (Fast 4G, 4× CPU), LCP is about 7 s, almost all of it spent waiting on and running scripts.

The site uses a small part of Reqore, but every component ships, along with everything they import. Measured by source in the bundle:

  • react-aria, react-aria-components, react-stately and @internationalized/date: about 28%;
  • Slate: about 3%;
  • lodash: about 5%.

The reason is the package:

  • package.json has only main (CommonJS output, require(...)), no module or exports ESM entry;
  • it has no sideEffects.

A bundler cannot drop unused components from a CommonJS barrel, so import { ReqoreButton } from '@qoretechnologies/reqore' brings in the whole library.

Proposal

  1. Publish an ES module build next to the CommonJS one: for example dist/esm built with module: esnext, with "module" and an "exports" map pointing import at it and require at dist/index.js.
  2. Declare "sideEffects": false, or list the files that do have side effects (global styles, if any).

Nothing changes for consumers that use require. The ESM path lets Vite, Rollup and webpack keep only the components an app imports.

Meanwhile

The landing page puts Reqore in a file of its own (manualChunks), so returning visitors keep it cached across the site's deploys. It also loads its editor lazily. Neither reduces what a first visit downloads.

Dominant language
TypeScript
Stars
4
Forks
0
Avg merge
16h 28m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from qoretechnologies/reqore

All issues in qoretechnologies/reqore

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.