From ed052d0bde2600ab97325e4bbc280bba4729520c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tayfun=20Y=C4=B1lmaz?= Date: Mon, 10 Aug 2026 18:43:14 +0300 Subject: [PATCH] fix(csx): embed CSX into references that only declare a location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updateCodeInJson guarded every match with `'code' in obj`, so a script reference carrying only `location` (no pre-existing `code` key) was skipped entirely and the encoding logic below it never ran. The documented default — absent encoding means B64 — therefore only applied to references that already had a `code` field written into them at some earlier point. Dropping the guard lets the `code` key be created when it is missing. Encoding handling is unchanged: absent/B64 writes Base64, NAT writes the native source, and any other value (e.g. REF) is still left untouched, so REF references gain no `code` key. Co-Authored-By: Claude Opus 5 --- src/lib/csx.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/csx.js b/src/lib/csx.js index ef5a356..e6dce7e 100644 --- a/src/lib/csx.js +++ b/src/lib/csx.js @@ -122,8 +122,9 @@ async function updateCodeInJson(jsonPath, csxLocation, base64Code, nativeCode) { return; } - if (obj.location === csxLocation && 'code' in obj) { - // Encoding decides how the CSX content is embedded: + if (obj.location === csxLocation) { + // A reference may carry only `location` — the `code` key is then created + // here. Encoding decides how the CSX content is embedded: // absent / B64 -> Base64 (default) // NAT -> JSON-stringified native source // anything else (e.g. REF) -> leave untouched