From d03482e084b8d551a3ab15d8f16b32615a707399 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Thu, 28 May 2026 10:59:11 +0200 Subject: [PATCH] Fix Turbopack OOM by avoiding duplicate-source re-export in motion/react MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous `motion/src/react.ts` had two re-export statements pulling from the same module: export { motion, m } from "framer-motion" export * from "framer-motion" When compiled to ESM and loaded by Next.js 16's Turbopack on Windows, this duplicate-source pattern caused the dev server to OOM during module-graph analysis (#3741). Importing `framer-motion` directly worked fine, since framer-motion's own index never re-exports from the same source twice. Switching to an `import * as fm from "framer-motion"` + `const` alias keeps the explicit `motion`/`m` exports that IDE auto-import relies on (#3432) without the duplicate-source pattern. Per the ES spec, local declarations shadow the names from `export * from "framer-motion"`, so the compiled output now has a single wildcard re-export plus two local const bindings — a shape Turbopack handles cleanly. Fixes #3741 Co-Authored-By: Claude Opus 4.7 --- packages/motion/src/react.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/motion/src/react.ts b/packages/motion/src/react.ts index d0ba2f67b6..68ad2f648a 100644 --- a/packages/motion/src/react.ts +++ b/packages/motion/src/react.ts @@ -1,3 +1,16 @@ -// Explicit named exports for better IDE auto-import support -export { motion, m } from "framer-motion" +// Re-export everything from framer-motion. +// +// `motion` and `m` are aliased through local bindings so the module has +// explicit named exports for IDE auto-import (see #3432). The previous +// `export { motion, m } from "framer-motion"` line — sitting alongside +// `export * from "framer-motion"` — was a duplicate-source re-export pattern +// that caused Next.js Turbopack to OOM during module-graph analysis (#3741). +// Local declarations shadow the wildcard re-export per the ES spec, so +// `motion` and `m` come from the explicit bindings below and the rest from +// `export *`. +import * as fm from "framer-motion" + +export const motion: typeof fm.motion = fm.motion +export const m: typeof fm.m = fm.m + export * from "framer-motion"