Skip to content

Commit 0356183

Browse files
committed
fix(analytics): use more unique chunk name for middleware (#1339)
Fixes issue with Next.js where the "middleware" webpack chunk name collides with Next.js's middleware.js entrypoint when using the Node.js runtime. Based on #1355 by @blurrah.
1 parent 8f10626 commit 0356183

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': patch
3+
---
4+
5+
Rename middleware chunk name to avoid collision with Next.js middleware entrypoint

packages/browser/src/core/analytics/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export class Analytics
467467
async addSourceMiddleware(fn: MiddlewareFunction): Promise<Analytics> {
468468
await this.queue.criticalTasks.run(async () => {
469469
const { sourceMiddlewarePlugin } = await import(
470-
/* webpackChunkName: "middleware" */ '../../plugins/middleware'
470+
/* webpackChunkName: "analytics-middleware" */ '../../plugins/middleware'
471471
)
472472

473473
const integrations: Record<string, boolean> = {}

0 commit comments

Comments
 (0)