feat: add clean option to clear output path before bundling#30
feat: add clean option to clear output path before bundling#30xierenyuan merged 2 commits intomainfrom
Conversation
WalkthroughA conditional cleanup step was added to the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BaseBundler
participant rimraf
Caller->>BaseBundler: build(options)
alt options.clean is true
loop for each bundler config
BaseBundler->>rimraf: sync(config.output.path)
end
end
BaseBundler->>BaseBundler: create compiler and continue build
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a clean option to the bundler configuration that clears the output path before bundling starts. This addresses issue #29 by providing users with a way to ensure clean builds by removing previous build artifacts.
- Adds
rimrafimport to handle directory deletion - Implements clean functionality that removes output directories when the clean option is enabled
| if (opts.clean) { | ||
| bundlerConfigs.forEach((config) => { | ||
| if (config.output?.path) { | ||
| rimraf.sync(config.output.path) |
There was a problem hiding this comment.
Using rimraf.sync() for file deletion is blocking and can cause performance issues. Consider using the asynchronous version rimraf() with await to avoid blocking the event loop during potentially long directory deletion operations.
| let isFirstCompile = true | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| if (opts.clean) { |
There was a problem hiding this comment.
The clean option should be validated to ensure it's a boolean type. Without type checking, unexpected values could cause runtime errors or unexpected behavior.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/bundler-shared-config/src/provider/BaseBundler.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-and-test (22.x, windows-latest)
- GitHub Check: build-and-test (22.x, ubuntu-latest)
🔇 Additional comments (1)
packages/bundler-shared-config/src/provider/BaseBundler.ts (1)
8-8: LGTM!The rimraf import is properly added alongside the existing logger import from the shared package.
There was a problem hiding this comment.
Bugbot free trial expires on August 4, 2025
Learn more in the Cursor dashboard.
| logger.verbose( | ||
| `[BaseBundler] Cleaning output directory: ${config.output.path} failed`, | ||
| ) | ||
| } |
There was a problem hiding this comment.
Bug: Error Logging Missing in Directory Cleanup
When cleaning the output directory fails, the catch block logs a generic failure message without including the actual error details. This omission makes debugging difficult as the root cause of the cleaning failure is not logged. The error variable should be included in the log message.
| .eslintcache | ||
|
|
||
| build | ||
| .takumi/todos |
There was a problem hiding this comment.
Bug: Gitignore Includes Personal Todo File
The .takumi/todos file was accidentally added to .gitignore. This appears to be personal/temporary content unrelated to the main feature.
rt
close #29
Summary by CodeRabbit