feat: add js_openapi_schema macro#722
Open
agentydragon-agent wants to merge 3 commits intoagentydragon:develfrom
Open
feat: add js_openapi_schema macro#722agentydragon-agent wants to merge 3 commits intoagentydragon:develfrom
agentydragon-agent wants to merge 3 commits intoagentydragon:develfrom
Conversation
tools/js/openapi.bzl: new macro js_openapi_schema(name, generator, out) bundles the genrule + openapi-typescript binary + js_run_binary + js_library into a single call. Eliminates ~20 lines of boilerplate per frontend package. props/frontend/src/lib/BUILD.bazel: replace four rules across two files with js_openapi_schema(name = "schema", generator = "//props/backend:export_schema_bin") props/backend/BUILD.bazel: remove openapi_schema genrule (macro runs the binary directly, no intermediate target needed). props/frontend/BUILD.bazel: remove generate_schema_bin js_binary and openapi_schema_local genrule (both replaced by the macro). props/frontend/generate-schema.mjs: deleted (replaced by openapi-typescript CLI invoked directly via the npm package_json.bzl binary macro). https://claude.ai/code/session_01AVe4v8xDvXAH5hK6o9Yk81
My local sandbox had pnpm v6 which downgraded the lockfile format from 9.0 to 6.0. Since no new npm packages were added, revert to the original format so CI can resolve npm packages correctly. https://claude.ai/code/session_01AVe4v8xDvXAH5hK6o9Yk81
rules_js 2.9.2 defaults to pnpm 8.6.11 which cannot parse lockfileVersion 9 lockfiles. On every fresh CI run this triggers a non-hermetic regeneration via system pnpm, failing with "pnpm-lock.yaml file updated. Please run your build again." which kills the entire npm_ducktape repository. Fix: declare the pnpm extension with pnpm_version = "9.15.9" (+ integrity hash) and set use_pnpm on npm_translate_lock to point at the new @pnpm toolchain. The hermetic pnpm v9 can read the committed v9 lockfile without regenerating it, so the first Bazel run on CI succeeds. https://claude.ai/code/session_01AVe4v8xDvXAH5hK6o9Yk81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/js/openapi.bzlwith a newjs_openapi_schema(name, generator, out)macro that bundles the full OpenAPI → TypeScript type generation pipeline into a single Bazel callprops/frontend/src/lib/BUILD.bazelopenapi_schemagenrule fromprops/backend/BUILD.bazeland thegenerate_schema_binjs_binary +openapi_schema_localgenrule fromprops/frontend/BUILD.bazelprops/frontend/generate-schema.mjs(replaced by the openapi-typescript CLI invoked directly via npm package_json.bzl)Before (spread across
props/frontend/BUILD.bazelandprops/frontend/src/lib/BUILD.bazel):After (one line in
props/frontend/src/lib/BUILD.bazel):Test plan
bazel build //props/frontend/src/lib:schemabuilds successfullybazel build //props/frontend:bundlebuilds successfullyhttps://claude.ai/code/session_01AVe4v8xDvXAH5hK6o9Yk81