amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Amplify fails to build Next.js App with translation using i18-next

Open darklight147 opened this issue 2 years ago • 1 comments

Before opening, please confirm:

App Id

d2afd0bnknw8fi

Region

us-east-1

Amplify Hosting feature

Custom builds

Describe the bug

Amplify fails succeed the command next build when trying to build a next.js App.

The build fails right after Printing to the console: Starting SSR Build..., in addition to showing the message:

Error: Command failed with exit code 1: node_modules/.bin/next build
warn  - Invalid next.config.js options detected:
[{
  "instancePath": "",
  "schemaPath": "#/additionalProperties",
  "keyword": "additionalProperties",
  "params": {
    "additionalProperty": "target"
  },
  "message": "must NOT have additional properties"
  }
]

Although the property "target" doesn't exist in either of config files of next.js

contents of "next.config.js"

/* eslint-disable unicorn/prefer-module */
/** @type {import('next').NextConfig} */
module.exports = {
  reactStrictMode: true,
  images: {
    domains: ['cdn.ourdomain.com'],
  },
};

contents of "next-i18next.config.js"

/* eslint-disable unicorn/filename-case */
/* eslint-disable unicorn/prefer-module */
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
  },
};

Expected behavior

After building locally, and on other OS's and even building docker images (with success), unless I am mistaken, this is a Amplify bug

Reproduction steps

  1. Init a next.js project with typescript support
  2. Add next-i18next package by using your package manager of choise
  3. edit your next.config.js like follows
const { i18n } = require('./next-i18next.config');

module.exports = {
  i18n,
};
  1. Create a file called "next-i18next.config.js"
  2. add the following to the file
module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'de'],
  },
};
  1. Run the command from your terminal: npm run build or yarn run build
  2. after it's success
  3. Configure your amplify to auto deploy from your github repo,
  4. it should fail on "frontend build"

Build Settings

No response

Additional information

No response

darklight147 avatar Aug 03 '22 15:08 darklight147

Hi @darklight147 thank you for providing these reproduction steps. We have added this to our product backlog for prioritization. Will update if we are able to find a possible workaround in the mean time.

ghost avatar Aug 08 '22 19:08 ghost

Hi,

I am pleased to share we have now launched support for Next.js 12 and 13. This new release improves the support for Next.js's i18 plugins. For more information, please see our blog post at https://aws.amazon.com/blogs/mobile/amplify-next-js-13

If you run into issues with Next.js 12 or 13, please open a new issue so we can track it specifically. Thank you everyone for your patience and support. It's much appreciated.

calavera avatar Nov 17 '22 20:11 calavera

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Nov 17 '22 20:11 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Nov 17 '22 21:11 github-actions[bot]