Skip to content

Commit 7e06a98

Browse files
arbrandesclaude
andcommitted
feat: support npm workspaces for local development
Add workspaces configuration and workspace-aware scripts for developing with local packages (such as frontend-base). Also, since npm skips bin-linking for workspace packages during install, do it when frontend-base is built. Part of openedx/frontend-base#184 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 575892f commit 7e06a98

6 files changed

Lines changed: 2039 additions & 599 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ npm-debug.log
33
coverage
44
module.config.js
55
dist/
6+
packages/
7+
/.turbo
8+
/turbo.json
69
/*.tgz
710

811
### i18n ###

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
TURBO = TURBO_TELEMETRY_DISABLED=1 turbo --dangerously-disable-package-manager-check
2+
13
intl_imports = ./node_modules/.bin/intl-imports.js
24
transifex_utils = ./node_modules/.bin/transifex-utils.js
35
i18n = ./src/i18n
@@ -13,10 +15,35 @@ precommit:
1315
requirements:
1416
npm ci
1517

18+
# turbo.site.json is the standalone turbo config for this package. It is
19+
# renamed to avoid conflicts with turbo v2's workspace validation, which
20+
# rejects root task syntax (//#) and requires "extends" in package-level
21+
# turbo.json files, such as when running in a site repository. The targets
22+
# below copy it into place before running turbo and clean up after.
23+
turbo.json: turbo.site.json
24+
cp $< $@
25+
26+
# NPM doesn't bin-link workspace packages during install, so it must be done manually.
27+
bin-link:
28+
[ -f packages/frontend-base/package.json ] && npm rebuild --ignore-scripts @openedx/frontend-base || true
29+
30+
build-packages: turbo.json
31+
$(TURBO) run build; rm -f turbo.json
32+
$(MAKE) bin-link
33+
34+
clean-packages: turbo.json
35+
$(TURBO) run clean; rm -f turbo.json
36+
37+
dev-packages: turbo.json
38+
$(TURBO) run watch:build dev:site; rm -f turbo.json
39+
40+
dev-site: bin-link
41+
npm run dev
42+
1643
clean:
1744
rm -rf dist
1845

19-
build: clean
46+
build:
2047
tsc --project tsconfig.build.json
2148
tsc-alias -p tsconfig.build.json
2249
find src -type f -name '*.scss' -exec sh -c '\

nodemon.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": [
3+
"src"
4+
],
5+
"ext": "js,jsx,ts,tsx,scss"
6+
}

0 commit comments

Comments
 (0)