Fix issues #42 #49 #51 #60 #61
Merged
Merged
Conversation
… consistency Co-authored-by: Copilot <copilot@github.com>
…expand_crate_path fixes : #51 Co-authored-by: Copilot <copilot@github.com>
…rom being tracked
… transformation - Introduced `error_tests.rs` to validate the display and source behavior of `BundlerError`. - Added `file_manager_tests.rs` to test file reading, existence checks, and module file finding. - Created `transformer_tests.rs` to cover various aspects of code transformation, including configuration defaults, attribute handling, and module expansion. Co-authored-by: Copilot <copilot@github.com>
…efault() for consistency
…als during minification Co-authored-by: Copilot <copilot@github.com>
…ruption during minification
This was
linked to
issues
May 12, 2026
Closed
There was a problem hiding this comment.
Pull request overview
This PR enhances CG-Bundler to inline direct external Cargo dependencies into the bundled output (addressing issues like “extern crates are not bundled”), improves robustness of crate path expansion, updates the crate to Rust edition 2024 / higher MSRV, and significantly expands test coverage (including new regression tests for reported issues).
Changes:
- Add
CargoProject::external_lib_pathsand wireBundler/CodeTransformerto inline referenced direct dependency libraries asmod <crate> { ... }. - Fix crate-path expansion edge case (single-segment path equal to crate name) and improve minification behavior (string/placeholder handling,
<-spacing regression). - Add/refactor extensive tests across bundler, transformer, file manager, cargo project, error handling, and CLI behaviors.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/cargo_project.rs |
Adds external dependency discovery (external_lib_paths) for inlining. |
src/bundler.rs |
Uses transformer constructor that receives external lib paths. |
src/transformer.rs |
Implements external dependency inlining into mod <name> { ... } blocks; refactors helpers; adjusts crate-path expansion. |
src/main.rs |
Updates minification logic (literal placeholdering + <- fix), improves watch output formatting, and adds broad CLI/unit tests. |
src/file_manager.rs |
Moves unit tests out of the module (now covered by integration tests). |
Cargo.toml |
Updates edition to 2024 and raises rust-version. |
.gitignore |
Ignores .vscode. |
tests/unit_tests.rs |
Refactors assertions/formatting and minor test improvements. |
tests/transformer_tests.rs |
New: focused transformer test suite (regressions + internal behaviors). |
tests/integration_tests.rs |
Adds regression test for issue #49 and refactors string building/formatting in tests. |
tests/file_manager_tests.rs |
New: FileManager test coverage moved to tests/. |
tests/error_tests.rs |
New: BundlerError display/source/from impl tests. |
tests/comprehensive_tests.rs |
Refactors test project generation and improves assertions/string building. |
tests/cli_tests.rs |
Refactors test project generation formatting. |
tests/cargo_project_tests.rs |
New: CargoProject behavior tests including external_lib_paths. |
tests/bundler_tests.rs |
New: Bundler API and basic bundle behavior tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Added `rustfmt_fmt.rs` for formatting Rust code using rustfmt with a fallback mechanism. - Introduced `test_support.rs` for shared test fixtures to create minimal Cargo projects. - Refactored `transformer.rs` by splitting functionality into dedicated modules: `docs.rs`, `expansion.rs`, and `visit_mut_impl.rs`. - Moved documentation-related functions to `docs.rs` for better organization. - Implemented external library expansion and module handling in `expansion.rs`. - Enhanced `visit_mut_impl.rs` to handle AST traversal and transformation. - Updated tests to ensure formatting and transformation functionalities work as expected.
|
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.



closes : #49 #51 #60 #42
This pull request introduces significant enhancements to support inlining direct external dependencies as modules, improves code clarity, and updates the Rust edition and minimum supported Rust version. The main changes add a mechanism to detect and inline external crate libraries directly into the bundled output, ensuring correct handling of crate paths and improving test coverage for edge cases. Several code quality improvements and test refactorings are also included.
External dependencies inlining:
external_lib_pathstoCargoProjectthat returns a mapping from each direct dependency's crate name to its library entry point path, excluding the root package and non-library dependencies. (src/cargo_project.rs)Bundlerto use the newCodeTransformer::with_external_libsconstructor, passing in the external library paths for inlining. (src/bundler.rs)CodeTransformerto support inlining external libraries asmod <name> { ... }blocks at the top of the bundled output, only for dependencies actually referenced in the code. (src/transformer.rs) [1] [2]Crate path handling and robustness:
expand_crate_pathto avoid stripping single-segment paths matching the crate name, preventing empty paths and related panics. Added a regression test for this scenario. (src/transformer.rs) [1] [2]CodeTransformerfor clearer Rust idioms and conciseness, such as usingif let ... && ...patterns. (src/transformer.rs)Rust edition and MSRV update:
"2024"and minimum supported Rust version to"1.91.0"inCargo.toml.Test and code quality improvements:
tests/cli_tests.rs,tests/comprehensive_tests.rs) [1] [2] [3]writeln!for string building and direct format string interpolation. (tests/comprehensive_tests.rs,tests/integration_tests.rs) [1] [2] [3] [4] [5]Minor improvements:
Bundler::set_configandCodeTransformer::with_external_libsconstwhere possible for improved API clarity. (src/bundler.rs,src/transformer.rs) [1] [2]src/main.rs)