You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using this package in a Next.js application, it seems like Webpack is adding the buffer node module so it is available in the browser.
This package only uses the Buffer class to verify if an object is one of such kind, and it doesn't use any other functions, so it can be a good idea to use an alternative that won't include the buffer module in the bundle.
# Create app
yarn create next-app --example analyze-bundles analyze-bundles-app
# Navigate to the directorycd analyze-bundles-app
# Install the module
yarn add serialize-error
Update pages/index.tsx to use the module
import{NextPage}from"next";import{serializeError}from"serialize-error";import{useState,useEffect}from"react";constIndex: NextPage<void>=()=>{const[err,setErr]=useState(null);useEffect(()=>{setErr(serializeError(newError("This is an error")));},[]);return(<div><h1>Test Page</h1><div>{JSON.stringify(err)}</div></div>);};exportdefaultIndex;
Make a production build with the analyzer plugin
yarn analyze
When the reports are created, open .next/analyze/client.html and see that the buffer module is included in the bundle
The text was updated successfully, but these errors were encountered:
When using this package in a Next.js application, it seems like Webpack is adding the
buffer
node module so it is available in the browser.This package only uses the Buffer class to verify if an object is one of such kind, and it doesn't use any other functions, so it can be a good idea to use an alternative that won't include the buffer module in the bundle.
To reproduce the issue:
Create a Next.js application from a template with Webpack's bundle analyzer
Update
pages/index.tsx
to use the moduleMake a production build with the analyzer plugin
When the reports are created, open
.next/analyze/client.html
and see that the buffer module is included in the bundleThe text was updated successfully, but these errors were encountered: