Next.js Discord

Discord Forum

I have a question about `next build` in standalone mode.

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
I am wondering, why is the dist directory missing from my dependencies.

1. npx next build
2. cd .next/static/node_modules/foo
3. no dist directory present, only src

If I go to my repo, and into the same "foo" dependency, it has dist directory, that is node_modules/foo has a dist directory in my workspace.

NOTE: I am just using foo as an example here, it is true for all dependencies.

7 Replies

I am not sure why you expect a dist folder. standalone mode creates a .next/standalone folder on build

https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
Brown bearOP
I am expecting dist under individual node_modules.

Here's what d3 looks like under node_modules of standalone
And here is what it looks like normally
Notice how the d3 dependency is missing it's minified dist under the standalone next build. 🤷‍♂️
Does it work as expected? Perhaps the dist folder is considered unneccessary and not copied in
Brown bearOP
The app behaves as intended. My concern is that the app might not be deployed optimally. Dist is intended for distribution and is minified ... so what this means is that my app is currently potentially serving less performant scripts?

It could also be that I just am not familiar with web dev standards? I am specifically referring to client side libs btw. So client side js.
Brown bearOP
I think I figured out a partial answer myself. Bundling scripts and dependencies is complex, tools like webpack, rollup, snowpack, do this for us. Whatever is under dist is of no value since webpack during next build will pack our things for us anyway it would seem.

A lot of hidden magic, which makes it hard sometimes to inspect what is going on. I'll probably search for some plugins and tools to make it clearer how large certain dependencies are client side.