Skip to content

Commit

Permalink
build: Speed up playground build
Browse files Browse the repository at this point in the history
As discussed in PRQL#1836 (comment)
  • Loading branch information
max-sixty committed Jun 22, 2023
1 parent e638995 commit 92fdb83
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
17 changes: 13 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ tasks:
- mkdir -p website/public
# Copy the book into the website path, using rsync so it only copies new files
- rsync -ai --checksum --delete book/book/ website/public/book/
- task: install-playground-npm-dependencies
# Must set `install-links=false` in the playground's `npm install` to
# install prql-js as the regular dependency, instead of creating a
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
- cd playground && npm install --install-links=false
- cd playground && npm run build
# We place the playground app in a nested path, because we want to use
# prql-lang.org/playground with an iframe containing the playground.
Expand Down Expand Up @@ -290,16 +293,23 @@ tasks:
cmds:
- mdbook serve --port=3000

# Use `npm install --install-links=false` to install prql-js
# as the regular dependency, instead of creating a
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
run-playground:
desc: Build & serve the playground.
dir: web/playground
env:
PROFILE: dev
cmds:
- npm install --install-links=false
- npm start

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

# Use `npm install --install-links=false` to install prql-js
# as the regular dependency, instead of creating a
# symlink. Refer to https://github.com/PRQL/prql/pull/1296.
desc: Check to see if package.json has changed since we ran npm install
dir: web/playground
env:
PROFILE: dev
cmds:
- npm install --install-links=false
sources:
Expand Down
8 changes: 8 additions & 0 deletions bindings/prql-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ JavaScript bindings for [`prql-compiler`](https://github.com/PRQL/prql/).
npm install prql-js
```

Pass `--profile=dev` for a faster, less optimized build. Without this, the
`wasm` binaries are optimized on each run, even if the underlying code hasn't
changed.

```sh
npm install prql-js --profile=dev
```

## Usage

Currently these functions are exposed
Expand Down
8 changes: 4 additions & 4 deletions bindings/prql-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"url": "https://github.com/PRQL/prql"
},
"scripts": {
"build": "npm run build:node && npm run build:bundler && npm run build:web",
"build:bundler": "wasm-pack build --target bundler --release --out-dir dist/bundler && rm dist/bundler/.gitignore",
"build:node": "wasm-pack build --target nodejs --release --out-dir dist/node && rm dist/node/.gitignore",
"build:web": "wasm-pack build --target no-modules --release --out-dir dist/web && rm dist/web/.gitignore",
"build": "npm run build:node && npm run build:web && npm run build:bundler",
"build:bundler": "npx cross-env wasm-pack build --target bundler --out-dir dist/bundler --${PROFILE} && rm dist/bundler/.gitignore",
"build:node": "npx cross-env wasm-pack build --target nodejs --out-dir dist/node --${PROFILE} && rm dist/node/.gitignore",
"build:web": "npx cross-env wasm-pack build --target no-modules --out-dir dist/web --${PROFILE} && rm dist/web/.gitignore",
"prepare": "npm run build",
"test": "mocha tests"
},
Expand Down
2 changes: 0 additions & 2 deletions bindings/prql-js/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// https://github.com/rustwasm/wasm-bindgen/pull/2984
#![allow(clippy::drop_non_drop)]
mod utils;

use std::str::FromStr;
Expand Down
4 changes: 2 additions & 2 deletions web/playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A fast-feedback compiler from PRQL to SQL, hosted at
<https://prql-lang.org/playground/>

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

```sh
Expand All @@ -15,7 +15,7 @@ task run-playground

```sh
cd playground
npm install
npm install --install-links=false --profile=dev
npm start
```

Expand Down
10 changes: 4 additions & 6 deletions web/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
"name": "prql-playground",
"private": true,
"scripts": {
"build": "npm run genBook && react-scripts build",
"eject": "npm run genBook && react-scripts eject",
"preinstall": "rsync -ai --checksum --delete ../../prql-compiler/tests/integration/data/ public/data/",
"start": "npm run genBook && react-scripts start",
"test": "npm run genBook && react-scripts test",
"genBook": "node generateBook.js"
"build": "react-scripts build",
"prepare": "rsync -ai --checksum --delete ../../prql-compiler/tests/integration/data/ public/data/ && node generateBook.js",
"start": "react-scripts start",
"test": "react-scripts test"
},
"version": "0.8.1"
}
Binary file added web/playground/prql-playground-0.8.1.tgz
Binary file not shown.

0 comments on commit 92fdb83

Please sign in to comment.