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/@[email protected][email protected]/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.