Bundling .next/standalone/server.js With Standalone Output NextJS App:
Unanswered
American black bear posted this in #help-forum
American black bearOP
My company currently has a NextJS app that we self-hosted inside a client's servers.
A constraint of our client's runtime environements is that we cannot ship a large number of files, as each file has to be scanned by the internal networks virus scan, which leads to hours and sometimes days before the files can be scanned by the client's network. Our current solution to this is that we use the "export" output in next config. Which only exports the static client side files of the application. This is quite limited in what we can do with a NextJS app, and I am on a mission to see if we can get full feature support for our developers here.
We originally went the export route because no one at the company knew you could get a server output from the NextJS Framework using a Customer Server or the "standalone" output configuration.
I have opted to use the standalone output feature which gives us a nicely packaged set of distributable files. However, shipping all the node_modules inside the .next/standalone output is NOT an option.
My solution to this was going to be to bundle the .next/standalone/server.js into a single bundle and ship that along side the public folder and .next folder, which would work for our needs.Which would take the current ouput of the standalone folder like this:
|-- .next/
|-- node_modules/
|-- server.js <-- bundle this with node_modules
and copying the /public folder and .next/static folder and resulting in a distributable environment like this:
|-- .next/
|-- public/
|-- static/
|-- bundle.js
The problem is I can't figure out:
How do you bundle "next" module in the node_modules folder?
I've been trying to bundle the 'next' npm package referenced in .next/standalone/server.js to no avail. I am open to use any bundler that will work. I cannot seem to figure out the configuration I need using Rollup, Webpack, ncc, or any other bundler.
Please help me bundle the standalone server which uses "next" to be a single JS bundle file?
A constraint of our client's runtime environements is that we cannot ship a large number of files, as each file has to be scanned by the internal networks virus scan, which leads to hours and sometimes days before the files can be scanned by the client's network. Our current solution to this is that we use the "export" output in next config. Which only exports the static client side files of the application. This is quite limited in what we can do with a NextJS app, and I am on a mission to see if we can get full feature support for our developers here.
We originally went the export route because no one at the company knew you could get a server output from the NextJS Framework using a Customer Server or the "standalone" output configuration.
I have opted to use the standalone output feature which gives us a nicely packaged set of distributable files. However, shipping all the node_modules inside the .next/standalone output is NOT an option.
My solution to this was going to be to bundle the .next/standalone/server.js into a single bundle and ship that along side the public folder and .next folder, which would work for our needs.Which would take the current ouput of the standalone folder like this:
|-- .next/
|-- node_modules/
|-- server.js <-- bundle this with node_modules
and copying the /public folder and .next/static folder and resulting in a distributable environment like this:
|-- .next/
|-- public/
|-- static/
|-- bundle.js
The problem is I can't figure out:
How do you bundle "next" module in the node_modules folder?
I've been trying to bundle the 'next' npm package referenced in .next/standalone/server.js to no avail. I am open to use any bundler that will work. I cannot seem to figure out the configuration I need using Rollup, Webpack, ncc, or any other bundler.
Please help me bundle the standalone server which uses "next" to be a single JS bundle file?