Summary
When using NextJS 15.5.12 and configuring middleware.ts to use NodeJS runtime instead of Edge, there's a chunk name collision with middleware
How to reproduce
Configure any minimal middleware in middleware.ts and add @segment/analytics-next:1.77.0 or above to the dependencies.
export const config = {
matcher: ...
runtime: 'nodejs',
};
Error when building the application:
Failed to compile.
../node_modules/.pnpm/@segment+analytics-next@1.81.1_encoding@0.1.13/node_modules/@segment/analytics-next/dist/pkg/core/analytics/index.js
It's not allowed to load an initial chunk on demand. The chunk name "middleware" is already used by an entrypoint.
Summary
When using NextJS 15.5.12 and configuring middleware.ts to use NodeJS runtime instead of Edge, there's a chunk name collision with
middlewareHow to reproduce
Configure any minimal middleware in
middleware.tsand add @segment/analytics-next:1.77.0 or above to the dependencies.Error when building the application: