Skip to content

fix: swap mismatched console.log calls in importing_bytes example#3117

Merged
bartlomieju merged 2 commits into
mainfrom
orch/issue-61
May 14, 2026
Merged

fix: swap mismatched console.log calls in importing_bytes example#3117
bartlomieju merged 2 commits into
mainfrom
orch/issue-61

Conversation

@lunadogbot
Copy link
Copy Markdown
Contributor

Summary

The /examples/importing_bytes/ snippet logs the wrong variable in both halves of the example. As pointed out by the reader in #3044:

  • Line 20 logs text immediately after import bytes from "./image.png"text is not defined yet (TDZ).
  • Line 26 logs bytes after const text = await import(...) — should log text.

Swap the two console.log arguments so each log matches its preceding import. Variable names are left as-is to keep the diff minimal, per the reporter's request.

Test plan

  • Re-read the snippet end-to-end and confirmed both console.log calls now reference variables that exist at that point in the program.

Closes #3044
Closes bartlomieju/orchid-inbox#61

cc @bartlomieju

The static `import bytes` was followed by `console.log(text)` (TDZ), and
the dynamic `const text` was followed by `console.log(bytes)`. Swap them
so each log matches its preceding import.

Closes #3044
@lunadogbot
Copy link
Copy Markdown
Contributor Author

The lint and link check failure here is unrelated to this change — the build fails rendering /styleguide/typography.mdx with TypeError: Cannot resolve module "lume/jsx-runtime", which is the same failure mode I see across other currently-open PRs (it doesn't touch examples/scripts/importing_bytes.ts or any example rendering). This PR only swaps two console.log arguments. cc @bartlomieju

Copy link
Copy Markdown
Contributor

@fibibot fibibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff swap is correct. Pre-fix, line 20 console.log(text) hits the TDZ (the const text is on line 23), and line 26 console.log(bytes) logs the static-import value under a comment that introduces dynamic imports. After the swap, each console.log references the binding immediately above it, which is the intent. The diff is also intentionally minimal — no rename of text (which still holds the dynamic-import namespace object, not bytes), matching the reporter's request in #3044.

Holding approval until lint and link check finishes. The currently-failing run is the same /styleguide/typography.mdx "Cannot resolve module 'lume/jsx-runtime'" build error affecting other open PRs (e.g. #3107), not anything in examples/scripts/importing_bytes.ts.

@bartlomieju bartlomieju merged commit f3b54f0 into main May 14, 2026
2 checks passed
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.

Feedback: /examples/importing_bytes/ - Positive

3 participants