Skip to content
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

bundle size too big for React-SDK #147

Open
tmkasun opened this issue Oct 26, 2022 · 1 comment
Open

bundle size too big for React-SDK #147

tmkasun opened this issue Oct 26, 2022 · 1 comment
Assignees

Comments

@tmkasun
Copy link
Contributor

tmkasun commented Oct 26, 2022

Is your suggestion related to an experience? Please describe.

When we did a bundle analysis in our React app which we use @asgardeo/auth-react for auth purposes, It outputs the following result.

image

@asgardeo/auth-react is consuming +500KB which is bigger than the next biggest chunk in our app.
For the comparison, MUI core is under 100KB, React + React-DOM is ~126KB

So IMO +500KB for auth library is an unusually large bundle size.

Describe the improvement

IMHO, We might be packing the resources that @asgardeo/auth-react probably not used in the runtime, So if we can do proper Tree shaking we might able to reduce the bundle size by large amount.

@pavinduLakshan
Copy link
Contributor

The reason for this "unusual" large bundle size is that the web worker storage implementation can not be treeshaked, as what will be used by the web worker in the runtime cannot be determined in the build time.

As per the offline ad-hoc conversations we had, there are several ways to address this concern.

  1. Package the web worker implementation as an npm package to be optionally installed, since the SDK's default token storage strategy is session storage.
  2. Provide an option (a build-time argument) to select web worker implementation to be included in the final bundle.

The following are some of the alternative methods I could come up with.

  1. Load the web worker implementation from remote CDN.
  2. Re use the code between main thread client and web worker client using a library such as webworkify [1].

[1] https://github.com/browserify/webworkify

cc: @DonOmalVindula @brionmario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants