Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 'npm packaging for node and web' from Elijah Morgan
Add web support to npm package. **Still a WIP need to do some cleanup still** I assumed it is better to keep the server code and web code together in the same package (bigger download number). It took quite a bit of experimentation but the ultimate experience is node - commonjs ```js const { Database } = require("limbo-wasm/node"); ``` web - module ```js const worker = new Worker(new URL('limbo-wasm/web/limbo-worker.js', import.meta.url), { type: 'module' }); ``` Like I said this took a lot of experimentation on my part as this is my first time trying to create an npm package let alone that mixes commonjs and modules. The structure is an npm workspace with two sub packages (web and node). ``` node ├── dist │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index_bg.wasm │ ├── index_bg.wasm.d.ts │ └── snippets │ └── limbo-wasm-d1562e55b90f5289 │ └── node │ └── src │ └── vfs.js ├── package.json └── src └── vfs.js web ├── dist │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index_bg.wasm │ ├── index_bg.wasm.d.ts │ └── snippets │ └── limbo-wasm-d1562e55b90f5289 │ └── web │ └── src │ └── web-vfs.js ├── html │ ├── index.html │ ├── limbo-opfs-test.html │ └── limbo-test.html ├── node_modules ├── package.json ├── playwright.config.js ├── src │ ├── limbo-worker.js │ ├── opfs-interface.js │ ├── opfs-sync-proxy.js │ ├── opfs-worker.js │ ├── opfs.js │ └── web-vfs.js ├── test │ ├── helpers.js │ ├── limbo.test.js │ ├── opfs.test.js │ └── setup.js └── vite.config.js ``` The output of wasm-pack gets put in <web/node>dist JS code moves into <web/node>src/ Tests move under web/test The npm package looks like (you can see I need to cleanup some of the stuff that gets included). ``` -rw-r--r-- 0 0 0 195 Oct 26 1985 package/web/html/index.html -rw-r--r-- 0 0 0 2733 Oct 26 1985 package/web/html/limbo-opfs-test.html -rw-r--r-- 0 0 0 162 Oct 26 1985 package/web/html/limbo-test.html -rw-r--r-- 0 0 0 632 Oct 26 1985 package/web/test/helpers.js -rw-r--r-- 0 0 0 18128 Oct 26 1985 package/node/dist/index.js -rw-r--r-- 0 0 0 21732 Oct 26 1985 package/web/dist/index.js -rw-r--r-- 0 0 0 1836 Oct 26 1985 package/web/src/limbo-worker.js -rw-r--r-- 0 0 0 2108 Oct 26 1985 package/web/test/limbo.test.js -rw-r--r-- 0 0 0 1764 Oct 26 1985 package/web/src/opfs-interface.js -rw-r--r-- 0 0 0 3409 Oct 26 1985 package/web/src/opfs-sync-proxy.js -rw-r--r-- 0 0 0 1430 Oct 26 1985 package/web/src/opfs-worker.js -rw-r--r-- 0 0 0 3976 Oct 26 1985 package/web/src/opfs.js -rw-r--r-- 0 0 0 4502 Oct 26 1985 package/web/test/opfs.test.js -rw-r--r-- 0 0 0 269 Oct 26 1985 package/web/playwright.config.js -rw-r--r-- 0 0 0 0 Oct 26 1985 package/web/test/setup.js -rw-r--r-- 0 0 0 519 Oct 26 1985 package/node/dist/snippets/limbo-wasm-d1562e55b90f5289/node/src/vfs.js -rw-r--r-- 0 0 0 519 Oct 26 1985 package/node/src/vfs.js -rw-r--r-- 0 0 0 608 Oct 26 1985 package/web/vite.config.js -rw-r--r-- 0 0 0 435 Oct 26 1985 package/web/dist/snippets/limbo-wasm-d1562e55b90f5289/web/src/web-vfs.js -rw-r--r-- 0 0 0 435 Oct 26 1985 package/web/src/web-vfs.js -rw-r--r-- 0 0 0 146 Oct 26 1985 package/web/node_modules/.vite/deps/_metadata.json -rw-r--r-- 0 0 0 309 Oct 26 1985 package/node/package.json -rw-r--r-- 0 0 0 671 Oct 26 1985 package/package.json -rw-r--r-- 0 0 0 23 Oct 26 1985 package/web/node_modules/.vite/deps/package.json -rw-r--r-- 0 0 0 602 Oct 26 1985 package/web/package.json -rw-r--r-- 0 0 0 153 Oct 26 1985 package/web/node_modules/.vite/vitest/results.json -rw-r--r-- 0 0 0 1296 Oct 26 1985 package/node/dist/README.md -rw-r--r-- 0 0 0 1296 Oct 26 1985 package/README.md -rw-r--r-- 0 0 0 1296 Oct 26 1985 package/web/dist/README.md -rw-r--r-- 0 0 0 1217 Oct 26 1985 package/node/dist/index_bg.wasm.d.ts -rw-r--r-- 0 0 0 1217 Oct 26 1985 package/web/dist/index_bg.wasm.d.ts -rw-r--r-- 0 0 0 449 Oct 26 1985 package/node/dist/index.d.ts -rw-r--r-- 0 0 0 2554 Oct 26 1985 package/web/dist/index.d.ts -rw-r--r-- 0 0 0 2215065 Oct 26 1985 package/node/dist/index_bg.wasm -rw-r--r-- 0 0 0 2213889 Oct 26 1985 package/web/dist/index_bg.wasm ``` resolves #624 Closes #657
- Loading branch information