pmndrs / lamina

🍰 An extensible, layer based shader material for ThreeJS
MIT License
1.01k stars 41 forks source link

NextJS build fails due to import error related to react-merge-refs upgrade #43

Closed pfarnach closed 2 years ago

pfarnach commented 2 years ago

Hi there, when importing lamina into my project, I'm getting the following build error in NextJS (12.2.4):

Uncaught Error: require() of ES Module /[My_Project]/node_modules/lamina/node_modules/react-merge-refs/dist/index.mjs not supported.
Instead change the require of /[My_Project]/node_modules/lamina/node_modules/react-merge-refs/dist/index.mjs to a dynamic import() which is available in all CommonJS modules.

This may be a downstream issue but when I reverted lamina to 1.1.20 (changes here where there was a major version bump to react-merge-refs), the build error goes away (and a shader compilation error appears). Apparently NextJS has enabled ES Modules by default since v12. Any thoughts on how to proceed? Thanks!