-
Couldn't load subscription status.
- Fork 3
Open
@ryan-roemer
Description
Background
Use case is that we want to get Next.js configured for the server-side as follows:
- Ideally mimic something like
assignDefaultsin https://unpkg.com/browse/next@12.1.4/dist/server/config.js wherein we pass a config object from readingnext.config.jsand get it all fixed up per that function. - Unfortuately, we can't do this because (1)
assignDefaultsis not exported, and (2) we don't want torequireanything that has Next's webpack stuff involved (forloadConfigs webpack hooks).
For our current code, we have a pure object (with object values but no arrays), which we can get away with a naive Object.assign() on, but this lacks:
- Handling arrays, functions, etc.
- Validation, checking, etc.
Like the real assignDefaults and loadConfig do in Next.js proper.
Task
- Find some way to get all the Next.js configuration goodness and parity.
Ideas
- Find a third party library
- Build and monkey patch
dist/server/config.jsto a new file that exportsassignDefaults - At build time inflate the server object using
assignDefaultsand write it out to disk that gets included in the zip bundle.