Description
In a type:module package, the suggested way to import createMiddleware() doesn't work.
Workaround1: Remove the type:module line of your package.json
Workaround2: Change the suggested middleware.js file to something like
import middleware from "next-intl/middleware";
const createMiddleware = middleware.default;
export default createMiddleware({...});
Verifications
Mandatory reproduction URL
https://github.com/DamienCassou/next-intl-issue-createMiddleware
Reproduction description
Steps to reproduce:
- clone the reproduction project
- type
yarn
- type
yarn run dev
- open http://localhost:3000
Actual behavior:
TypeError: next_intl_middleware__WEBPACK_IMPORTED_MODULE_0__ is not a function
src/middleware.js (3:1) @ <unknown>
1 | import createMiddleware from 'next-intl/middleware';
2 |
> 3 | export default createMiddleware({
| ^
4 | // A list of all locales that are supported
5 | locales: ['en', 'de'],
6 |
Expected behaviour
I see the content of Page.jsx in English.
Description
In a type:module package, the suggested way to import
createMiddleware()doesn't work.Workaround1: Remove the type:module line of your package.json
Workaround2: Change the suggested middleware.js file to something like
Verifications
Mandatory reproduction URL
https://github.com/DamienCassou/next-intl-issue-createMiddleware
Reproduction description
Steps to reproduce:
yarnyarn run devActual behavior:
Expected behaviour
I see the content of Page.jsx in English.