Skip to content

Commit c55c160

Browse files
author
ks2211
committed
update readme for bundler instructions, upgrade to 0.2.76 bindgen, drop filename for rs files (needed for cjs)
Signed-off-by: ks2211 <kaushik@cosmonic.com>
1 parent aaaf614 commit c55c160

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,38 @@ $ npm install @wasmcloud/wasmcloud-js
8686
</script>
8787
```
8888

89+
**With a bundler**
90+
91+
There are some caveats to using with a bundler:
92+
93+
* The module contains `.wasm` files that need to be present alongside the final build output. Using `webpack-copy-plugin` can solve this issue.
94+
95+
* Using the es6 imports is currently broken due to `webpack` bundling and the `.wasm` file -- this is being tracked/fixed.
96+
97+
```javascript
98+
import { wasmcloudjs } from '@wasmcloud/wasmcloud-js/dist/cjs/wasmcloud'
99+
100+
(async() => {
101+
const host = await wasmcloudjs.startHost('default', false, ['ws://localhost:4222'])
102+
console.log(host);
103+
})()
104+
105+
```
106+
107+
```javascript
108+
// webpack config, add this to the plugin section
109+
plugins: [
110+
new CopyPlugin({
111+
patterns: [
112+
{
113+
from: 'node_modules/@wasmcloud/wasmcloud-js/dist/cjs/*.wasm',
114+
to: '[name].wasm'
115+
}
116+
]
117+
}),
118+
]
119+
```
120+
89121
**Node**
90122

91123
*IN PROGRESS* - NodeJS does not support WebSockets natively (required by nats.ws)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "@wasmcloud/wasmcloud-js",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "wasmcloud host in JavaScript/Browser",
55
"main": "dist/wasmcloud.js",
6+
"browser": "dist/wasmcloud.js",
67
"module": "dist/src/index.js",
78
"types": "dist/src/index.d.ts",
89
"files": [
910
"dist",
1011
"src",
11-
"README.md"
12+
"README.md",
13+
"wasmcloud-rs-js"
1214
],
1315
"scripts": {
1416
"build": "npm run clean && npm run build:browser && npm run build:cjs",
@@ -60,7 +62,6 @@
6062
"chai": "^4.3.4",
6163
"chai-as-promised": "^7.1.1",
6264
"copy-webpack-plugin": "^9.0.1",
63-
"esbuild": "^0.12.20",
6465
"eslint": "^7.32.0",
6566
"mocha": "^9.0.3",
6667
"path": "^0.12.7",

wasmcloud-rs-js/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"]
1414
default = ["console_error_panic_hook"]
1515

1616
[dependencies]
17-
wasm-bindgen = "0.2.63"
17+
wasm-bindgen = "0.2.76"
1818
wascap = "0.6.0"
1919
getrandom = { version = "0.2", features = ["js"] }
2020
rand = { version = "0.7.3", features = ["wasm-bindgen"] }

webpack.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const baseConfig = {
2222
new WasmPackPlugin({
2323
crateDirectory: path.resolve(__dirname, 'wasmcloud-rs-js'),
2424
extraArgs: '--target bundler',
25-
outDir: path.resolve(__dirname, 'wasmcloud-rs-js', 'pkg'),
26-
outName: 'wasmcloud_rs_js'
25+
outDir: path.resolve(__dirname, 'wasmcloud-rs-js', 'pkg')
2726
})
2827
],
2928
experiments: {

0 commit comments

Comments
 (0)