@@ -52,6 +52,77 @@ created when copying this template above.
5252The dev server is running at `http://apps.local.openedx.io:8080 <http://apps.local.openedx.io:8080 >`_
5353or whatever port you setup.
5454
55+ Local Development with Workspaces
56+ ==================================
57+
58+ This repository supports `npm workspaces `_ to enable local development of
59+ frontend apps (e.g., ``frontend-app-authn ``, ``frontend-app-learner-dashboard ``)
60+ and ``frontend-base `` itself, all running together in the context of a site.
61+
62+ The ``packages/ `` directory (gitignored) holds local checkouts of packages being
63+ developed. These act as development-only overrides of the npm-published
64+ versions.
65+
66+ Since symlinks cause module resolution failures (Node.js resolves to the real
67+ path, breaking hoisted dependency resolution), local checkouts should either be
68+ made directly under ``packages/ `` or made available via bind mounts (or volume
69+ mounts, if running under Docker). For example, if the checkouts are siblings
70+ of this repository::
71+
72+ mkdir -p packages/{frontend-base,frontend-app-authn,frontend-app-learner-dashboard}
73+ cd packages
74+ for i in *; do sudo mount --bind ../../${i} ${i}; done
75+ cd ..
76+ npm install
77+
78+ `bindfs `_ can be used instead of ``sudo mount --bind `` to avoid requiring root
79+ privileges.
80+
81+ .. _bindfs : https://bindfs.org/
82+ .. _npm workspaces : https://docs.npmjs.com/cli/using-npm/workspaces
83+
84+ Version Placeholders
85+ --------------------
86+
87+ The ``@openedx/ `` packages use `semantic-release `_ and carry a placeholder
88+ version of ``0.0.0-dev `` in their ``package.json `` until they are published.
89+ Because npm resolves peer dependencies strictly, a workspace checkout at
90+ ``0.0.0-dev `` will not satisfy a requirement like ``^1.0.0 ``. To work
91+ around this, each ``@openedx/ `` dependency in the site's ``package.json ``
92+ includes ``|| 0.0.0-dev `` — for example,
93+ ``"@openedx/frontend-base": "^1.0.0 || 0.0.0-dev" ``. If you add a new
94+ ``@openedx/ `` package that will be checked out as a workspace, make sure to
95+ include the same ``|| 0.0.0-dev `` suffix.
96+
97+ .. _semantic-release : https://github.com/semantic-release/semantic-release
98+
99+ Why Turborepo
100+ -------------
101+
102+ Workspace packages must be built in dependency order — for example,
103+ ``frontend-base `` before apps that depend on it — but npm is not smart enough
104+ to do this on its own. `Turborepo `_ handles this automatically via
105+ ``dependsOn: ["^build"] `` in ``turbo.json ``, building the dependency graph and
106+ running tasks in the correct topological order.
107+
108+ It also enables watch mode without race conditions: the ``clean `` target is
109+ decoupled from ``build `` so that watch rebuilds overwrite in place without
110+ wiping ``dist/ ``.
111+
112+ Note that Turborepo collects anonymous telemetry by default. To disable it, set
113+ ``TURBO_TELEMETRY_DISABLED=1 `` in your environment.
114+
115+ .. _Turborepo : https://turbo.build/
116+
117+ Workspace Scripts
118+ -----------------
119+
120+ - ``npm run build:packages `` — Build all workspace packages in dependency order.
121+ - ``npm run clean:packages `` — Run the ``clean `` script in each workspace package.
122+ - ``npm run dev:packages `` — Watch-build all workspace packages and start the
123+ dev server, so that changes to any local dependency are picked up
124+ automatically.
125+
55126Internationalization
56127====================
57128
0 commit comments