Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted import error: 'rbush' does not contain a default export (imported as 'RBush'). #12191

Closed
DoHung1997 opened this issue Sep 12, 2024 · 5 comments
Labels
dependencies Relating to our package dependencies type - bug

Comments

@DoHung1997
Copy link

DoHung1997 commented Sep 12, 2024

./node_modules/@cesium/engine/Source/Core/RectangleCollisionChecker.js
Attempted import error: 'rbush' does not contain a default export (imported as 'RBush').

I have a problem when building cesium with nextjs. When I run "yarn build", it show this error

@ggetz
Copy link
Contributor

ggetz commented Sep 13, 2024

@jjspace Can you please take a look at this?

@jjspace
Copy link
Contributor

jjspace commented Sep 13, 2024

rbush is a dependency of engine. In the 1.120 update we updated this to v4.0.0 but that version switched to only support ES modules and dropped CommonJS. We publish CesiumJS to be used in both ESM and CommonJS projects. I think this just means that in your project it's trying to build as CommonJS and failing on that package.
I think that short term we have to lock that package to 3.0.1 and longer term maybe investigate replacing it. Thoughts @ggetz

@jjspace jjspace added dependencies Relating to our package dependencies and removed needs triage labels Sep 13, 2024
@ggetz
Copy link
Contributor

ggetz commented Sep 13, 2024

@jjspace I agree. Let's move ahead with the locked version.

How would you like to document the locked version? Maybe leave this issue open?

@jjspace
Copy link
Contributor

jjspace commented Sep 17, 2024

@DoHung1997 Short term you should be able to override the version of rbush in your package.json to avoid the build error (See this SO question). This will be pinned in the next release so you will be able to remove the override.

{
  "dependencies": {...},
  "devDependencies": {...},
  "overrides": {
    "@cesium/engine": {
      "rbush": "3.0.1"
    }
  }
}

How would you like to document the locked version? Maybe leave this issue open?

@ggetz That's fine, we can just leave this issue open and maybe rename it to match the other dependencies issues or make a new one (Edit, created #12203). I really wish we could add comments to package.json but that's apparently a discussion that's been shut down before so no luck there.

Down the rabbit hole

Just a collection of links I previously collected tumbling down the rabbit hole of finding out whether npm would support .jsonc or another alternative. Seems the answer is sadly a resounding "no" currently.

@DoHung1997
Copy link
Author

Greate! it worked correctly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Relating to our package dependencies type - bug
Projects
None yet
Development

No branches or pull requests

3 participants