Skip to content

--no-tree-shaking オプション追加#25

Merged
TwoSquirrels merged 7 commits into
mainfrom
fallback
Jul 7, 2026
Merged

--no-tree-shaking オプション追加#25
TwoSquirrels merged 7 commits into
mainfrom
fallback

Conversation

@TwoSquirrels

@TwoSquirrels TwoSquirrels commented Jun 12, 2026

Copy link
Copy Markdown
Owner

close #22

フォールバックが可能になります!

Summary by CodeRabbit

  • New Features

    • Added a new --no-tree-shaking option for bundling, letting you expand code without tree-shaking when needed.
    • You can now combine it with --keep, and the behavior difference is documented.
  • Documentation

    • Expanded the README, specification, and cheat sheet in both English and Japanese with clearer bundling guidance, fallback usage, and troubleshooting tips.
  • Tests

    • Added coverage for the new bundling behavior and updated existing CLI tests to use shared helpers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@TwoSquirrels, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91b55656-eb3a-4d18-bfb6-f925af30bed3

📥 Commits

Reviewing files that changed from the base of the PR and between 8983e36 and 85705fc.

📒 Files selected for processing (4)
  • README.ja.md
  • README.md
  • docs/cheatsheet.ja.md
  • docs/cheatsheet.md
📝 Walkthrough

Walkthrough

Adds a new --no-tree-shaking CLI flag to the bundle command that skips identifier-tag hash verification and dependency-header analysis, expanding all non-kept libraries without tree-shaking. Includes updated tests and documentation across README, cheatsheets (English/Japanese), and spec files.

Changes

No-tree-shaking fallback feature

Layer / File(s) Summary
CLI flag and bundle logic
src/cli.rs, src/commands/bundle.rs
Adds no_tree_shaking: bool to BundleArgs and updates run so inventory.verify() is skipped when --no-check or --no-tree-shaking is set, and forces the unused set to an empty BTreeSet instead of calling unused_origins(...) when --no-tree-shaking is enabled.
CLI test refactor and new coverage
tests/cli.rs
Introduces shared fixtures (used_and_unused_library, run_bundle, struct_defs), refactors existing bundle tests to use them, adds bundle_no_tree_shaking_keeps_unused_headers to verify unexpanded headers remain, and extends the library-change verification test with a --no-tree-shaking success assertion.
README option documentation
README.md, README.ja.md
Adds a --no-tree-shaking row to the bundling options table with clarifying text distinguishing it from --keep and noting they can be combined.
Cheatsheet documents
docs/cheatsheet.md, docs/cheatsheet.ja.md
Adds new task-oriented cheatsheets (English and Japanese) covering setup, submission, tuning with -k/-c/-e, a --no-tree-shaking fallback workflow, library maintenance, .risundlerc.toml usage, and troubleshooting.
Spec documentation
docs/spec.md, docs/spec.ja.md
Expands hash-verification wording to note --no-tree-shaking skips verification for all libraries, and adds a dedicated section describing skipped identifier/dependency analysis and non-configurability via .risundlerc.toml.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant BundleCommand
  participant Inventory
  User->>CLI: risundle bundle --no-tree-shaking
  CLI->>BundleCommand: run(args)
  alt no_tree_shaking or no_check
    BundleCommand->>BundleCommand: skip inventory.verify()
  else
    BundleCommand->>Inventory: verify()
  end
  alt no_tree_shaking
    BundleCommand->>BundleCommand: unused = empty set
  else
    BundleCommand->>BundleCommand: unused = unused_origins(...)
  end
  BundleCommand->>User: expanded output (all non-kept libraries)
Loading

Related issues: #22 (フォールバック機能) — implements a fallback option to disable tree-shaking and output fully expanded code when tree-shaken code fails to compile.

Suggested reviewers: TwoSquirrels

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #22 asks for a compile-check fallback after tree-shaking, but this PR only adds a flag that disables tree-shaking entirely. Implement post-tree-shaking compilation verification and, on failure, fall back to the pre-tree-shaking output.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: adding the --no-tree-shaking option.
Out of Scope Changes check ✅ Passed The changes stay focused on the new --no-tree-shaking option, its docs, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

TwoSquirrels and others added 5 commits July 7, 2026 09:14
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
識別子タグを使わないモードでは stale ハッシュ検証が不要であり、
フォールバック用途をエラーで妨げないようにする。あわせて CLI 専用の
tree_shaking を Settings から外し、config + CLI マージという構造体の
契約を保つ。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
- keep 指定ライブラリは --no-tree-shaking でも #include のまま残る旨を明記
- フォールバックレシピ: keep ライブラリには -I が必要な注意を追加、
  2>/dev/null をやめて g++ のエラーを見せ、誤診を防ぐ
- 英語版チートシートのクリップボード例に iconv 併記
- spec に --no-tree-shaking の挙動 (検証スキップ・設定ファイル非対応) を追記

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
@TwoSquirrels TwoSquirrels marked this pull request as ready for review July 7, 2026 00:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cheatsheet.ja.md`:
- Around line 94-113: The fallback check currently uses g++ with -fsyntax-only,
which only performs syntax/semantic validation and misses build failures that
happen during a real compile. Update the examples around risundle and the
bundle() helper to use the actual g++ compilation flow that matches normal build
behavior, and keep the --no-tree-shaking fallback tied to that real compile
result rather than syntax-only checking.

In `@docs/cheatsheet.md`:
- Around line 95-113: The fallback logic in the cheatsheet currently uses a
syntax-only check in the bundle() example, which may miss real build failures.
Replace the g++ -fsyntax-only verification with the same full compile command
your judge uses, and keep the || fallback to risundle --no-tree-shaking in the
shell recipe. Update the surrounding example text so it clearly reflects that
the check should mirror the actual build step rather than just syntax
validation.

In `@README.ja.md`:
- Around line 63-68: The `README.ja.md` options description for
`--no-tree-shaking` is missing its validation-skip behavior, so update the
`--no-tree-shaking` explanation in this section to explicitly state that it also
skips library update hash verification, not just tree-shaking. Keep the
surrounding `--keep` and `--embed` descriptions as-is, and adjust the note below
the table so the behavior of `--no-tree-shaking` is described consistently and
unambiguously.

In `@README.md`:
- Around line 63-68: Update the README section for the `--no-tree-shaking`
option to explicitly mention that it also skips the library-update hash
verification performed by the implementation. Keep the existing explanation of
tree-shaking behavior, and add a brief note near the `--no-tree-shaking`
description so readers know stale libraries are not rejected in this mode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 200d45ec-1d13-449e-975d-b94ab503a29f

📥 Commits

Reviewing files that changed from the base of the PR and between dcffdc1 and 8983e36.

📒 Files selected for processing (9)
  • README.ja.md
  • README.md
  • docs/cheatsheet.ja.md
  • docs/cheatsheet.md
  • docs/spec.ja.md
  • docs/spec.md
  • src/cli.rs
  • src/commands/bundle.rs
  • tests/cli.rs

Comment thread docs/cheatsheet.ja.md
Comment thread docs/cheatsheet.md
Comment thread README.ja.md Outdated
Comment thread README.md Outdated
- フォールバックレシピの検証をリンクまで通す実コンパイル (-o /dev/null) に
  変更し、定義消失時の undefined reference も検出できるようにする
- README に --no-tree-shaking がハッシュ検証も行わない旨を追記

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwiopnwyFnRbSUyNoFLWAZ
@TwoSquirrels TwoSquirrels merged commit bb697f4 into main Jul 7, 2026
9 checks passed
@TwoSquirrels TwoSquirrels deleted the fallback branch July 7, 2026 01:03
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.

フォールバック機能

1 participant