on-internet
← Community

How to enable tree shaking for next.js?

Stack Overflow ·

Is there something to enable to have next.js perform tree-shaking/removal of dead code from dependencies? I've exported two objects like this: library.js export const foo = {foo:"foo"} export const bar = {bar:"bar"} And in my next.js app I do like this: page.tsx import { foo } from 'library'; console.log(foo); So now I'd expect a production-build will not include bar, and indeed something appears to go right because this line is produced: .next/server/chunks/621.js /* unused harmony exports bar */ But confusingly when I load the app in the browser the network-traffic indicates the unused expor

Comments

Sign in or sign up to comment and upvote.

No comments yet.