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

Cesium no longer works under Node.js when using ESM modules #10684

Closed
mramato opened this issue Aug 12, 2022 · 3 comments · Fixed by #10694
Closed

Cesium no longer works under Node.js when using ESM modules #10684

mramato opened this issue Aug 12, 2022 · 3 comments · Fixed by #10694

Comments

@mramato
Copy link
Contributor

mramato commented Aug 12, 2022

  1. Create a file called test.mjs with contents import { Cartographic } from "./Source/Cesium.js";
  2. Run node test.mjs
  3. It fails with the below callstack
$ node test.mjs 
file:///home/mamato/Git/CesiumGS/cesium/node_modules/@zip.js/zip.js/lib/core/streams/crc32-stream.js:33
class Crc32Stream extends TransformStream {
                          ^

ReferenceError: TransformStream is not defined
    at file:///home/mamato/Git/CesiumGS/cesium/node_modules/@zip.js/zip.js/lib/core/streams/crc32-stream.js:33:27
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

I did a little digging and it appears zip.js module released a new version in the past month that caused this. Pinning to an older version fixes the issue (need to experiment to find out the exact version). May be worth opening an issue with them to see what they have to say.

Once we address this, it would be good to add the test.mjs and run it as part of CI to avoid breaking ESM support in the future.

CC @ggetz

@ggetz
Copy link
Contributor

ggetz commented Aug 16, 2022

Thanks for the report @mramato! I opened a fix for this in #10694. Looks like the zip.js maintainer addressed this and suggests either locking to 2.4.x or adding a polyfill for TransformStream. I've locked it in the above PR.

@mramato
Copy link
Contributor Author

mramato commented Aug 22, 2022

Thanks @ggetz!

Should we write up another issue to undo the pinned npm version once the zip.js maintainer has a better fix on their end?

@ggetz
Copy link
Contributor

ggetz commented Aug 22, 2022

Opened #10712

@jjhembd jjhembd mentioned this issue Jan 31, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Issue/PR closed
Development

Successfully merging a pull request may close this issue.

2 participants