Cesium will not load with requirejs

I’m trying to load Cesium with requirejs and I’m getting an error when Cesium is trying to require ‘long’ from GitHub - protobufjs/protobuf.js: Protocol Buffers for JavaScript & TypeScript.? I was googling the issue and I found some comments about a chrome release causing an issue with require.
Has anyone encountered this problem?
TIA, Scott

I simplified my code as much as possible and I’m getting the same results.

<script src='require.js'></script>
  <script> require( [ "Cesium" ], function( Cesium ) { 
      const cesiumWidget = new Cesium.Viewer('cesiumContainer');
    } ) 
  </script>


There’s a problem with long.js and using require.
Here’s the comment where long is trying to be loaded.

      /*!
       * protobuf.js v7.2.6 (c) 2016, daniel wirtz
       * compiled tue, 16 jan 2024 22:54:38 utc
       * licensed under the bsd-3-clause license
       * see: https://github.com/dcodeio/protobuf.js for details
       */

Scott

Chrome version: Version 131.0.6778.70 (Official Build) (64-bit)
Cesium 1.123
Require version: 2.3.7

Scott

Hi Scott,

Did you happen to have CesiumJS working with require in a previous version?

I ask because it looks like there have been issues with Protobuf.js use with RequireJS for a few years now.

We may be running into the same thing in Sandcastle as per this GitHub issue, but that hasn’t been a showstopping issue for us.

Thanks!
Gabby

Yes, our old component based system uses require, and that has worked in the past. That has been a long time ago, so we keep running into issues with require. I was able to get Cesium to load by loading the library globally before require was loaded. If require has been loaded then the issues with ‘long’ are still present. In the original simple example, I just removed require and loaded Cesium in a script tag.