Open larsqa opened 2 years ago
It just doesn't look like next.config.cjs
is loaded on my end:
# I'm using ESM
$ cat package.json | jq --raw-output .type
module
# Set up an intentional error in next.config
$ echo 'throw new Error("intentional error in next.config")' > next.config.cjs
# Try a build, it succeeds, signaling `next.config.cjs` is never loaded
$ ./node_modules/.bin/next build
✓ Linting and checking validity of types
▲ Next.js 14.0.4
✓ Creating an optimized production build
✓ Compiled successfully
✓ Collecting page data
✓ Generating static pages (3/3)
✓ Collecting build traces
✓ Finalizing page optimization
Route (pages) Size First Load JS
┌ ○ / (801 ms) 68 kB 206 kB
├ /_app 0 B 138 kB
└ ○ /404 182 B 138 kB
+ First Load JS shared by all 138 kB
├ chunks/framework-5429a50ba5373c56.js 45.2 kB
├ chunks/main-72cd581c1e9bd837.js 31.6 kB
├ chunks/pages/_app-9e8e58a043cf1f7b.js 59.8 kB
└ chunks/webpack-87b3a303122f2f0d.js 995 B
○ (Static) prerendered as static content
# Move it to a regular .js file
$ mv next.config.cjs next.config.js
# Build correctly fails, but should have also failed previously
$ ./node_modules/.bin/next build
⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
> Build error occurred
Error: intentional error in next.config
at file:///home/mike/Work/transmission-material-ui/next.config.js:1:7
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
The option
output: "standalone"
in thenext.config.js
file is ignored when usingnext.config.cjs
(note:.cjs
) as file extension.Expected Behavior
output: "standalone"
should work in both.js
and.cjs
filesLink to reproduction
N/A
To Reproduce
N/A