Skip to content

Commit df203d3

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). Decouple clean from build in the Makefile so watch mode can rebuild without wiping dist/. Part of openedx/frontend-base#184 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ed58e02 commit df203d3

5 files changed

Lines changed: 65 additions & 4 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: 20 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,27 @@ 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+
build-packages: turbo.json
27+
$(TURBO) run build; rm -f turbo.json
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+
1635
clean:
1736
rm -rf dist
1837

19-
build: clean
38+
build:
2039
tsc --project tsconfig.build.json
2140
tsc-alias -p tsconfig.build.json
2241
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+
}

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"files": [
1717
"/dist"
1818
],
19+
"workspaces": [
20+
"packages/*"
21+
],
1922
"browserslist": [
2023
"extends @edx/browserslist-config"
2124
],
@@ -25,14 +28,19 @@
2528
],
2629
"scripts": {
2730
"build": "make build",
31+
"build:packages": "make build-packages",
2832
"clean": "make clean",
33+
"clean:packages": "make clean-packages",
2934
"dev": "PORT=1999 PUBLIC_PATH=/authn openedx dev",
35+
"dev:site": "npm run dev",
36+
"dev:packages": "make dev-packages",
3037
"i18n_extract": "openedx formatjs extract",
3138
"lint": "openedx lint .",
3239
"lint:fix": "openedx lint --fix .",
33-
"prepack": "npm run build",
40+
"prepack": "npm run clean && npm run build",
3441
"snapshot": "openedx test --updateSnapshot",
35-
"test": "openedx test --coverage --passWithNoTests"
42+
"test": "openedx test --coverage --passWithNoTests",
43+
"watch:build": "nodemon --exec 'npm run build'"
3644
},
3745
"author": "Open edX",
3846
"license": "AGPL-3.0",
@@ -73,9 +81,11 @@
7381
"babel-plugin-formatjs": "10.5.38",
7482
"eslint-plugin-import": "2.31.0",
7583
"jest": "^29.7.0",
84+
"nodemon": "^3.1.14",
7685
"react-test-renderer": "^18.3.1",
7786
"ts-jest": "^29.4.0",
78-
"tsc-alias": "^1.8.16"
87+
"tsc-alias": "^1.8.16",
88+
"turbo": "^2.8.16"
7989
},
8090
"peerDependencies": {
8191
"@openedx/frontend-base": "^1.0.0-alpha.13",

turbo.site.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://turbo.build/schema.json",
3+
"tasks": {
4+
"build": {
5+
"dependsOn": ["^build"],
6+
"outputs": ["dist/**"],
7+
"cache": false
8+
},
9+
"clean": {
10+
"cache": false
11+
},
12+
"watch:build": {
13+
"dependsOn": ["^build"],
14+
"persistent": true,
15+
"cache": false
16+
},
17+
"//#dev:site": {
18+
"dependsOn": ["^build"],
19+
"persistent": true,
20+
"cache": false
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)