Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
Binaries:
Node: 16.15.1
npm: 8.11.0
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: 12.2.5
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
A typeof Buffer check, for example:
const isNode = typeof Buffer !== 'undefined';
console.log({ isNode });
It causes a full Buffer ployfill (22.51Kb) to be put into the client bundle.
Expected Behavior
A typeof Buffer check should just return 'undefined' in browsers instead.
Link to reproduction
https://github.com/chentsulin/nextjs-issue-40178-bundle-client-buffer
To Reproduce
Add the following lines to the pages/index.js file:
const isNode = typeof Buffer !== 'undefined';
console.log({ isNode });
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
Binaries:
Node: 16.15.1
npm: 8.11.0
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: 12.2.5
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
A
typeof Buffercheck, for example:It causes a full
Bufferployfill (22.51Kb) to be put into the client bundle.Expected Behavior
A
typeof Buffercheck should just return'undefined'in browsers instead.Link to reproduction
https://github.com/chentsulin/nextjs-issue-40178-bundle-client-buffer
To Reproduce
Add the following lines to the
pages/index.jsfile: