While Next.js does support Optional Chaining, I have encountered an issue when trying to deploy the following code snippet:
module.exports = {
experimental: {
outputStandalone: true,
},
images: {
domains: process.env.NEXT_PUBLIC_IMAGE_DOMAINS?.split(",").filter((d) => d.trim()).map((d) => d.trim()),
},
reactStrictMode: false,
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: [
"@svgr/webpack",
{
loader: "svg-url-loader",
options: {},
},
],
});
return config;
},
};
However, I encounter an error when deploying it on Vercel:
> Build error occurred
/vercel/path0/next.config.js:6
domains: process.env.NEXT_PUBLIC_IMAGE_DOMAINS?.split(",")
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:195:29)
at ModuleJob.run (internal/modules/esm/module_job.js:145:37)
at async Loader.import (internal/modules/esm/loader.js:182:24)
at async Object.loadConfig [as default] (/vercel/path0/node_modules/next/dist/server/config.js:448:36)
at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:75:20)
error Command failed with exit code 1.
Does anyone have any insights into what might be causing this error?