Skip to content

Upgrade FlatBuffers from 24.3.25 to 25.9.23#7360

Merged
DennisOSRM merged 3 commits intomasterfrom
copilot/upgrade-flatbuffers-to-25-9-23
Feb 19, 2026
Merged

Upgrade FlatBuffers from 24.3.25 to 25.9.23#7360
DennisOSRM merged 3 commits intomasterfrom
copilot/upgrade-flatbuffers-to-25-9-23

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

FlatBuffers 25.x removed the --js code generator. JavaScript bindings now require TypeScript generation followed by transpilation.

Changes

  • Version references: Updated scripts/update_dependencies.sh and third_party/flatbuffers/ to v25.9.23

  • C++ headers: Regenerated generated/include/engine/api/flatbuffers/*.h with flatc 25.9.23. Version assertions now check for 25.9.23.

  • JavaScript generation workflow (new approach):

    # Generate TypeScript from schemas
    flatc --ts --ts-flat-files -o /tmp/output include/engine/api/flatbuffers/fbresult.fbs
    
    # Bundle to JavaScript with esbuild
    esbuild /tmp/output/osrm/engine/api/fbresult.ts --format=esm --bundle --external:flatbuffers

    The bundled output is wrapped to maintain the existing osrm.engine.api.fbresult.* namespace for backward compatibility with existing test code.

  • Result: features/support/fbresult_generated.js reduced from 3,971 to 1,419 lines while preserving identical API surface.

Original prompt

This section details on the original issue you should resolve

<issue_title>Upgrade FlatBuffers from 24.3.25 to 25.9.23</issue_title>
<issue_description>OSRM currently uses FlatBuffers 24.3.25 (released March 2024) while the latest version is 25.9.23 (released September 2025).

The main challenge of the upgrading is that flatc compiler does not support Javascript anymore, so we have to use "flatc --ts" and then transpile to Javascript</issue_description>

<agent_instructions>Upgrade the dependency, but note that only a subset of the files are actually here. Pick the right directory to copy to minimise churn.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 16, 2026 16:35
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
…bility

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade FlatBuffers from 24.3.25 to 25.9.23 Upgrade FlatBuffers from 24.3.25 to 25.9.23 Feb 16, 2026
Copilot AI requested a review from DennisOSRM February 16, 2026 16:43
@DennisOSRM DennisOSRM marked this pull request as ready for review February 16, 2026 19:22
@DennisOSRM
Copy link
Copy Markdown
Collaborator

@copilot Check if the typescript can be used directly without transpiling.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 16, 2026

@copilot Check if the typescript can be used directly without transpiling.

TypeScript cannot be used directly without transpilation for the following reasons:

  1. Import resolution issue: The FlatBuffers TypeScript generator (flatc --ts) outputs files with .js extensions in import statements (e.g., import { Error } from './error.js'). This is standard TypeScript practice for ESM compatibility, but Node.js's --experimental-strip-types flag doesn't resolve .js imports to .ts files.

  2. Generated code structure: The TypeScript files have inter-dependencies using those .js imports. Modifying these would require patching all generated files after each generation, which is brittle and error-prone.

  3. Runtime requirements: Using TypeScript directly would require either:

    • Modifying the generated imports (breaks on regeneration)
    • Adding runtime tools like tsx or ts-node (new dependencies)
    • Using experimental Node.js flags (not production-ready)

The current transpilation approach using esbuild is optimal because:

  • It's a one-time build step
  • Produces clean, dependency-free JavaScript
  • The output is 65% smaller (1,419 vs 3,971 lines)
  • No runtime overhead or experimental flags needed
  • Works identically to the previous version

@DennisOSRM DennisOSRM merged commit 8a125eb into master Feb 19, 2026
20 checks passed
@DennisOSRM DennisOSRM deleted the copilot/upgrade-flatbuffers-to-25-9-23 branch February 19, 2026 11:34
MarcelloPerathoner pushed a commit to MarcelloPerathoner/osrm-backend that referenced this pull request Feb 24, 2026
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.

Upgrade FlatBuffers from 24.3.25 to 25.9.23

2 participants