Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update JS packaging #109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions rhizomedb-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,38 @@
},
"homepage": "https://github.com/rhizomedb/rs-rhizome#readme",
"type": "module",
"module": "dist/bundler/rhizomedb_wasm.js",
"types": "dist/nodejs/rhizomedb_wasm.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./lib/browser/rhizomedb_wasm.d.ts",
"import": "./lib/browser/rhizomedb_wasm.js"
},
"node": {
"types": "./lib/node/rhizomedb_wasm.d.ts",
"import": "./lib/browser/rhizomedb_wasm.js",
"require": "./lib/node/rhizomedb_wasm.js"
},
"deno": {
"types": "./lib/deno/rhizomedb_wasm.d.ts",
"import": "./lib/deno/rhizomedb_wasm.js"
},
"workerd": {
"types": "./lib/workerd/rhizomedb_wasm.d.ts",
"import": "./lib/workerd/index.js"
},
"import": "./lib/browser/rhizomedb_wasm.js",
"require": "./lib/node/rhizomedb_wasm.js"
"workerd": "./dist/web/workerd.js",
"browser": "./dist/bundler/rhizomedb_wasm.js",
"node": "./dist/nodejs/rhizomedb_wasm.cjs",
"default": "./dist/bundler/rhizomedb_wasm.js",
"types": "./dist/nodejs/rhizomedb_wasm.d.ts"
},
"./nodejs": {
"default": "./dist/nodejs/rhizomedb_wasm.cjs",
"types": "./dist/nodejs/rhizomedb_wasm.d.ts"
},
"./web": {
"default": "./dist/web/rhizomedb_wasm.js",
"types": "./dist/web/rhizomedb_wasm.d.ts"
},
"./workerd": {
"default": "./dist/web/workerd.js",
"types": "./dist/web/rhizomedb_wasm.d.ts"
}
},
"files": [
"dist"
],
"scripts": {
"build": "export PROFILE=dev && export TARGET_DIR=debug && npm run buildall",
"release": "export PROFILE=release && export TARGET_DIR=release && npm run buildall",
"buildall": "wireit",
"build": "export PROFILE=dev && export TARGET_DIR=debug && npm run build:all",
"release": "export PROFILE=release && export TARGET_DIR=release && npm run build:all",
"build:all": "wireit",
"clean": "wireit",
"test": "wireit",
"test:browser": "wireit",
"test:node": "wireit"
},
"wireit": {
Expand All @@ -67,76 +68,76 @@
"compile"
]
},
"bindgen:browser": {
"command": "wasm-bindgen --target web --out-dir lib/browser target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm",
"env": {
"TARGET_DIR": {
"external": true
}
},
"dependencies": [
"opt"
]
},
"bindgen:node": {
"command": "wasm-bindgen --target nodejs --out-dir lib/node target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm",
"bindgen:bundler": {
"command": "wasm-bindgen --weak-refs --target bundler --out-dir dist/bundler target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm",
"env": {
"TARGET_DIR": {
"external": true
}
},
"dependencies": [
"opt"
],
"output": [
"dist/bundler"
]
},
"bindgen:deno": {
"command": "wasm-bindgen --target deno --out-dir lib/deno target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm",
"bindgen:nodejs": {
"command": "wasm-bindgen --weak-refs --target nodejs --out-dir dist/nodejs target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm && move-file dist/nodejs/rhizomedb_wasm.js dist/nodejs/rhizomedb_wasm.cjs",
"env": {
"TARGET_DIR": {
"external": true
}
},
"dependencies": [
"opt"
],
"output": [
"dist/nodejs"
]
},
"bindgen:workerd": {
"command": "wasm-bindgen --target web --out-dir lib/workerd target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm && shx cp src/loaders/export-workerd-wasm.js lib/workerd/index.js",
"bindgen:web": {
"command": "wasm-bindgen --weak-refs --target web --out-dir dist/web target/wasm32-unknown-unknown/$TARGET_DIR/rhizomedb_wasm.wasm && cpy --flat src/loaders/workerd.js dist/web",
"env": {
"TARGET_DIR": {
"external": true
}
},
"dependencies": [
"opt"
],
"output": [
"dist/web"
]
},
"buildall": {
"build:all": {
"dependencies": [
"bindgen:browser",
"bindgen:node",
"bindgen:deno",
"bindgen:workerd"
"bindgen:bundler",
"bindgen:nodejs",
"bindgen:web"
]
},
"clean": {
"command": "shx rm -rf ./lib"
"command": "rimraf dist"
},
"test:prepare": {
"command": "npx playwright install && shx mkdir tests/report",
"command": "npx playwright install && cross-env mkdir tests/report",
"output": [
"tests/report"
]
},
"test:chromium": {
"command": "pw-test tests/browser.test.ts --assets lib/browser --reporter json --cov > tests/report/chromium.json",
"command": "pw-test tests/rhizomedb.test.ts -r mocha --reporter json --cov > tests/report/chromium.json",
"dependencies": [
"build",
"test:prepare"
],
"output": [
"tests/report/chromium.json"
]
},
"test:firefox": {
"command": "pw-test tests/browser.test.ts --assets lib/browser --reporter json --browser firefox > tests/report/firefox.json",
"command": "pw-test tests/rhizomedb.test.ts -r mocha --reporter json --browser firefox > tests/report/firefox.json",
"dependencies": [
"build",
"test:prepare"
Expand All @@ -146,7 +147,7 @@
]
},
"test:webkit": {
"command": "pw-test tests/browser.test.ts --assets lib/browser --reporter json --browser webkit > tests/report/webkit.json",
"command": "pw-test tests/rhizomedb.test.ts -r mocha --reporter json --browser webkit > tests/report/webkit.json",
"dependencies": [
"build",
"test:prepare"
Expand All @@ -163,7 +164,7 @@
]
},
"test:node": {
"command": "vitest run node.test.ts --outputFile tests/report/node.json",
"command": "pw-test tests/rhizomedb.test.ts -r mocha --reporter json --mode node > tests/report/node.json",
"dependencies": [
"build",
"test:prepare"
Expand All @@ -190,18 +191,17 @@
}
},
"devDependencies": {
"@playwright/test": "^1.34.3",
"@types/expect": "^24.3.0",
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"assert": "^2.0.0",
"expect": "^29.5.0",
"cpy-cli": "^5.0.0",
"cross-env": "^7.0.3",
"mocha": "^10.2.0",
"move-file-cli": "^3.0.0",
"nyc": "^15.1.0",
"playwright-test": "^9.1.0",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"vitest": "^0.31.4",
"playwright-test": "^12.1.1",
"rimraf": "^5.0.1",
"typescript": "^5.1.6",
"wireit": "^0.9.5"
}
}
16 changes: 0 additions & 16 deletions rhizomedb-wasm/tests/browser.test.ts

This file was deleted.

16 changes: 0 additions & 16 deletions rhizomedb-wasm/tests/node.test.ts

This file was deleted.

55 changes: 55 additions & 0 deletions rhizomedb-wasm/tests/rhizomedb.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import assert from 'assert'
import { setPanicHook, Rhizome, InputTuple } from '../dist/bundler/rhizomedb_wasm.js'

before(async () => {
setPanicHook();
})

describe('rhizome', async () => {
it('can compute simple projections', async () => {
const client = await new Rhizome(
() => { },
(p) => {
p.output("values", { value: "int" });

p.rule(
"values",
(value) => ({ value }),
(value) => [
{
op: "search",
rel: "evac",
where: {
attribute: "value",
value,
},
},
]
);
});

const values = [];

await client.registerSink("values", (f) => {
values.push(f.value);
});

let resolver;
const p = new Promise((resolve) => { resolver = resolve });

await client.registerStream("evac", async function*() {
yield new InputTuple("1", "value", 1, []);
yield new InputTuple("1", "value", 2, []);
yield new InputTuple("1", "value", 3, []);
yield new InputTuple("1", "value", 4, []);
yield new InputTuple("1", "value", 5, []);

resolver();
}());

await p;
await client.flush();

assert.deepStrictEqual(values, [1, 2, 3, 4, 5]);
})
})
66 changes: 0 additions & 66 deletions rhizomedb-wasm/tests/rhizomedb/rhizomedb.test.ts

This file was deleted.

21 changes: 17 additions & 4 deletions rhizomedb-wasm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"compilerOptions": {
"outDir": "dist",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"emitDeclarationOnly": true,
"esModuleInterop": true,
"moduleResolution": "Node"
},
"include": [
"tests/**/*.test.ts"
"src",
"tests",
"package.json"
],
"exclude": [
"node_modules",
"dist"
]
}
Loading
Loading