Repository navigation
fix(freshness): bundle-fallback for renderDirectivesAsText import (unblocks CI + CF runtime) - #3029
Merged
Merged
Conversation
…blocks CI + CF runtime) - Add parsers/directives.ts entry to scripts/bundle-shared.cjs → outputs srv/lib/_shared/parsers.bundle.mjs (gitignored, generated by prebuild:shared-bundle) - Replace static top-level import in srv/lib/freshness-detector.js with a lazy try/catch inside detectFreshness(): workspace path first (dev/CI), _shared/parsers.bundle.mjs fallback (CF runtime where scripts/ is absent)
This was referenced Nov 6, 2026
Merged
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.
What & why
Fixes a runtime-import bug introduced by the directive-grammar foundation (#3021) that is currently failing the
unitCI job on every open fan-out PR (#3024–#3028) and would also break at CF runtime.srv/lib/freshness-detector.jsstatically imported../../scripts/parsers/directives.jsforrenderDirectivesAsText. Onlydirectives.tsexists on disk, so:test/unit/freshness-actions.test.jsboots a real CAP HTTP server; Node's native ESM loader resolves the static import outside Vitest's transform and throwsERR_MODULE_NOT_FOUND. This landed on DEV with feat(directives): generic tutorial directive grammar foundation (openspec: tutorial-directive-grammar) #3021 and every PR's merge-ref CI inherits it.cds build --productioncopies onlysrv/intogen/srv/—scripts/parsers/is never included, so the import would fail in production too.Fix
Adopts the repo's existing workspace-first / bundle-fallback pattern (same as
srv/lib/tutorial-step-slicer.js):scripts/bundle-shared.cjs— add aparsers.bundle.mjstarget (direct file-path entry, sincescripts/parsersisn't a workspace package) to the maintargetsarray only →srv/lib/_shared/parsers.bundle.mjs. (Not added to QA/MCP target arrays —freshness-detector.jsis only used by thesrvapp.)srv/lib/freshness-detector.js— replace the static top-level import with a lazyawait import()inside the already-asyncdetectFreshness(): try the workspace../../scripts/parsers/directives.js(resolves in dev/test), catch to./_shared/parsers.bundle.mjs(generated at build, present ingen/srv/on CF).The generated bundle is not committed —
srv/lib/_shared/is gitignored andprebuild:shared-bundleregenerates it beforecds build(same as the existing*.bundle.mjs). Verified:prebuild→prebuild:shared-bundlefires beforebuild:cds.How tested
npx vitest run test/unit/freshness-actions.test.js→ 3/3 passnpx vitest run test/unit/freshness-detector.test.js→ 3/3 passprebuild:shared-bundleruns in the CF build chain beforecds build --production, soparsers.bundle.mjsexists ingen/srv/srv/lib/_shared/at runtime.Type of change
Deploy scope
srv/**,scripts/**) — no content, no UI.Notes for reviewers
packages/mcp/tutorial-step-slicer.jshas the samerenderDirectivesAsTextstatic import; its unit path is masked today (bundle fallback +KG_STEP_SLICER_ENABLEDfalsy), but it would hit the same CF-runtime failure when that flag is on. Flagged for a follow-up PR.Checklist
DEVcds.ql/CQL only (no raw SQL) — n/a, no DB change