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

Aperta
#726 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, rollup, typescript, vite, webpack

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
4
Fork
0
Merge medio
16h 28m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di qoretechnologies/reqore

Tutte le issue di qoretechnologies/reqore

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.