convex-js PR 174: cli: fix codegen emitting OS-dependent module order (paths sorted before separator normalization) (#54376)
Fixes #173. Codegen sorts module paths in their OS-native form before the separators get normalized, so the generated api files come out in a different order on Windows than on macOS/Linux. Full writeup with the repro is in the issue. This adds `compareModulePaths` to `codegen_templates/common.ts`. It compares the forward slash normalized form of each path using plain code unit comparison. That is exactly the order these paths already sorted with on POSIX, so files generated on macOS/Linux come out byte for byte identical; Windows output now matches them. Applied at the three places that sorted native relative paths: - `doApiCodegen` in `src/cli/lib/codegen.ts` - `codegenDynamicApiObjects` and `codegenDynamicApiObjectsTS` in `src/cli/codegen_templates/component_api.ts` I went through the other sorts under `src/cli` and they all operate on separator-free strings (tool names, table names, identifiers, server-side component paths). `consistentPathSort` in the bundler sorts per-directory entry names, so that one is fine as is. One deliberate choice: I didn't reuse the existing `compareStrings` here because the collator's order differs from plain code unit order, and switching to it would reshuffle api files already committed by POSIX users. The point of this fix is to converge on the order most existing files already have. Testing: unit test on the comparator covering both separator forms of the repro trio, plus running codegen from source on Windows against a project containing `foo.ts` / `foo/bar.ts` / `fooBaz.ts` and confirming the generated `api.d.ts` imports and `fullApi` keys come out in POSIX order. Typecheck and lint pass. Co-authored-by: David Whatley <nsxdavid@gmail.com> GitOrigin-RevId: b29247708a769c4fdfb5d439063a0feeb702d3fa
N
Nicolas Ettlin committed
83ed0ffeb3f26e22fe164af152085e90bd8a6550
Parent: 15e9bdf
Committed by Convex, Inc. <no-reply@convex.dev>
on 7/13/2026, 9:25:23 PM