Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only include files when packaging bevy, rather than excluding #18571

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LikeLakers2
Copy link
Contributor

@LikeLakers2 LikeLakers2 commented Mar 27, 2025

Objective

Reduce the size of .crate files generated by cargo package or cargo publish for the bevy package.

Solution

Change what files are included in a .crate file, by only including necessary folders and files, rather than excluding a few specific folders and keeping the rest.

As a result of this change, several files and folders are no longer included in the generated .crate files:

  • .cargo/ - Only contains config_fast_builds.toml, which does nothing unless renamed to config.toml
  • docs-template/ - Only used for generating documentation
  • working-migration-guides/, working-release-notes/ - These are only relevant for building up documentation that will be released alongside 0.16 proper.
  • .gitattributes, .gitignore - Only used for the repo, and have no effect on how Cargo handles the package
  • clippy.toml, deny.toml, rustfmt.toml, typos.toml - Only relevant when developing Bevy
  • CODE_OF_CONDUCT.md, CONTRIBUTING.md, CREDITS.md - Only relevant in their latest form as contained on the repo (so there's not much point to packaging these up, since they can quickly become outdated)

Testing

This change was tested following these steps:

  1. Run cargo package at the root of the repo
  2. Rename the resulting .crate file so it isn't overwritten later
  3. Insert the changes from this PR into /Cargo.toml
  4. Run cargo package at the root of the repo
  5. Compare the resulting .crate file sizes

I performed my testing on Windows 10 22H2, with Rust 1.85.1, using commit 0d90da8. Only one change was made from this commit that was unrelated to testing: The removal of an instance of "bevy_internal/bevy_anti_aliasing" from /Cargo.toml. This was done because Cargo would complain about the use of a non-existent feature otherwise - I do not believe it affects the results in any major way.

@IQuick143 IQuick143 added A-Cross-Cutting Impacts the entire engine D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 27, 2025
@mockersf
Copy link
Member

Can you keep the tests and examples as included? They are used as compilation tests front the crates, and examples are used when building docs on docs.rs

@LikeLakers2
Copy link
Contributor Author

LikeLakers2 commented Mar 27, 2025

@mockersf Done.

I will admit, I'm a little bothered by how this brings the resulting file size back up to nearly 600 KB. It's not so bad since it's only downloaded once by Cargo, and I understand the examples are used by the docs, but it still feels... weird to me.

@LikeLakers2 LikeLakers2 changed the title Reduce bevy's packaged size by only including files, rather than excluding Only include files when packaging bevy, rather than excluding Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants