You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I receive a TypeScript error, "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@splinetool/react-spline/next")' call instead." after a fresh installation and import. This doesn't break anything locally, but does break the build.
Steps to Reproduce:
npm install @splinetool/react-spline @splinetool/runtime
import Spline from '@splinetool/react-spline/next' in .tsx file (I'm using Next.JS 14 App Router)
Use Case:
Display 3D Phone Mockup in the upper fold/hero section. I've tried Lazy Loading using a dynamic import, but the fallback image doesn't consistently load. When it does, it's very brief, leaving a blank space until the Spline fully renders.
Actual Behavior:
Throws error and breaks build
Code Example:
Regular Import:
importReactfrom'react'importSplinefrom'@splinetool/react-spline/next'importButtonfrom'../../components/base/Button'importstylesfrom'./hero.module.css'functionHero(){return(<sectionclassName={styles.hero}><divclassName={` ${styles.container} container `}><divclassName={` ${styles.left_column} column `}><h1className={styles.intro}><spanclassName={styles.greeting}>Hello,</span><br/>
my name is Épris
</h1><pclassName={styles.pronunciation}>(pronounced aye-pree)</p><pclassName={styles.intro_text}>
I'm a technical and visual problem solver who fuses innovation and
creativity to craft immersive digital experiences.
</p><Buttonhref="/about"variant="solid"colorScheme="accent2">
About Me
</Button></div><divclassName={` ${styles.right_column} column `}><divclassName={styles.sosweet}><Splinescene="https://prod.spline.design/QvnN9UZyqrXUgWZ2/scene.splinecode"className={`${styles.sosweet_mockup}${styles.imgLight}`}/><Splinescene="https://prod.spline.design/cEkXHQu0orVinyJF/scene.splinecode"className={`${styles.sosweet_mockup}${styles.imgDark}`}/></div></div></div></section>)}exportdefaultHero
Dynamic import:
importReactfrom'react'importdynamicfrom'next/dynamic'importImagefrom'next/image'importButtonfrom'../../components/base/Button'importstylesfrom'./hero.module.css'constSpline=dynamic(()=>import('@splinetool/react-spline/next'),{loading: ()=>(<Imagesrc="/assets/images/so_sweet_mockup.png"alt=""priority={true}className={`${styles.sosweet_mockup}`}width="365"height="753"/>),})functionHero(){return(<sectionclassName={styles.hero}><divclassName={` ${styles.container} container `}><divclassName={` ${styles.left_column} column `}><h1className={styles.intro}><spanclassName={styles.greeting}>Hello,</span><br/>
my name is Épris
</h1><pclassName={styles.pronunciation}>(pronounced aye-pree)</p><pclassName={styles.intro_text}>
I'm a technical and visual problem solver who fuses innovation and
creativity to craft immersive digital experiences.
</p><Buttonhref="/about"variant="solid"colorScheme="accent2">
About Me
</Button></div><divclassName={` ${styles.right_column} column `}><divclassName={styles.sosweet}><Splinescene="https://prod.spline.design/QvnN9UZyqrXUgWZ2/scene.splinecode"className={`${styles.sosweet_mockup}${styles.imgLight}`}/><Splinescene="https://prod.spline.design/cEkXHQu0orVinyJF/scene.splinecode"className={`${styles.sosweet_mockup}${styles.imgDark}`}/><svgwidth="572"height="443"className={styles.sosweet_bg}viewBox="0 0 572 443"fill="none"xmlns="http://www.w3.org/2000/svg"xmlnsXlink="http://www.w3.org/1999/xlink"><ellipsecx="69.6033"cy="74.6112"rx="69.6033"ry="74.6112"className={styles.sosweet_ellipse}/><pathd="M465.367 442.5C400.302 442.5 352.107 365.564 352.107 328.066C352.107 258.242 424.4 203.934 487.657 203.934C561.156 203.934 572 255.656 572 293.154C572 330.652 538.263 442.5 465.367 442.5Z"mask="url(#pattern-mask)"className={styles.sosweet_pattern}/><defs><patternid="pattern0"patternContentUnits="objectBoundingBox"width="0.0545719"height="0.0503006"><usexlinkHref="#image0_185_645"transform="scale(0.00454766 0.00419172)"/></pattern><maskid="pattern-mask"x="0"y="0"width="1"height="1"><rectx="350"y="200"width="220"height="245"fill="url(#pattern0)"/></mask><imageid="image0_185_645"width="12"height="12"xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAA4SURBVHgB7cwxEQAwCATBQzm4QgQaEiskOIAuRb75ZueExla4CWiCtfAOz/v68SO4NsEVZ4IrfgCccWkURPNAMQAAAABJRU5ErkJggg=="/></defs></svg></div></div></div></section>)}exportdefaultHero
The text was updated successfully, but these errors were encountered:
Description:
I receive a TypeScript error, "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@splinetool/react-spline/next")' call instead." after a fresh installation and import. This doesn't break anything locally, but does break the build.
Steps to Reproduce:
npm install @splinetool/react-spline @splinetool/runtime
import Spline from '@splinetool/react-spline/next' in .tsx file (I'm using Next.JS 14 App Router)
Use Case:
Display 3D Phone Mockup in the upper fold/hero section. I've tried Lazy Loading using a dynamic import, but the fallback image doesn't consistently load. When it does, it's very brief, leaving a blank space until the Spline fully renders.
Actual Behavior:
Throws error and breaks build
Code Example:
Regular Import:
Dynamic import:
The text was updated successfully, but these errors were encountered: