motion icon indicating copy to clipboard operation
motion copied to clipboard

[BUG] Next.js 13 and turbopack support

Open lawandothman opened this issue 4 years ago • 5 comments

1. Read the FAQs 👇

2. Describe the bug

Give a clear and concise description of what the bug is.

scrapeMotionValuesFromProps is not defined when running framer motion with Next.js 13 and turbopack.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/compassionate-wing-33omuu

A CodeSandbox minimal reproduction will allow us to quickly follow the reproduction steps. Without one, this bug report won't be accepted.

4. Steps to reproduce

Steps to reproduce the behavior: Run the development server using turbopack yarn dev --turbo

lawandothman avatar Oct 29 '22 11:10 lawandothman

In my case, it works without Turbopack. But, Turbopack failed to compile with below:

error - [rendering] [root of the dev server]/  Error during SSR Rendering
  ReferenceError: scrapeMotionValuesFromProps is not defined
    at <unknown> (.next/server/pages/chunks/_f94c7f.js:7:8)
    at [project-with-next]/node_modules/framer-motion/dist/es/render/html/config-motion.mjs (ecmascript) (.next/server/pages/chunks/_f94c7f.js:4866:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/_f94c7f.js:1:0)
    at [project-with-next]/node_modules/framer-motion/dist/es/render/dom/utils/create-config.mjs (ecmascript) (.next/server/pages/chunks/_f94c7f.js:3127:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/_f94c7f.js:1:0)
    at [project-with-next]/node_modules/framer-motion/dist/es/render/dom/motion.mjs (ecmascript) (.next/server/pages/chunks/_f94c7f.js:334:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/_f94c7f.js:1:0)
    at [project-with-next]/node_modules/framer-motion/dist/es/index.mjs (ecmascript) (.next/server/pages/chunks/_f94c7f.js:294:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/components_3ed733.js:1:0)
    at [project-with-next]/components/common/LayoutWrapper.tsx (ecmascript) (.next/server/pages/chunks/components_3ed733.js:809:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:1:0)
    at [project-with-next]/pages/_app.tsx (ecmascript) (.next/server/pages/chunks/_2281c3.js:430:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at getOrInstantiateModuleFromParent (.next/server/pages/chunks/_2281c3.js:1029:12)
    at esmImport (.next/server/pages/chunks/_2281c3.js:758:20)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:1:0)
    at [project-with-next]/pages/index.tsx/server-renderer.tsx (ecmascript) (.next/server/pages/chunks/_2281c3.js:255:3)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:949:21)
    at runModuleExecutionHooks (.next/server/pages/chunks/_2281c3.js:987:5)
    at instantiateModule (.next/server/pages/chunks/_2281c3.js:948:5)
    at instantiateRuntimeModule (.next/server/pages/chunks/_2281c3.js:1533:12)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:588:1)
    at <unknown> (.next/server/pages/chunks/_2281c3.js:1584:39)
    at <anonymous>
    at Object.registerChunk [as push] (.next/server/pages/chunks/_2281c3.js:1584:25)
    at Object.<anonymous> (.next/server/pages/chunks/[embedded_modules]_@vercel_turbopack-next_c6c740.js:1:41)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (.next/server/pages/index.js:12:1)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at <unknown> (node:internal/main/run_main_module:17:47)
  
  
  | Node.js exit code: 1

Hope helps.

FradSer avatar Oct 30 '22 08:10 FradSer

In my case, I couldn't get it to work even without turbopack. There is no error thrown, content is shown, but animation refuse to work also when using the "use client" directive.

IhsenBouallegue avatar Oct 30 '22 13:10 IhsenBouallegue

I'm gonna keep this open to keep aware of it but I suspect you'll have better luck giving this report to Vercel as there's nothing odd or unique about this import.

mattgperry avatar Nov 04 '22 09:11 mattgperry

Good Morning. Would it be possible to add the statement "use client" in motion? I believe it would solve the above problem.

Place where I believe it would have to be added: image

According to the documentation: image

Alternatives

For developers with the same problem, the next13 documentation provides a solution. image

Pedromdsn avatar Nov 10 '22 12:11 Pedromdsn

Same problem here, got ReferenceError: scrapeMotionValuesFromProps is not defined.

I tried this

'use client';

import { AnimatePresence } from "framer-motion"

export default AnimatePresence

But it didn't work

0xS4D avatar Nov 24 '22 16:11 0xS4D