-
Notifications
You must be signed in to change notification settings - Fork 42
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
Optimize js-waku for the Browser #337
Comments
For reference, here is my current polyfill instructions for my package: Crypto-browserify
Fix
Then add to your tsconfig.json: "compilerOptions": {
"paths": {
"crypto": [
"node_modules/crypto-browserify"
]
}
} Stream-browserify
Fix
Then add to your tsconfig.json: "compilerOptions": {
"paths": {
"crypto": [
"node_modules/stream-browserify"
]
}
} DUMP_SESSION_KEYS
Fix
Add polyfill somewhere: global.process = require('process'); |
As well as my commonJS list that I'm using for angular: "allowedCommonJsDependencies": [
"it-concat",
"crypto",
"debug",
"libp2p",
"libp2p-gossipsub/src/utils",
"@chainsafe/libp2p-noise/dist/src/noise",
"libp2p-bootstrap",
"libp2p-websockets",
"libp2p-websockets/src/filters",
"multiaddr",
"peer-id",
"ecies-geth",
"secp256k1",
"libp2p-gossipsub",
"hashconnect"
], |
Thanks for that. Regarding Thanks for the list of deps, I'll try to remove some once migrated to browser only and will probably have to do some upstream fixes :) |
Note that I am updating the documentation to cover polyfills with react-scripts: waku-org/js.waku.guide#19 |
@chainsafe/libp2p-noiseThis library brings two issues:
The bundle size is mostly due to the usage of node-forge, which is also used by libp2p-crypto. node-forge https://github.com/digitalbazaar/forge actually provide ways to bundle only what is necessary. Need to check if the libp2p libraries actually leverage this bundling optimization. |
It is possible to keep the package size small with node-forge: https://mobile.twitter.com/IAmTrySound/status/1476899235723456515 by using source-map-js: vitejs/vite#6556 |
Moved to icebox. Once #527 is done, we can update this one and move it back to backlog. |
updated description to suit better needs of the issue |
Problem
js-waku targets the browser. NodeJS user should use nim-waku and JSON RPC API.
There are a number of issues when using js-waku in the browser:
References
Tasks
Acceptance Criteria
Analysis done in #527. Once done, action plan can be updated.
test_utils
is not bundled.Note, if some dependencies do need polyfills, then it is possible to bundle the polyfill so that users do not have to set it up. It is also possible to only bundle the necessary APIs. see https://github.com/ethers-io/ethers.js/blob/4e6d121fb8aa7327290afab7653364be8ddd8d81/packages/shims/src/index.js
The text was updated successfully, but these errors were encountered: