Skip to content

Update npm packages #12591

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

Merged
merged 3 commits into from
Apr 30, 2025
Merged

Update npm packages #12591

merged 3 commits into from
Apr 30, 2025

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented Apr 29, 2025

Description

npm outdated:

Package  Current  Wanted  Latest  Location              Depended by
express   4.21.2  4.21.2   5.1.0  node_modules/express  cesium
jsdoc     3.6.11  3.6.11   4.0.4  node_modules/jsdoc    cesium
lerc       2.0.0   2.0.0   4.0.4  node_modules/lerc     engine@npm:@cesium/[email protected]
rbush      3.0.1   3.0.1   4.0.1  node_modules/rbush    engine@npm:@cesium/[email protected]

Express switched the @latest version to v5. This came with the major changes from v4 -> v5, migration guide. Our server is fairly minimal so it didn't need that many changes. I believe I got them all.

  • express.static.mime no longer exists. They say to switch to mime-types but that does not have the .define() we were using.
    • Switched to a custom middleware function instead
  • wildcards in paths must now be named per the new path matching syntax
    • Switched some routes to regular expressions instead where the wildcard param was not used
    • Switched the proxy wildcard to a named param and updated handlers

Issue number and link

No issue, part of release prep

Testing plan

mime type test script

async function checkContentType(route) {
  const request = await fetch(route);
  return request.headers.get("Content-Type");
}

const testUrls = {
  "http://localhost:8080/Apps/SampleData/simple.czml": "application/json",
  "http://localhost:8080/Apps/SampleData/population909500.json":
    "application/json",
  "http://localhost:8080/Apps/SampleData/simplestyles.geojson":
    "application/json",
  "http://localhost:8080/Apps/SampleData/ne_10m_us_states.topojson":
    "application/json",
  "http://localhost:8080/Build/CesiumUnminified/ThirdParty/basis_transcoder.wasm":
    "application/wasm",
  "http://localhost:8080/Apps/Sandcastle/images/Cesium_Logo_ETC1S.ktx2":
    "image/ktx2",
  "http://localhost:8080/Apps/SampleData/models/BoxUnlit/BoxUnlit.gltf":
    "model/gltf+json",
  // "bgltf": 'unknown', // unknown
  "http://localhost:8080/Apps/SampleData/models/Pawns/Pawns.glb":
    "model/gltf-binary",
  "http://localhost:8080/Apps/SampleData/Cesium3DTiles/Tilesets/Tileset/ll.b3dm":
    "application/octet-stream",
  "http://localhost:8080/Apps/SampleData/Cesium3DTiles/PointCloud/PointCloudTimeDynamic/0.pnts":
    "application/octet-stream",
  "http://localhost:8080/Apps/SampleData/Cesium3DTiles/Instanced/InstancedOrientation/instancedOrientation.i3dm":
    "application/octet-stream",
  "http://localhost:8080/Apps/SampleData/Cesium3DTiles/Composite/Composite/composite.cmpt":
    "application/octet-stream",
  "http://localhost:8080/Apps/SampleData/Cesium3DTiles/Classification/PointCloud/content.geom":
    "application/octet-stream",
  "http://localhost:8080/Specs/Data/Cesium3DTiles/Vector/VectorTilePoints/parent.vctr":
    "application/octet-stream",
  "http://localhost:8080/packages/engine/Source/Shaders/Builtin/Functions/clipPolygons.glsl":
    "text/plain",
};

async function main() {
  for (const [url, expected] of Object.entries(testUrls)) {
    const type = await checkContentType(url);
    const matches = type?.startsWith(expected);
    console.log(matches, url);
    if (!matches) {
      console.log(`Expected: ${expected}, got: ${type}`);
    }
  }
}

main().catch((error) => {
  console.error("Something went wrong");
  console.error(error.message);
});

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@jjspace jjspace requested a review from ggetz April 29, 2025 17:51
Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Apr 30, 2025

Thanks @jjspace! I tweaked the regexes to more closely match the "express-like" patterns I saw in the docs. This simplified and added clarity IMO.

  • Remove the wildcard entirely where it was not need— e.g. "/Build/Specs" matches all paths containing /Build/Specs, so "/Build/Specs/*" is (and was) redundant
  • Provided more specific routes where knew the pattern— e.g. /Build/CesiumUnminified/index.js{.map} to match both the js file and its source map
  • Used app.param and a named param for the proxy route (:remote)

@ggetz
Copy link
Contributor

ggetz commented Apr 30, 2025

I tested out the updated routes and mime type handling. Everything appears to be working great!

@ggetz ggetz added this pull request to the merge queue Apr 30, 2025
Merged via the queue into main with commit 4651643 Apr 30, 2025
9 checks passed
@ggetz ggetz deleted the update-npm-packages branch April 30, 2025 19:53
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.

2 participants