Skip to content

[Exploration] Split into monorepo with 17 npm workspace packages#235

Closed
brnrdog wants to merge 10 commits intopre-alphafrom
breaking-down-rescript-json
Closed

[Exploration] Split into monorepo with 17 npm workspace packages#235
brnrdog wants to merge 10 commits intopre-alphafrom
breaking-down-rescript-json

Conversation

@brnrdog
Copy link
Copy Markdown
Collaborator

@brnrdog brnrdog commented Apr 17, 2026

The current single-package @rescript/webapi bundles all Web API bindings together, which creates
significant overhead for consumers who only need a subset of the APIs. By splitting into independent
packages, we:

  • Decrease the overhead/overload of the Web API — consumers install and compile only the bindings
    they actually use
  • Decrease compilation time — smaller dependency graphs mean faster builds for projects that
    don't need every API surface

Summary

  • Reorganize the single @rescript/webapi package into a monorepo with npm workspaces and 17
    independent packages
  • All type definitions stay in the base @rescript/webapi package; binding packages depend only on
    the base, eliminating circular dependencies
  • Each package builds independently and consumers can install only what they need

Package structure

@rescript/webapi (base types + Event + tiny modules — 77 files)
├── @rescript/webapi-dom (122 files)
├── @rescript/webapi-fetch (8 files)
├── @rescript/webapi-file (12 files)
├── @rescript/webapi-canvas (7 files)
├── @rescript/webapi-webaudio (31 files)
├── @rescript/webapi-uievents (14 files)
├── @rescript/webapi-web-workers (4 files)
│   └── @rescript/webapi-service-worker (12 files)
├── @rescript/webapi-indexed-db (5 files)
├── @rescript/webapi-media (8 files)
├── @rescript/webapi-websockets (3 files)
├── @rescript/webapi-geolocation (3 files)
├── @rescript/webapi-webstorage (2 files)
├── @rescript/webapi-crypto (2 files)
├── @rescript/webapi-performance (3 files)
└── @rescript/webapi-global (1 file)

Key changes

  • Created packages/ directory with 17 packages, each with package.json and rescript.json
  • Moved 314 .res files from flat src/ into flattened package src/ directories
  • Updated open statements in type definition files (open Eventopen EventTypes, open File
    open FileTypes) to reference type modules directly
  • Fixed cross-package module references in DOM, Fetch, Canvas, UIEvents, WebSockets, and Global
  • Moved IntersectionObserverRoot.res to webapi-dom (depends on DOM bindings)
  • Inlined File.isInstanceOf in FormDataEntryValue.res to avoid circular package dependency
  • Added -open WebAPIWebWorkers to service-worker config for WorkerGlobalScope.Impl
  • Replaced deprecated bsc-flags with compiler-flags across all packages
  • Updated test files for new namespace paths
  • Added build / clean scripts to all packages and build:packages to root

Build scripts

npm run build            # build everything from root
npm run build:packages   # build each package independently
npm run clean            # clean all build artifacts
npm run build -w @rescript/webapi-dom  # build a single package

Test plan

  • npm run clean && npm run build — all 336 modules compile from clean build
  • npm run build:packages — each of the 17 packages builds independently
  • Verify a sample consumer project can depend on individual packages

jderochervlk and others added 8 commits April 17, 2026 07:04
Reorganize the single @rescript/webapi package into a monorepo with
npm workspaces. Type definitions stay in the base package while binding
packages depend only on the base, eliminating circular dependencies.

Packages: webapi (base), webapi-dom, webapi-fetch, webapi-file,
webapi-canvas, webapi-webaudio, webapi-uievents, webapi-service-worker,
webapi-web-workers, webapi-indexed-db, webapi-media, webapi-websockets,
webapi-geolocation, webapi-webstorage, webapi-crypto,
webapi-performance, webapi-global.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each package now has `npm run build` and `npm run clean` scripts.
Root gets `build:packages` to build all packages independently
via `npm run build --workspaces`.
@brnrdog brnrdog changed the base branch from main to brnrdog/descriptive-make-fns April 17, 2026 15:51
@brnrdog brnrdog marked this pull request as draft April 17, 2026 15:59
@brnrdog brnrdog changed the title Split into monorepo with 17 npm workspace packages [Exploration] Split into monorepo with 17 npm workspace packages Apr 17, 2026
@brnrdog brnrdog force-pushed the brnrdog/descriptive-make-fns branch 2 times, most recently from 252361a to edeb2c1 Compare April 18, 2026 12:24
Base automatically changed from brnrdog/descriptive-make-fns to pre-alpha April 18, 2026 12:46
@brnrdog
Copy link
Copy Markdown
Collaborator Author

brnrdog commented Apr 19, 2026

Closing this one in favour of #249

@brnrdog brnrdog closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants