Skip to content

Commit

Permalink
add metadata for crates
Browse files Browse the repository at this point in the history
remove rollup plugin typescript

organize JS into one folder
  • Loading branch information
insipx committed Aug 27, 2024
1 parent d43b891 commit bb18b61
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 38 deletions.
1 change: 1 addition & 0 deletions diesel-wasm-sqlite/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!.yarn/releases
!.yarn/sdks
!.yarn/versions
node_modules/**
2 changes: 1 addition & 1 deletion diesel-wasm-sqlite/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion diesel-wasm-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
[package]
name = "diesel-wasm-sqlite"
version = "0.1.1"
version = "0.0.1"
edition = "2021"
resolver = "2"
authors = ["XMTP Labs <[email protected]>"]
description = "SQLite WebAssembly backend for Diesel"
homepage = "https://xmtp.org/"
repository = "https://github.com/xmtp/libxmtp"
license = "MIT"
keywords = ["orm", "database", "sql", "wasm"]
categories = ["database", "wasm"]

[dependencies]
talc = { version = "4.4", default-features = false, features = ["lock_api"] }
Expand Down
16 changes: 8 additions & 8 deletions diesel-wasm-sqlite/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::env;
use std::process::Command;
// use std::process::Command;

fn main() {
println!("cargo::rerun-if-changed=package.js");
println!("cargo::rerun-if-changed=package.json");
// println!("cargo::rerun-if-changed=package.js");
// println!("cargo::rerun-if-changed=package.json");

Command::new("yarn").args(["install"]).status().unwrap();
Command::new("yarn")
.args(["run", "build"])
.status()
.unwrap();
// Command::new("yarn").args(["install"]).status().unwrap();
// Command::new("yarn")
// .args(["run", "build"])
// .status()
// .unwrap();

let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if target_arch != "wasm32" {
Expand Down
1 change: 0 additions & 1 deletion diesel-wasm-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"rollup": "^4.19.0",
"rollup-plugin-copy": "^3.5.0"
}
Expand Down
14 changes: 12 additions & 2 deletions diesel-wasm-sqlite/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import { defineConfig } from "rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import copy from "rollup-plugin-copy";

export default defineConfig([
{
input: "package.js",
output: {
file: "src/wa-sqlite-diesel-bundle.js",
file: "src/js/wa-sqlite-diesel-bundle.js",
format: "es",
},
plugins: [
nodeResolve(),
copy({
targets: [
{
src:
"./node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.wasm",
dest: "src/js",
},
],
}),
],
// external: ["@sqlite.org/sqlite-wasm"],
},
{
input:
"./node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-opfs-async-proxy.js",
output: {
file: "src/sqlite3-opfs-async-proxy.js",
file: "src/js/sqlite3-opfs-async-proxy.js",
format: "es",
},
},
Expand Down
7 changes: 3 additions & 4 deletions diesel-wasm-sqlite/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub(super) static SQLITE: OnceCell<SQLite> = OnceCell::const_new();
// have to go through JS/browser at all.

/// the raw WASM bytes
pub(super) const WASM: &[u8] =
include_bytes!("../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.wasm");
pub(super) const WASM: &[u8] = include_bytes!("js/sqlite3.wasm");

/// Options for instantiating memory constraints
#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -103,7 +102,7 @@ pub async fn init_sqlite() {
let opts = serde_wasm_bindgen::to_value(&Opts {
wasm_binary: WASM,
wasm_memory: mem,
proxy_uri: wasm_bindgen::link_to!(module = "/src/sqlite3-opfs-async-proxy.js"),
proxy_uri: wasm_bindgen::link_to!(module = "/src/js/sqlite3-opfs-async-proxy.js"),
})
.expect("serialization must be infallible for const struct");
let opts = Object::from(opts);
Expand Down Expand Up @@ -140,7 +139,7 @@ struct Version {
}

/// Direct Sqlite3 bindings
#[wasm_bindgen(module = "/src/wa-sqlite-diesel-bundle.js")]
#[wasm_bindgen(module = "/src/js/wa-sqlite-diesel-bundle.js")]
extern "C" {
#[derive(Debug)]
pub type SQLite;
Expand Down
Binary file added diesel-wasm-sqlite/src/js/sqlite3.wasm
Binary file not shown.
22 changes: 1 addition & 21 deletions diesel-wasm-sqlite/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,7 @@ __metadata:
languageName: node
linkType: hard

"@rollup/plugin-typescript@npm:^11.1.6":
version: 11.1.6
resolution: "@rollup/plugin-typescript@npm:11.1.6"
dependencies:
"@rollup/pluginutils": "npm:^5.1.0"
resolve: "npm:^1.22.1"
peerDependencies:
rollup: ^2.14.0||^3.0.0||^4.0.0
tslib: "*"
typescript: ">=3.7.0"
peerDependenciesMeta:
rollup:
optional: true
tslib:
optional: true
checksum: 10/4ae4d6cfc929393171288df2f18b5eb837fa53d8689118d9661b3064567341f6f6cf8389af55f1d5f015e3682abf30a64ab609fdf75ecb5a84224505e407eb69
languageName: node
linkType: hard

"@rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.1.0":
"@rollup/pluginutils@npm:^5.0.1":
version: 5.1.0
resolution: "@rollup/pluginutils@npm:5.1.0"
dependencies:
Expand Down Expand Up @@ -503,7 +484,6 @@ __metadata:
resolution: "diesel-wasm-sqlite@workspace:."
dependencies:
"@rollup/plugin-node-resolve": "npm:^15.2.3"
"@rollup/plugin-typescript": "npm:^11.1.6"
"@sqlite.org/sqlite-wasm": "npm:latest"
rollup: "npm:^4.19.0"
rollup-plugin-copy: "npm:^3.5.0"
Expand Down

0 comments on commit bb18b61

Please sign in to comment.