Skip to content

[Bug]: middleware chunk name collision when using nodejs middleware runtime in NextJS with @segment/analytics-next ^1.77.0 #1339

Description

@igordonin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions