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

Unnecessary polyfill is included in client js by using Buffer API #107

Closed
nissy-dev opened this issue May 4, 2022 · 1 comment · Fixed by #89
Closed

Unnecessary polyfill is included in client js by using Buffer API #107

nissy-dev opened this issue May 4, 2022 · 1 comment · Fixed by #89

Comments

@nissy-dev
Copy link

nissy-dev commented May 4, 2022

next-themes uses Buffer API for base64 encode when server-side rendering.

return isServer ? Buffer.from(str).toString('base64') : btoa(str)

However, this line increases a bundle size of client js. The polyfill of Buffer API is not necessary, but _app.js includes it.

SS_ 2022-05-04 18 13 31

I suggest two ways of solving this issue.

  1. Stop using base64. I seem the PR v0.2 #89 will solve.
  2. Drop supporting Node.js v14 and below. atob/btoa is available in Node.js v16 and later.

@pacocoursey
Will you continue to work about #89 ?

@nissy-dev nissy-dev changed the title Unnecessary Polyfill is included in client js by using Buffer API Unnecessary polyfill is included in client js by using Buffer API May 4, 2022
@pacocoursey
Copy link
Owner

Yes, I plan to move away from the base64 approach. Now that Next.js 12.1.6 is out, we can go back to using an inline script with beforeInteractive.

So this should be resolved with #89.

@pacocoursey pacocoursey mentioned this issue May 5, 2022
Merged
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

Successfully merging a pull request may close this issue.

2 participants