@@ -52,6 +52,62 @@ 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+ Why Turborepo
85+ -------------
86+
87+ Workspace packages must be built in dependency order — for example,
88+ ``frontend-base `` before apps that depend on it — but npm is not smart enough
89+ to do this on its own. `Turborepo `_ handles this automatically via
90+ ``dependsOn: ["^build"] `` in ``turbo.json ``, building the dependency graph and
91+ running tasks in the correct topological order.
92+
93+ It also enables watch mode without race conditions: the ``clean `` target is
94+ decoupled from ``build `` so that watch rebuilds overwrite in place without
95+ wiping ``dist/ ``.
96+
97+ Note that Turborepo collects anonymous telemetry by default. To disable it, set
98+ ``TURBO_TELEMETRY_DISABLED=1 `` in your environment.
99+
100+ .. _Turborepo : https://turbo.build/
101+
102+ Workspace Scripts
103+ -----------------
104+
105+ - ``npm run build:packages `` — Build all workspace packages in dependency order.
106+ - ``npm run clean:packages `` — Run the ``clean `` script in each workspace package.
107+ - ``npm run dev:packages `` — Watch-build all workspace packages and start the
108+ dev server, so that changes to any local dependency are picked up
109+ automatically.
110+
55111Internationalization
56112====================
57113
0 commit comments