You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/philosophy.mdx
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,10 @@ The bindings are generated from the [MDN Web API documentation](https://develope
16
16
17
17
In other words, if you are searching for a specific JavaScript binding, begin your journey at the [MDN Web API documentation](https://developer.mozilla.org/en-US/docs/Web/API) and determine which module contains your sample. Ensure that the module is available in the bindings by checking the specific API. Please [open an issue](https://github.com/rescript-lang/experimental-rescript-webapi/issues/new/choose) if you require an API that is not yet present.
18
18
19
-
The bindings are exposed under the `WebAPI` namespace, with feature entry modules such as `WebAPI.DOM` available when you want to scope imports more narrowly.
19
+
The bindings are exposed under the `WebAPI` namespace with the same flat module structure as the original package.
20
20
21
21
```ReScript
22
-
open WebAPI.Global
23
-
// or WebAPI.DOM
22
+
open WebAPI.DomGlobal
24
23
25
24
let myElement: WebAPI.Element.t = document->WebAPI.Document.createElement("div")
26
25
```
@@ -44,8 +43,7 @@ JavaScript supports function overloads, where a function can have multiple signa
44
43
In some cases, type conversion will be required. Subtypes can safely be cast to their base type using conversion helpers within their module.
45
44
46
45
```ReScript
47
-
open WebAPI.Global
48
-
// or WebAPI.DOM
46
+
open WebAPI.DomGlobal
49
47
50
48
let element: WebAPI.Element.t = document->WebAPI.Document.createElement("div")
51
49
let node: WebAPI.Node.t = element->WebAPI.Element.asNode
Copy file name to clipboardExpand all lines: docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md
+17-21Lines changed: 17 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,16 @@
7
7
8
8
The repository was split into npm workspaces so each Web API area could build and publish independently from `packages/*`. The ReScript compiler now supports feature-gated source directories and feature-gated dependencies, so the package split is no longer required to support partial builds.
9
9
10
-
The new target is a single published npm package, `@rescript/webapi`, with a unified internal build and an external API that still preserves feature-level boundaries such as `WebAPI.DOM`, `WebAPI.Fetch`, and `WebAPI.Base`.
10
+
The new target is a single published npm package, `@rescript/webapi`, with a unified internal build and feature-gated source groups such as `WebAPI.DOM`, `WebAPI.Fetch`, and `WebAPI.Base`.
11
11
12
12
## Goals
13
13
14
14
- Remove the monorepo/workspace package split.
15
15
- Move all feature sources from `packages/<Pkg>/src` to `src/<Pkg>`.
16
16
- Delete every subpackage `package.json` and `rescript.json`.
17
17
- Make the root `rescript.json` the single source of truth for sources, features, and ReScript dependencies.
18
-
- Preserve the logical public API boundaries as `WebAPI.<Feature>`.
19
-
- Keep internal helper modules private through the new `public` source setting.
18
+
- Preserve the original flat public API module shape.
19
+
- Keep feature boundaries in the build configuration rather than generated wrapper modules.
20
20
- Publish one npm package: `@rescript/webapi`.
21
21
- Let internal builds and downstream consumers compile only the features they need.
22
22
@@ -62,14 +62,12 @@ Each former package source directory is listed as its own source entry. Example
62
62
{
63
63
"dir": "src/DOM",
64
64
"subdirs": true,
65
-
"feature": "WebAPI.DOM",
66
-
"public": ["DOM"]
65
+
"feature": "WebAPI.DOM"
67
66
},
68
67
{
69
68
"dir": "src/Fetch",
70
69
"subdirs": true,
71
-
"feature": "WebAPI.Fetch",
72
-
"public": ["Fetch"]
70
+
"feature": "WebAPI.Fetch"
73
71
},
74
72
{
75
73
"dir": "tests",
@@ -84,8 +82,7 @@ Rules:
84
82
85
83
- Every former package gets one root source entry.
86
84
- The `feature` value matches the public module name, for example `"WebAPI.DOM"` and `"WebAPI.Fetch"`.
87
-
- The `public` list exposes only the feature entry module for that source directory.
88
-
- Helper modules such as `DomTypes` and `DomGlobal` stay internal because they are not listed in `public`.
85
+
- Source directories expose their modules directly, matching the original plain package structure.
89
86
-`tests` remains a dev-only source.
90
87
91
88
### Dependencies
@@ -112,23 +109,22 @@ Migration rule:
112
109
113
110
## Public API Shape
114
111
115
-
The public API remains feature-oriented:
112
+
The build remains feature-oriented:
116
113
117
114
-`WebAPI.Base`
118
115
-`WebAPI.DOM`
119
116
-`WebAPI.Fetch`
120
117
-`WebAPI.WebCrypto`
121
118
- and the rest of the former package surfaces
122
119
123
-
The unified build must not expose raw internal file modules as first-class public API. Consumers should interact with a curated surface through the feature entry modules only.
120
+
The unified build keeps the original flat module surface instead of adding generated feature entry modules. For example, consumers should use modules such as:
124
121
125
-
Each feature directory therefore needs one public entry module whose filename matches the feature name:
122
+
-`WebAPI.Document`
123
+
-`WebAPI.Element`
124
+
-`WebAPI.Headers`
125
+
-`WebAPI.URL`
126
126
127
-
-`src/DOM/DOM.res`
128
-
-`src/Fetch/Fetch.res`
129
-
-`src/Base/Base.res`
130
-
131
-
Those entry modules are the only modules exported from their source directory through `public`.
127
+
Shared DOM base types should be owned by `DOM`, so common references stay short, for example `DOM.element` instead of `BaseDOM.element` or `Base.DOM.element`.
132
128
133
129
## Internal Module Naming
134
130
@@ -144,6 +140,7 @@ In a unified package these names would collide, so the migration must rename gen
- Prefix internal modules with the feature’s public module stem.
156
-
- Keep the public entry module itself unprefixed when it is the exported surface module, for example `DOM.res`and `Fetch.res`.
153
+
- Keep legacy same-name public modules unprefixed when the feature owns that name, for example `src/URL/URL.res`, `src/Event/Event.res`, and `src/File/File.res`.
157
154
158
155
This keeps the public API stable while making the unified internal module graph collision-free.
159
156
@@ -196,8 +193,7 @@ The build becomes unified at the repository level:
196
193
1. ReScript reads the root `rescript.json`.
197
194
2. Each feature source directory is included in the build graph.
198
195
3. Feature gating determines which source directories and gated dependencies participate in a given build.
199
-
4. Only the explicitly public feature entry modules are exposed to consumers.
0 commit comments