Skip to content

feat: add clean option to clear output path before bundling#30

Merged
xierenyuan merged 2 commits intomainfrom
feat/add-clean-option-before-bundle
Jul 25, 2025
Merged

feat: add clean option to clear output path before bundling#30
xierenyuan merged 2 commits intomainfrom
feat/add-clean-option-before-bundle

Conversation

@xierenyuan
Copy link
Contributor

@xierenyuan xierenyuan commented Jul 25, 2025

rt
close #29

Summary by CodeRabbit

  • New Features
    • Added automatic cleanup of output directories before building when the clean option is enabled.
  • Chores
    • Updated project configuration to ignore a new directory path in version control.

Copilot AI review requested due to automatic review settings July 25, 2025 05:59
@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

A conditional cleanup step was added to the build method in the BaseBundler class. When the clean option is enabled in build options, the output directories specified in each bundler configuration are synchronously deleted before the build process starts. No changes were made to public interfaces. Additionally, the .gitignore file in the examples/ant-pro directory was updated to ignore the .takumi/todos path.

Changes

File(s) Change Summary
packages/bundler-shared-config/src/provider/BaseBundler.ts Added logic to conditionally delete output directories using rimraf.sync when the clean option is true.
examples/ant-pro/.gitignore Added .takumi/todos entry to ignore this path from Git tracking.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A bunny with a broom, so neat,
Cleans up the dist before the feat.
No more files piling high,
As hashes change, old bits say bye.
With every build, a tidy start—
That’s the bunny’s favorite part! 🧹🐇

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a44de02 and bff07ea.

📒 Files selected for processing (2)
  • examples/ant-pro/.gitignore (1 hunks)
  • packages/bundler-shared-config/src/provider/BaseBundler.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/ant-pro/.gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bundler-shared-config/src/provider/BaseBundler.ts
⏰ 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)
  • GitHub Check: build-and-test (22.x, ubuntu-latest)
  • GitHub Check: build-and-test (22.x, windows-latest)
  • GitHub Check: Cursor Bugbot
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-clean-option-before-bundle

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 rimraf import 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)
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
let isFirstCompile = true

return new Promise((resolve, reject) => {
if (opts.clean) {
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df47361 and a44de02.

📒 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.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bugbot free trial expires on August 4, 2025
Learn more in the Cursor dashboard.

logger.verbose(
`[BaseBundler] Cleaning output directory: ${config.output.path} failed`,
)
}
Copy link

Choose a reason for hiding this comment

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

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.

Locations (1)

Fix in CursorFix in Web

.eslintcache

build
.takumi/todos
Copy link

Choose a reason for hiding this comment

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

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.

Locations (1)

Fix in CursorFix in Web

@xierenyuan xierenyuan merged commit 5b78029 into main Jul 25, 2025
5 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.

编译时不会自动删除dist目录,导致hash为true时文件不断增加

2 participants