Comments (13)
Should work with:
"@react-three/fiber": "^6.0.1",
"@react-three/postprocessing": "^2.0.1",
"next": "^10.1.2",
"postprocessing": "^6.21.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"three": "^0.127.0"
@kyleawayan @nathanbabcock @vinkovsky @sargunv @MichalPrzybys-TomTom @marcelmusiol lmk if the issue is still present
from react-postprocessing.
In the Next.js 13 project, global server-side rendering (SSG) is enabled by default, and the component is for client-side rendering (CSR) effects and cannot be processed during server-side rendering. This can cause build errors. To fix this, you can move the code that uses the component into a client-rendered environment to ensure that it is only executed on the client side.
const DepthOfField = dynamic(
() =>
import("@react-three/postprocessing").then((module) => module.DepthOfField),
{
ssr: false,
},
)
const EffectComposer = dynamic(
() =>
import("@react-three/postprocessing").then(
(module) => module.EffectComposer,
),
{
ssr: false,
},
)
from react-postprocessing.
I'm using CRA, not Next, but I had a similar error and was able to resolve it by adding this Babel plugin: @babel/plugin-proposal-optional-chaining
. A quick look at the index.js file in the tarball shows optional chaining is being used in a couple spots.
from react-postprocessing.
Using code from Effects.js
from https://codesandbox.io/embed/r3f-game-i2160 for now
from react-postprocessing.
I'm getting the same error
from react-postprocessing.
Fails on Gatsby as well. Presumably it's an issue with SSG; eg using window
without checking for its existence.
As such, the same approach applies for other modules that do this: use Loadable Components.
This is something the developers should fix, but this works until then.
from react-postprocessing.
Same here
from react-postprocessing.
As suggested here webpack/webpack#10227, there is a workaround - you can add resolutions
with acorn 8.x to your package.json.
from react-postprocessing.
Did anyone find a working solution for Nextjs? I tried adding adding resolutions
with acorn 8.x to package.json and using the @babel/plugin-proposal-optional-chaining
plugin, but no success so far.
Edit: Found a solution: vercel/next.js#20363 (comment)
Add next.config.js
to the root directory and add:
module.exports = {
future: { webpack5: true }
}
from react-postprocessing.
still the same error with nuxt js
from react-postprocessing.
still the same error with nuxt js
is it latest? can you go back a few versions, at least before ssr was merged? maybe it's that.
from react-postprocessing.
I still get this error with latest everything:
"@react-three/drei": "^9.17.0",
"@react-three/fiber": "^8.0.27",
"@react-three/postprocessing": "^2.4.6",
"next": "12.2.1",
"postprocessing": "^6.28.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"three": "^0.142.0"
also tried adding next-transpile-modules
to transpile the build node_modules
but no dice.
error - /Users/christopher-williams/dev/r3f-spaceship/node_modules/postprocessing/build/postprocessing.js:1405
this.fragmentShader = effect_default.replace(EffectShaderSection.FRAGMENT_HEAD, shaderParts.get(EffectShaderSection.FRAGMENT_HEAD) ?? "").replace(EffectShaderSection.FRAGMENT_MAIN_UV, shaderParts.get(EffectShaderSection.FRAGMENT_MAIN_UV) ?? "").replace(EffectShaderSection.FRAGMENT_MAIN_IMAGE, shaderParts.get(EffectShaderSection.FRAGMENT_MAIN_IMAGE) ?? "");
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/Users/christopher-williams/dev/r3f-spaceship/node_modules/@react-three/postprocessing/dist/index.cjs:5:22)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) {
page: '/'
}
from react-postprocessing.
On the off chance this helps anybody who finds their way here - I got this error when I tried to use the code from the r3f docs page for Depth of Field not understanding that in order to use the DepthOfField component, it must be placed in the EffectComposer component as stated in the react-postprocessing README.
TLDR In other words, my fix was:
<Canvas>
{/* The rest of your scene */}
<EffectComposer>
<DepthOfField />
</EffectComposer>
</Canvas>
from react-postprocessing.
Related Issues (20)
- EffectComposer and Typescript
- Next 13+ EffectComposer Import Error HOT 3
- Added the Custom Effect of Sharpeness
- Live demo broken
- Remove yarn, just adds complexity
- "no exported member" errors when using NodeNext module/moduleResolution in TypeScript
- Selection causes endless loop
- DepthOfField issue: white halo around objects when using resolutionScale < 0.5
- Upgrade `postprocessing` dependency to latest HOT 4
- No tone mapping exposure support HOT 3
- ToneMappingMode is not re-exported. This can lead to confusion due to how Typescript handles enums
- Current state of SSR
- Memory leak when switching cameras HOT 2
- Configure SMAA
- Invalid value used as weak map key in postprocessing
- [Bug] - N8AO works incorrectly with adaptiveDpr
- Shockwave on cloned objects HOT 1
- Modify Godrays props
- When using `EffectComposer`and `GizmoViewport`, `GizmoViewport` disappears
- if there a way to get gl.info from renderpass? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-postprocessing.