Skip to content

feat: add new onAfterDevCompile plugin hook#5882

Merged
chenjiahan merged 1 commit intomainfrom
after_dev_compile_0819
Aug 19, 2025
Merged

feat: add new onAfterDevCompile plugin hook#5882
chenjiahan merged 1 commit intomainfrom
after_dev_compile_0819

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented Aug 19, 2025

Summary

This PR adds a new onAfterDevCompile plugin hook to replace the previous onDevCompileDone hook.

import type { RsbuildPlugin } from '@rsbuild/core';

const myPlugin: RsbuildPlugin = {
  name: 'my-plugin',
  setup(api) {
    api.onBeforeDevCompile(() => {
      // ...
    });

    // The new hook
    api.onAfterDevCompile(() => {
      // ...
    });

    // The deprecated hook
    api.onDevCompileDone(() => {
      // ...
    });
  },
};

The intention of this change is to keep the naming of dev compile related hooks consistent, refer to #5788 (review)

The previous onDevCompileDone hook is still usable. I will explain the relationship between the two in the documentation after v1.5.0 is released.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 19, 2025 04:09
@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 19, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 64edd4b
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68a3f8fa849b67000843ad23
😎 Deploy Preview https://deploy-preview-5882--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67 (🔴 down 24 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
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 introduces a new onAfterDevCompile plugin hook to replace the existing onDevCompileDone hook for consistency in naming conventions. The previous hook remains available as a deprecated alias.

  • Adds new onAfterDevCompile hook with identical functionality to onDevCompileDone
  • Deprecates onDevCompileDone while maintaining backward compatibility as an alias
  • Updates all internal usage and tests to use the new hook name

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/types/plugin.ts Adds new hook type and updates documentation with deprecation notice
packages/core/src/types/hooks.ts Renames hook function type and updates comment references
packages/core/src/hooks.ts Replaces hook implementation and updates internal usage
packages/core/src/initPlugins.ts Maps new hook and creates alias for backward compatibility
packages/core/src/createRsbuild.ts Exposes new hook in RsbuildInstance interface
packages/core/src/server/devServer.ts Updates internal hook usage with comment
packages/core/src/index.ts Updates type exports
e2e/helper/jsApi.ts Updates test helper to use new hook
e2e/helper/utils.ts Adds new hook to test recorder and fixes naming inconsistencies
e2e/cases/rspack-profile/dev.mjs Updates example usage
e2e/cases/plugin-api/plugin-hooks/index.test.ts Updates test expectations
e2e/cases/plugin-api/plugin-hooks-environment/index.test.ts Updates test expectations and adds new hook
e2e/cases/output/manifest-environment/index.test.ts Updates test to use new hook
packages/core/tests/snapshots/hooks.test.ts.snap Updates test snapshot

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/src/types/rsbuild.ts
@chenjiahan chenjiahan requested a review from 9aoy August 19, 2025 04:11
Comment thread packages/core/src/hooks.ts
@chenjiahan chenjiahan merged commit 5474f64 into main Aug 19, 2025
14 checks passed
@chenjiahan chenjiahan deleted the after_dev_compile_0819 branch August 19, 2025 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants