-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Need clarity on the browser vs non-browser version relationship #2903
Comments
|
I only care about supporting more modern browsers. what's a tl;dr; on what the browserify bundle offers that the standard npm package doesn't? It it just I'm new to Vite (this was actually the first project I used it for), but I may try to make some contributions down the line to make the |
Before I added the |
Yes but also doesn't let you bundle your code together, and might be over-polyfilled for your requirements. We don't use or really test the browserify bundle it is just offered for historical reasons. I haven't used Vite myself ftr WebCrypto & TextEncoder are available natively in the web - https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/crypto/crypto.ts#L19-L21 |
Ahh, I thought those were being attached to the window object by However, the code you linked doesn't work for me unless I set up the global object before using the sdk— |
I also noticed |
Switches use of `global` to `globalThis`, which is better supported when building with modern build tools like Vite. Refs matrix-org#2903
Switches use of `global` to `globalThis`, which is better supported when building with modern build tools like Vite. Refs matrix-org#2903 Signed-off-by: Damon Vestervand <[email protected]> Signed-off-by: Damon <[email protected]>
I'm not really clear on what remains to be done on this issue. The summary is "Need clarity..." and some clarity has been given I think, so ... can we close it (please)? |
Switches use of `global` to `globalThis`, which is better supported when building with modern build tools like Vite. Refs #2903 Signed-off-by: Damon Vestervand <[email protected]> Signed-off-by: Damon <[email protected]>
I'm setting up a Vite + React +
matrix-js-sdk
project (but not using thematrix-react-sdk
), and I'm trying to understand how this project is laid out.To get things to work initially, I had to install the npm events package. I loaded Olm using wasm. Then I tried to use the sdk, and had a lot of issues with it referencing a global object that did not exist, so I do this before loading the sdk:
I then followed the pattern Element is using of importing
matrix-js-sdk/src/browser-index
at the root of my project, and importing all the sdk modules frommatrix-js-sdk/src
(instead ofmatrix-js-sdk
top level). This caused > 350 typescript compilation errors, as it tried to compile the/src
directory of the sdk, and there are a lot of errors such as indexingPartial
objects and not checking if the value is defined. I tried downgrading my typescript version, but no dice.I ended up removing the
brower-index
import, usingmatrix-js-sdk
imports instead ofmatrix-js-sdk/src
imports, and actually entirely removing my importing of the browser version that I downloaded from github.And it..somewhat works? I can log in and interact with the server, and send encrypted messages.
tl;dr; it seems to be working now even if I don't download the browser version at all or import
browser-index
. What am I missing? I'm just looking for some clarity on the reason the setup is the way it is and how I should understand/interact with it, as I haven't been able to find much documentation and have just been trying to reverse engineer Element and the react sdk. A quick overview explanation would be very helpfulThe text was updated successfully, but these errors were encountered: