-
Notifications
You must be signed in to change notification settings - Fork 4
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
Client build includes server-only libraries #8
Comments
Looks like the proper solution is one of these methods: https://arunoda.me/blog/ssr-and-server-only-modules (though #2 wouldnt apply in this case). |
Definitely, thanks for spotting this! I think the proper fix these days is using the if (typeof window === "undefined") {
ServerCookies = require('cookies')
} trick. Next.js configures webpack to drop that code for client-side builds. |
...thought I, not knowing that this does not apply to modules from node_modules. I'll use the evil eval hack then. |
### [1.1.3](v1.1.2...v1.1.3) (2020-07-18) ### Bug Fixes * **Build:** Exclude server-side `cookies` library from Webpack build ([6c3f044](6c3f044)), closes [#8](#8)
🎉 This issue has been resolved in version 1.1.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I noticed that when I build a project including this library, the resulting client build includes a bunch of server libraries that bloat up the size.
For comparison, here's the output of a clean
create-next-app
output:After adding this library, here's the resulting output size:
Here's an analysis of the client output with this library:
It seems all of the extraneous libraries stem from the importing of
cookies
.If I dynamically import this library, the size goes back down to something reasonable (the analysis diagram still ends up including the extraneous libraries, although they're not loaded):
This is probably not the ideal solution, but just throwing that out there.
The text was updated successfully, but these errors were encountered: