Conditional operator is forbidden for layout/page config.
Unanswered
Crazy ant posted this in #help-forum
Crazy antOP
i am trying to use revalidate config in my layout witu conditional for different duration in prod and dev.
but this give me error in next 15.
export const revalidate = process.env.NODE_ENV == "production" ? 60 * 10 : 0;but this give me error in next 15.
6 Replies
Western paper wasp
I believe the route config has to be statically analyzable
I think the compiler needs to be able to know the value without executing the code
ie the route config gets applied at a step before the app is actually run
so using complex expressions in the route config is illegal
You could try using Webpack DefinePlugin to replace the config with a constant value before next-types-plugin runs on it ? That way you could still have a different value by node_env
Crazy antOP
i've read that revalidate has to be statically analyzed, but 60 * 10 is working in 14 and below, and thrown exception in 15, is it intented to be working like that?