next.js: Attempted import error: 'webgl-sdf-generator' does not contain a default export (imported as 'createSDFGenerator')

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 18.17.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.4-canary.1
  eslint-config-next: 14.0.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which example does this report relate to?

there is no

What browser are you using? (if relevant)

Chrome 119.0.6045.160

How are you deploying your application? (if relevant)

localhost

Describe the Bug

There was no problem with my @react-three/fiber package. While the Next 14.0.1 version worked very smoothly, I started to receive warnings in the next 14.0.2, 14.0.3 and canary versions. I updated all relevant packages but the problem persists. The packages and versions that may be relevant are as follows:

@react-three/fiber: 8.15.11 @react-three/drei: 9.88.16 three: 0.158.0

The warning is as follows: Attempted import error: ‘webgl-sdf-generator’ does not contain a default export (imported as ‘createSDFGenerator’).

Screenshot_6

Expected Behavior

I expect it to work without warning, just like it did in Next 14.0.1.

To Reproduce

I updated the relevant packages and their next versions, but the result is the same. I get the same warning in both development and production mode.

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 20
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Yes I’m getting the exact same thing too. Thanks for making feel less crazy.

Unfortunately, that affirms that there is no way for us to work around this in Drei and that it’s an issue with the app directory. We’ve received a host of issues from its compiler all over the three.js ecosystem since the adoption of SWC. You’ll have to pin to Next 14.0.1 or earlier until a fix becomes available.

{
  "dependencies": {
    "next": "14.0.1"
  }
}

I merged pmndrs/drei#1726 in Drei 9.88.17 which contains a work-around so you can consume Drei, but let me know if this does/doesn’t work when using Text and whether you’re using the app directory.

WRT to Next and possibly a compiler regression, the specific syntax used in webgl-sdf-generator is export { SDFGenerator as default };, but it’s unclear whether it’s resolving as ESM to begin with via non-standard module or its default UMD target from main.

The Issue still occurs with "@react-three/drei": "9.88.17".

Unfortunately, that affirms that there is no way for us to work around this in Drei and that it’s an issue with the app directory. We’ve received a host of issues from its compiler all over the three.js ecosystem since the adoption of SWC. You’ll have to pin to Next 14.0.1 or earlier until a fix becomes available.

{
  "dependencies": {
    "next": "14.0.1"
  }
}

As I mentioned in my description, while there is no problem in 14.0.1, this warning occurs in later versions and canaries.

If someone could share an example or repository, that would help us track this down.