refactor: undo monorepo#260
Conversation
|
oh no! why? |
We won't need to ship separate npm packages because of this: rescript-lang/rescript#8379 |
There was a problem hiding this comment.
Undoing the monorepo would allow to have have a structure quite similar to what it was before, just with extracted "base" types. Now we should really think about how we want to call these base types (Base.DOM, BaseDOM, other?). I'm wondering if we couldn't come up with an even smarter structure with the features.
Edit: I'm quite excited to see we're close to finally reach the alpha haha
I think using |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fde4ee8d4a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # README.md # docs/content/docs/index.mdx
Summary
This PR restructures the repo back into a single root package,
@rescript/webapi, while keeping feature-gated source directories in the rootrescript.json.packages/*.src/<Feature>directories controlled by root-level feature entries such asWebAPI.DOM,WebAPI.Fetch,WebAPI.Canvas, andWebAPI.WebWorkers.*Typesand DOM/global helper files internal through explicit per-featurepubliclists inrescript.json.WebAPI.Headers,WebAPI.Request,WebAPI.Element,WebAPI.Path2D, andWebAPI.ReadableStreamdirectly.Global/GlobalScopepublic names to owner modules such asWebAPI.Fetch,WebAPI.Canvas,WebAPI.Worker,WebAPI.SharedWorkerScope, andWebAPI.ServiceWorkerScope.WebAPI.VisualViewportmodule and updatesWindow.visualViewportto returnWebAPI.VisualViewport.t.Current public API shape
Install the package and add it to
rescript.json:{ "dependencies": [ "@rescript/webapi" ] }Use public owner modules directly under
WebAPI:Fetch and request bodies:
Headers can be constructed from common JavaScript shapes and still expose typed methods:
Requests and responses keep their typed constructors and body readers:
DOM usage goes through public interface modules rather than generated type modules:
Worker global-scope APIs use simplified scope modules:
Visual viewport has a public wrapper type:
Canvas constructors and helpers use owner modules:
URL helpers expose constructors and static functions on the same public module:
Generic Web API types stay typed through their public owner modules:
Public surface checks
The root
rescript.jsonnow sets apubliclist for everysrc/<Feature>entry. Those lists are generated from the feature source files and filter out every module whose name ends inTypes, so modules such asDomTypes,FetchTypes,EventTypes, andUiEventsTypesare internal implementation modules.The public lists also avoid
GlobalandGlobalScopemodule names. DOM globals are reached through public owner modules such asWebAPI.Window, while feature-specific global helpers are exposed as simplified owner modules likeWebAPI.FetchandWebAPI.Worker.The generated API/LLM docs use the same
rescript.jsonpublic lists so internal helper files do not get published as API pages.Verification
node --test tests/unmonorepo/*.test.mjsnpm run buildnpm testASTRO_TELEMETRY_DISABLED=1 npm run build:docsnpm run format:checkgit diff --check