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

Fix for NodeJS with ESM modules #10694

Merged
merged 4 commits into from
Aug 22, 2022
Merged

Fix for NodeJS with ESM modules #10694

merged 4 commits into from
Aug 22, 2022

Conversation

ggetz
Copy link
Contributor

@ggetz ggetz commented Aug 16, 2022

Fixes #10684

NodeJS was failing to run ESM modules mainly because of a recent update to zip.js which requires TransformStream to be defined. Looks like the zip.js maintainer addressed this and suggests either locking to 2.4.x or adding a polyfill for TransformStream. Here, I've locked the package version.

To prevent related issues from going unnoticed in the future, I added a .mjs version of test.cjs, which is now run as part of CI.

In doing so, I also caught two other issues. One was a faulty import, and the other was the use of require in Resource.js. If I understand correctly, this is code that should only ever be executed in a NodeJS environment, and can be replaced with a dynamic import , satisfying both the ESM and CJS use cases.

@cesium-concierge
Copy link

Thanks for the pull request @ggetz!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.

Copy link
Contributor

@sanjeetsuhag sanjeetsuhag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, @ggetz. I just have a couple of things I wanted to clarify.

.travis.yml Show resolved Hide resolved
Source/Core/Resource.js Show resolved Hide resolved
@ggetz
Copy link
Contributor Author

ggetz commented Aug 22, 2022

Thanks @sanjeetsuhag! This should be ready for another look.

Copy link
Contributor

@sanjeetsuhag sanjeetsuhag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks @ggetz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cesium no longer works under Node.js when using ESM modules
3 participants