Skip to content

Commit 27f860a

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 510de50 commit 27f860a

6 files changed

Lines changed: 1846 additions & 3591 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
i18n = ./src/i18n
35

@@ -8,10 +10,35 @@ precommit:
810
requirements:
911
npm ci
1012

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

14-
build: clean
41+
build:
1542
tsc --project tsconfig.build.json
1643
tsc-alias -p tsconfig.build.json
1744
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)