Skip to content

Commit

Permalink
fix: Update build (#12)
Browse files Browse the repository at this point in the history
# Summary

This update adds tree-shaking to the JS build so that unused code paths
are removed. This removes references to unused files. The terser plugin
was also added to decrease the size of the source.

- Upgraded node version in `.node-version`
- Upgraded yarn
- Removed `package-lock.json`
- Fixed VSCode `rust-analyzer` settings
- Updated GitHub workflows
- Updated README
- Updated rollup config
- Added `wasm-pack` and `@rollup/plugin-terser` dependencies
- Renamed `package.js` to `sqlite3-diesel.js`
- Added test scripts
- Added tree-shaking and terser plugin for output

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

- **New Features**
- Updated workflow configurations for better performance and clarity in
CI/CD processes.
- Introduced new test scripts for comprehensive browser testing,
including headless modes.

- **Bug Fixes**
- Corrected paths and dependencies in the README for improved clarity
and consistency.

- **Documentation**
	- Enhanced README with clearer instructions and corrected examples.

- **Chores**
- Updated Node.js version and Yarn configuration for improved
compatibility and performance.
- Streamlined JavaScript code for better readability and
maintainability.

- **Style**
- Modernized JavaScript syntax in the async proxy file for enhanced
clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
rygine authored Nov 10, 2024
1 parent eac6c90 commit df43774
Show file tree
Hide file tree
Showing 16 changed files with 1,336 additions and 16,363 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Lint PR"
name: Lint PR
on:
pull_request_target:
types:
Expand Down
40 changes: 18 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,34 @@ on:
jobs:
test:
name: Test
# running with macos since it contains the safari driver
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: brew install --cask firefox
- name: Install Firefox
run: sudo apt-get update && sudo apt-get install -y firefox
- name: Update rust toolchains
run: rustup update
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Setup node and yarn
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "./yarn.lock"
cache-dependency-path: "yarn.lock"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Run Yarn install
uses: borales/actions-yarn@v5
with:
cmd: --cwd ./ install
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
- run: cargo build --target wasm32-unknown-unknown --tests --features unsafe-debug-query
- run: wasm-pack test --headless --chrome --features unsafe-debug-query
working-directory: ./
- run: wasm-pack test --headless --firefox --features unsafe-debug-query
working-directory: ./
- name: Install dependencies
run: yarn
- name: Build rust
run: cargo build --target wasm32-unknown-unknown --tests --features unsafe-debug-query
- name: Test in Chrome
run: yarn test:chrome:headless
- name: Test in Firefox
run: yarn test:firefox:headless
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.1
20.17.0
38 changes: 19 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"rust-analyzer": {
"cargo": {
"sysroot": "discover",
"allTargets": false,
"target": "wasm32-unknown-unknown"
},
"procMacro": {
"enable": true,
"attributes.enable": true,
"ignored": {
"async-trait": ["async_trait"],
"napi-derive": ["napi"],
"async-recursion": ["async_recursion"],
"ctor": ["ctor"],
"tokio": ["test"],
"diesel": ["table"],
"wasm-bindgen": ["wasm-bindgen"]
}
}
"rust-analyzer.cargo.sysroot": "discover",
"rust-analyzer.cargo.allTargets": false,
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.diagnostics.enable": true,
"rust-analyzer.diagnostics.disabled": [
"unlinked-file",
"unresolved-macro-call",
"unresolved-proc-macro"
],
"rust-analyzer.procMacro.attributes.enable": true,
"rust-analyzer.procMacro.ignored": {
"async-trait": ["async_trait"],
"napi-derive": ["napi"],
"async-recursion": ["async_recursion"],
"ctor": ["ctor"],
"tokio": ["test"],
"diesel": ["table"],
"wasm-bindgen": ["wasm-bindgen"]
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
Expand Down
934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ enableGlobalCache: false
enableTelemetry: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.1.cjs
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Diesel Backend for SQLite and WASM

### Use SQLite with Diesel ORM in your web apps!
Use SQLite with Diesel ORM in your web apps!

## Quickstart

add `diesel-wasm-sqlite` to your project. SQLite is automatically bundled with
Add `diesel-wasm-sqlite` to your project. SQLite is automatically bundled with
the library.

```toml
Expand Down Expand Up @@ -63,39 +63,37 @@ async fn code_in_web_worker() -> Result<i32, diesel::QueryResult<usize>> {
}
```

look in `tests/web.rs` for working example!
Look in `tests/test/web.rs` for a working example!

## Contributing

### Building

#### Install yarn dependencies

`yarn install`
`yarn`

#### Build the SQLite/OPFS BUndle
#### Build the SQLite/OPFS JavaScript Bundle

`yarn run build`
`yarn build`

#### Build the rust code, and re-build `package.json` if it changed
#### Build the rust code

`cargo build --target wasm32-unknown-unknown`

#### Run Tests
#### Run tests (browser)

`wasm-pack test --safari --features unsafe-debug-query`
- `yarn test:chrome`
- `yarn test:firefox`
- `yarn test:safari`

navigate to `http://localhost:8000` to observe test output
Navigate to `http://localhost:8000` to observe test output.

#### Run Tests (headless)
#### Run tests (headless)

`wasm-pack test --safari --headless`

#### Setting up the project in VSCode

rust-analyzer does not like crates with different targets in the same workspace.
If you want this to work well with your LSP, open `diesel-wasm-sqlite` as it's
own project in VSCode.
- `yarn test:chrome:headless`
- `yarn test:firefox:headless`
- `yarn test:safari:headless`

### Opening a Pull Request

Expand Down
Loading

0 comments on commit df43774

Please sign in to comment.