Skip to content

Commit ac3c882

Browse files
authored
Enable lerna caching for build scripts (jupyter#6767)
* Enable lerna caching for build scripts * Fix script definitions * Lint * simplify cacheable tasks * Update to lerna 7 * update config * cleanup * Stay on lerna 6 for now * Revert "cleanup" This reverts commit c061fc0. * lint * Skip cache when building prod * Cache labextension builds * Update `targetDefaults` * Update dev command * Fix dependencies * Add missing dependency * fix dep order * fix script deps * Update scripts * Update scripts dependencies * Add back scripts * lint * cache more * Mention task caching in contributing guide
1 parent 2270c04 commit ac3c882

File tree

10 files changed

+1191
-1093
lines changed

10 files changed

+1191
-1093
lines changed

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tasks:
2424
source /workspace/bin/activate-env.sh
2525
micromamba install -n base -y -c conda-forge python=3.11 nodejs=18
2626
source /workspace/bin/activate-env.sh
27-
python -m pip install -e ".[dev,test]" && jlpm && jlpm run build && jlpm develop
27+
python -m pip install -e ".[dev,test]" && jlpm run build && jlpm develop
2828
gp sync-done setup
2929
command: |
3030
gp sync-done setup

CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ Running the end to end tests in headful mode will trigger something like the fol
9494

9595
![playwight-headed-demo](https://user-images.githubusercontent.com/591645/141274633-ca9f9c2f-eef6-430e-9228-a35827f8133d.gif)
9696

97+
## Tasks caching
98+
99+
The repository is configured to use the Lerna caching system (via `nx`) for some of the development scripts.
100+
101+
This helps speed up rebuilds when running `jlpm run build` multiple times to avoid rebuilding packages that have not changed on disk.
102+
103+
To learn more about Lerna caching:
104+
105+
- https://lerna.js.org/docs/features/cache-tasks
106+
- https://nx.dev/core-features/cache-task-results
107+
97108
### Updating reference snapshots
98109

99110
Often a PR might make changes to the user interface, which can cause the visual regression tests to fail.

app/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@
169169
"@jupyterlab/tooltip-extension": "^4.0.3",
170170
"@jupyterlab/translation-extension": "^4.0.3",
171171
"@jupyterlab/ui-components-extension": "^4.0.3",
172-
"@jupyterlab/vega5-extension": "^4.0.3"
172+
"@jupyterlab/vega5-extension": "^4.0.3",
173+
"react": "^18.2.0",
174+
"react-dom": "^18.2.0",
175+
"yjs": "^13.5.40"
173176
},
174177
"devDependencies": {
175178
"@jupyterlab/builder": "^4.0.3",

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"npmClient": "jlpm",
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
33
"version": "independent",
44
"useWorkspaces": true
55
}

nx.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
3+
"tasksRunnerOptions": {
4+
"default": {
5+
"runner": "nx/tasks-runners/default",
6+
"options": {
7+
"cacheableOperations": [
8+
"build",
9+
"build:prod",
10+
"build:lib",
11+
"build:labextension:dev",
12+
"build:labextension"
13+
]
14+
}
15+
}
16+
},
17+
"namedInputs": {
18+
"default": ["{projectRoot}/**/*"]
19+
},
20+
"targetDefaults": {
21+
"build:lib": {
22+
"dependsOn": ["^build:lib"],
23+
"inputs": ["default", "^default"],
24+
"outputs": ["{projectRoot}/lib"]
25+
},
26+
"build": {
27+
"dependsOn": ["^build"],
28+
"inputs": ["default", "^default"]
29+
},
30+
"build:prod": {
31+
"dependsOn": ["^build:prod"],
32+
"inputs": ["default", "^default"]
33+
}
34+
}
35+
}

package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"packages/*"
2020
]
2121
},
22+
"nx": {},
2223
"scripts": {
2324
"build": "lerna run build",
24-
"build:prod": "lerna run build:prod",
25+
"build:lib": "lerna run build:lib",
26+
"build:prod": "lerna run build:prod --skip-nx-cache",
2527
"build:test": "lerna run build:test",
2628
"build:utils": "cd buildutils && npm run build",
2729
"clean": "lerna run clean",
@@ -50,10 +52,15 @@
5052
"eslint-plugin-jest": "^27.2.1",
5153
"eslint-plugin-prettier": "^4.2.1",
5254
"eslint-plugin-react": "^7.32.2",
53-
"lerna": "^6.5.1",
55+
"lerna": "^6.6.2",
5456
"npm-run-all": "^4.1.5",
5557
"prettier": "^2.8.5",
5658
"rimraf": "^3.0.2",
5759
"typescript": "~5.0.2"
60+
},
61+
"resolutions": {
62+
"@types/react": "^18.0.26",
63+
"react": "^18.2.0",
64+
"yjs": "^13.5.40"
5865
}
5966
}

packages/docmanager-extension/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"watch": "tsc -b --watch"
3939
},
4040
"dependencies": {
41+
"@jupyter-notebook/application": "^7.0.0",
4142
"@jupyterlab/application": "^4.0.3",
4243
"@jupyterlab/coreutils": "^6.0.3",
4344
"@jupyterlab/docmanager": "^4.0.3",

packages/docmanager-extension/tsconfig.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
"outDir": "lib",
55
"rootDir": "src"
66
},
7-
"include": ["src/**/*"]
7+
"include": ["src/**/*"],
8+
"references": [
9+
{
10+
"path": "../application"
11+
}
12+
]
813
}

packages/lab-extension/package.json

+36-3
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,51 @@
3030
"style/index.js"
3131
],
3232
"scripts": {
33-
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
33+
"build": "jlpm run build:labextension:dev",
3434
"build:labextension": "jupyter labextension build .",
3535
"build:labextension:dev": "jupyter labextension build --development True .",
36-
"build:lib": "tsc",
37-
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
36+
"build:lib": "tsc -b",
37+
"build:prod": "jlpm run build:labextension",
3838
"clean": "jlpm run clean:lib && jlpm run clean:labextension",
3939
"clean:labextension": "rimraf ../../notebook/labextension",
4040
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
4141
"watch": "run-p watch:src watch:labextension",
4242
"watch:labextension": "jupyter labextension watch .",
4343
"watch:src": "tsc -w"
4444
},
45+
"nx": {
46+
"targets": {
47+
"build:labextension:dev": {
48+
"dependsOn": [
49+
"^build:lib",
50+
"build:lib"
51+
],
52+
"outputs": [
53+
"{workspaceRoot}/notebook/labextension",
54+
"{workspaceRoot}/notebook/labextension/build_log.json"
55+
]
56+
},
57+
"build:labextension": {
58+
"dependsOn": [
59+
"^build:lib",
60+
"build:lib"
61+
],
62+
"outputs": [
63+
"{workspaceRoot}/notebook/labextension"
64+
]
65+
},
66+
"build": {
67+
"dependsOn": [
68+
"build:labextension:dev"
69+
]
70+
},
71+
"build:prod": {
72+
"dependsOn": [
73+
"build:labextension"
74+
]
75+
}
76+
}
77+
},
4578
"dependencies": {
4679
"@jupyter-notebook/application": "^7.0.0",
4780
"@jupyterlab/application": "^4.0.3",

0 commit comments

Comments
 (0)