When Next.js' experimental modern mode is used, the Terser settings for related bundles should be adjusted:
terserOptions.module = true
terserOptions.ecma = terserOptions.compress.ecma = terserOptions.output.ecma = 8
Currently, Terser always assumes an ES5 environment.