Issues with NextJS 12.0.9
See original GitHub issueTrying to import VRCanvas in NextJS 12.0.9
How can this be fixed?
SyntaxError: Unexpected token 'export'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///C:/Users/USER/Wicka/test/node_modules/%20(webxr-input-profiles/motion-controllers/dist/motion-controllers.module.js (397)
wrapSafe
internal/modules/cjs/loader.js (984:16)
Module._compile
internal/modules/cjs/loader.js (1032:27)
Object.Module._extensions..js
internal/modules/cjs/loader.js (1097:10)
Module.load
internal/modules/cjs/loader.js (933:32)
Function.Module._load
internal/modules/cjs/loader.js (774:14)
Module.require
internal/modules/cjs/loader.js (957:19)
require
internal/modules/cjs/helpers.js (88:18)
Object.<anonymous>
file:///C:/Users/USER/Wicka/test/node_modules/@react-three/xr/dist/index.cjs.js (10:25)
Module._compile
internal/modules/cjs/loader.js (1068:30)
Object.Module._extensions..js
internal/modules/cjs/loader.js (1097:10)
import React, { useRef, useState } from 'react';
import { Canvas, useFrame } from '@react-three/fiber';
import { VRCanvas } from '@react-three/xr'
function Box(props) {
// This reference gives us direct access to the THREE.Mesh object
const ref = useRef()
// Hold state for hovered and clicked events
const [hovered, hover] = useState(false)
const [clicked, click] = useState(false)
// Subscribe this component to the render-loop, rotate the mesh every frame
useFrame((state, delta) => (ref.current.rotation.x += 0.01))
// Return the view, these are regular Threejs elements expressed in JSX
return (
<mesh
{...props}
ref={ref}
scale={clicked ? 1.5 : 1}
onClick={(event) => click(!clicked)}
onPointerOver={(event) => hover(true)}
onPointerOut={(event) => hover(false)}>
<boxGeometry args={[1, 1, 1]} />
<meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} />
</mesh>
)
}
export default function Home() {
return (
<Canvas>
<ambientLight />
<pointLight position={[10, 10, 10]} />
<Box position={[-1.2, 0, 0]} />
<Box position={[1.2, 0, 0]} />
</Canvas>
)
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Compilation time extremely slow (Next > 12.0.9) · Issue #38590
I tried to use compilation with SWC and with babel, the result is the same. nextjs 12.0.9: compiled client and server successfully in...
Read more >Upgrade Guide - Next.js
Upgrading from version 10 to 11 · Upgrade React version to latest · Upgrade Next.js version to 11 · Webpack 5 · Cleaning...
Read more >next - npm
Getting Started · Documentation · Who is using Next.js? · Community · Contributing · Authors · Security.
Read more >Vercel Next.js version * : Security vulnerabilities - CVE Details
# CVE ID CWE ID Vulnerability Type(s) Publish Date Update Date Score Gaine...
1 CVE‑2022‑23646 451 2022‑02‑17 2022‑02‑25 4.3 None
2 CVE‑2022‑21721 400 DoS 2022‑01‑28...
Read more >next vulnerabilities | Snyk
version published direct vulnerabilities
13.0.8‑canary.3 21 Dec, 2022 0. C. 0. H. 0. M. 0. L
13.0.8‑canary.2 20 Dec, 2022 0. C. 0. H. 0....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Looks like one of react-xr’s dependencies incorrectly passes a module to its main field. I just created a PR to address that although I’m looking into wider issues across three.
I was able to have a running example, I think it works, but i’m only getting “WEBXR NOT AVAILABLE”
using NextJs dynamic imports