Skip to content

Commit 92fdb83

Browse files
committed
build: Speed up playground build
As discussed in #1836 (comment)
1 parent e638995 commit 92fdb83

File tree

7 files changed

+31
-18
lines changed

7 files changed

+31
-18
lines changed

Taskfile.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ tasks:
244244
- mkdir -p website/public
245245
# Copy the book into the website path, using rsync so it only copies new files
246246
- rsync -ai --checksum --delete book/book/ website/public/book/
247-
- task: install-playground-npm-dependencies
247+
# Must set `install-links=false` in the playground's `npm install` to
248+
# install prql-js as the regular dependency, instead of creating a
249+
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
250+
- cd playground && npm install --install-links=false
248251
- cd playground && npm run build
249252
# We place the playground app in a nested path, because we want to use
250253
# prql-lang.org/playground with an iframe containing the playground.
@@ -290,16 +293,23 @@ tasks:
290293
cmds:
291294
- mdbook serve --port=3000
292295

296+
# Use `npm install --install-links=false` to install prql-js
297+
# as the regular dependency, instead of creating a
298+
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
293299
run-playground:
294300
desc: Build & serve the playground.
295301
dir: web/playground
302+
env:
303+
PROFILE: dev
296304
cmds:
297305
- npm install --install-links=false
298306
- npm start
299307

300308
run-playground-cached:
301309
desc: Build & serve the playground, without rebuilding rust code.
302310
dir: web/playground
311+
env:
312+
PROFILE: dev
303313
cmds:
304314
- task: install-playground-npm-dependencies
305315
- npm start
@@ -309,11 +319,10 @@ tasks:
309319
# Use task's sources/generates to see if checksums of
310320
# node_modules directory have changed since package.json was updated
311321

312-
# Use `npm install --install-links=false` to install prql-js
313-
# as the regular dependency, instead of creating a
314-
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
315322
desc: Check to see if package.json has changed since we ran npm install
316323
dir: web/playground
324+
env:
325+
PROFILE: dev
317326
cmds:
318327
- npm install --install-links=false
319328
sources:

bindings/prql-js/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ JavaScript bindings for [`prql-compiler`](https://github.com/PRQL/prql/).
88
npm install prql-js
99
```
1010

11+
Pass `--profile=dev` for a faster, less optimized build. Without this, the
12+
`wasm` binaries are optimized on each run, even if the underlying code hasn't
13+
changed.
14+
15+
```sh
16+
npm install prql-js --profile=dev
17+
```
18+
1119
## Usage
1220

1321
Currently these functions are exposed

bindings/prql-js/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"url": "https://github.com/PRQL/prql"
1818
},
1919
"scripts": {
20-
"build": "npm run build:node && npm run build:bundler && npm run build:web",
21-
"build:bundler": "wasm-pack build --target bundler --release --out-dir dist/bundler && rm dist/bundler/.gitignore",
22-
"build:node": "wasm-pack build --target nodejs --release --out-dir dist/node && rm dist/node/.gitignore",
23-
"build:web": "wasm-pack build --target no-modules --release --out-dir dist/web && rm dist/web/.gitignore",
20+
"build": "npm run build:node && npm run build:web && npm run build:bundler",
21+
"build:bundler": "npx cross-env wasm-pack build --target bundler --out-dir dist/bundler --${PROFILE} && rm dist/bundler/.gitignore",
22+
"build:node": "npx cross-env wasm-pack build --target nodejs --out-dir dist/node --${PROFILE} && rm dist/node/.gitignore",
23+
"build:web": "npx cross-env wasm-pack build --target no-modules --out-dir dist/web --${PROFILE} && rm dist/web/.gitignore",
2424
"prepare": "npm run build",
2525
"test": "mocha tests"
2626
},

bindings/prql-js/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// https://github.com/rustwasm/wasm-bindgen/pull/2984
2-
#![allow(clippy::drop_non_drop)]
31
mod utils;
42

53
use std::str::FromStr;

web/playground/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A fast-feedback compiler from PRQL to SQL, hosted at
44
<https://prql-lang.org/playground/>
55

66
To run locally,
7-
[set up a development environment](https://prql-lang.org/book/contributing/development.html),
7+
[set up a development environment](https://prql-lang.org/book/contributing/development.html#setting-up-a-full-dev-environment),
88
and then run[^1]:
99

1010
```sh
@@ -15,7 +15,7 @@ task run-playground
1515

1616
```sh
1717
cd playground
18-
npm install
18+
npm install --install-links=false --profile=dev
1919
npm start
2020
```
2121

web/playground/package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
"name": "prql-playground",
4040
"private": true,
4141
"scripts": {
42-
"build": "npm run genBook && react-scripts build",
43-
"eject": "npm run genBook && react-scripts eject",
44-
"preinstall": "rsync -ai --checksum --delete ../../prql-compiler/tests/integration/data/ public/data/",
45-
"start": "npm run genBook && react-scripts start",
46-
"test": "npm run genBook && react-scripts test",
47-
"genBook": "node generateBook.js"
42+
"build": "react-scripts build",
43+
"prepare": "rsync -ai --checksum --delete ../../prql-compiler/tests/integration/data/ public/data/ && node generateBook.js",
44+
"start": "react-scripts start",
45+
"test": "react-scripts test"
4846
},
4947
"version": "0.8.1"
5048
}
15 KB
Binary file not shown.

0 commit comments

Comments
 (0)