Next.js Discord

Discord Forum

Standalone build output includes copy of entire monorepo

Unanswered
Serengeti posted this in #help-forum
Open in Discord
SerengetiOP
I have a monorepo with a Next.js project in a next directory. I have other shared JS packages in a packages directory. All of this is configured correctly with package.json and tsconfig.json. Everything builds successfully with and without output: "standalone".

Except in standalone mode, the .next/standalone output directory seems to contain a complete copy of my monorepo. Even files that have nothing to do with the Next.js build (aka *.backup files, deploy scripts, other code projects, etc). The Next.js documentation claims to use a sophisticated algorithm to trace code paths and only include what's needed to run the app. What is happening here? How do I even go about debugging this issue?

7 Replies

sadly I don't know the fix of this but I am following this thread as I am facing the same issue
SerengetiOP
Good to know I'm not the only one having this issue 😅
SerengetiOP
@Yi Lon Ma Are you using Sentry in your app?
SerengetiOP
I created a minimal repro of the problem and seemed to discover that it's caused by Sentry's JS SDK: https://github.com/getsentry/sentry-javascript/issues/18004
If the Sentry SDK isn't imported in the instrumentation file, then the build output is normal.