Skip to content

Commit ed56d09

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 18f3619 commit ed56d09

6 files changed

Lines changed: 1987 additions & 571 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
@@ -10,6 +10,8 @@ transifex_input = $(i18n)/transifex_input.json
1010
# This directory must match .babelrc .
1111
transifex_temp = ./temp/babel-plugin-formatjs
1212

13+
TURBO = TURBO_TELEMETRY_DISABLED=1 turbo --dangerously-disable-package-manager-check
14+
1315
NPM_TESTS=build i18n_extract lint test
1416

1517
# Variables for additional translation sources and imports (define in edx-internal if needed)
@@ -29,10 +31,35 @@ test.npm.%: validate-no-uncommitted-package-lock-changes
2931
requirements: ## install ci requirements
3032
npm ci
3133

34+
# turbo.site.json is the standalone turbo config for this package. It is
35+
# renamed to avoid conflicts with turbo v2's workspace validation, which
36+
# rejects root task syntax (//#) and requires "extends" in package-level
37+
# turbo.json files, such as when running in a site repository. The targets
38+
# below copy it into place before running turbo and clean up after.
39+
turbo.json: turbo.site.json
40+
cp $< $@
41+
42+
# NPM doesn't bin-link workspace packages during install, so it must be done manually.
43+
bin-link:
44+
[ -f packages/frontend-base/package.json ] && npm rebuild --ignore-scripts @openedx/frontend-base || true
45+
46+
build-packages: turbo.json
47+
$(TURBO) run build; rm -f turbo.json
48+
$(MAKE) bin-link
49+
50+
clean-packages: turbo.json
51+
$(TURBO) run clean; rm -f turbo.json
52+
53+
dev-packages: turbo.json
54+
$(TURBO) run watch:build dev:site; rm -f turbo.json
55+
56+
dev-site: bin-link
57+
npm run dev
58+
3259
clean:
3360
rm -rf dist
3461

35-
build: clean
62+
build:
3663
tsc --project tsconfig.build.json
3764
find src -type f \( -name '*.scss' -o \( \( -name '*.png' -o -name '*.svg' \) -path '*/assets/*' \) \) -exec sh -c '\
3865
for f in "$$@"; do \

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,png,svg"
6+
}

0 commit comments

Comments
 (0)