-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
rust-crypto is included by default which leads to bundle size growth #4154
Comments
I'm afraid I'm not following everything you're saying here; I'm not that familiar with all the finer details of babel and the javascript ecosystem, and I've never used It does seem a problem that the transpiled js-sdk forces the rust-crypto import to be resolved at load time. (We don't encounter this in element-web because we use the typescript source in A couple of questions about your solution:
I think updating
Again, I don't understand why this is necessary. Are you saying that importing |
Hi @richvdh ! I was trying to hotfix the problem, so don't take this workaround seriously as a solution.
|
Why don't you open a PR setting |
Reproduction: https://github.com/ms-dosx86/matrix-js-sdk-example
Steps to reproduce:
npm i
ng build
An empty project with just
createClient()
weighs 8.89mb.You can also do
ng build --stats-json
and uploaddist/matrix-js-sdk-example/stats.json
to https://esbuild.github.io/analyze/ to see what causes such huge bundle size.This happens because of lazy rust-crypto import here
https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/client.ts#L2255
it looks fine, the source of problem is babel preset
module: 'commonjs'
https://github.com/matrix-org/matrix-js-sdk/blob/develop/.babelrc#L10
which makes the lazy import not quite lazy.
Possible workaround for those who is facing the same problem:
module: false
andnode: 18
in.babelrc
import type { EncryptedFile, FileContent } from "../@types/media";
yarn build
lib
and replace with itnode_modules/matrix-js-sdk/lib
.The text was updated successfully, but these errors were encountered: