Skip to content

Conversation

@Nirvana-Jie
Copy link
Contributor

Description:
refactor: hmr

BREAKING CHANGE:
None

Related issue (if exists):
None

ErKeLost and others added 30 commits October 7, 2024 19:02
wumingliang and others added 19 commits April 10, 2025 00:27
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: ignore print fileSize in compile config file

* fix: ignore print fileSize in compile config file
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
fix: delete the map file when config is 'inilne' or 'all-inline'
* feat: resolver by resolve kind (#2154)

* feat: resolver by resolve kind

* fix: breaking change

* Version Packages (#2156)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: try fix ci linux gnu build (#2163)

* fix: resolve the relative path of projects (#2161)

* fix: resolve the relative path of projects

* Create js-plugin-sass.md

add changeset

---------

Co-authored-by: brightwu <1521488775@qq.com>

* Version Packages (#2164)

* Version Packages

* chore: remove ubuntu-20

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: brightwu <1521488775@qq.com>

* fix: tree shake issue when handling cross module top level variables … (#2166)

fix: tree shake issue when handling cross module top level variables writing

* Version Packages (#2167)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: handle Windows long path issue in base64_decode function (#2182)

* fix: handle Windows long path issue in base64_decode function

- Replace unwrap() with proper error handling in base64_decode
- Return safe string representation when base64 decode fails
- Fixes InvalidLength panic on Windows with long file paths
- Addresses issue where Farm crashes on Windows due to path length limits

* fix: address CoderabbitAI feedback - use decoded bytes for UTF-8 conversion

- Use decoded bytes instead of original input for UTF-8 lossy conversion
- This ensures we process the actual decoded data when UTF-8 conversion fails
- Addresses AI review feedback for more accurate error handling

---------

Co-authored-by: q1600822305 <q1600822305@noreply.gitcode.com>

* chore: resolve typo (#2185)

Co-authored-by: leo.kang <leo.kang@gooseott.com>

* fix(core): Add origin check to the HMR server (#2173)

* Add origin check to the HMR server

* Add type declarations

* Update ws.ts

* Add changeset

* Update changeset

* Fox format and use American English

* Fix format

* Fix format for real this time

* Hopefully for the last time, fix format

* Remove trailing spaces from some lines

---------

Co-authored-by: ADNY <66500121+ErKeLost@users.noreply.github.com>
Co-authored-by: brightwu <1521488775@qq.com>

* chore: update readme (#2187)

* chore: update readme

* fix: lint issue

* chore: test hmr host check (#2190)

* chore: test hmr host check

* fix: #2188 lazy compilation should respect publicPath

* fix: #2176  does not work

* fix: hmr origin check

* fix: hmr issue

* Version Packages (#2186)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: incorrect publicPath when isolating farm runtime (#2193)

* fix: incorrect publicPath when isolating farm runtime

* chore: lock cargo-xwin to 0.18.6

* fix: resolve extension compatible with . or direct file suffix (#2192)

* fix: resolve extension compatible with . or direct file suffix

* fix: resolve extension compatible with . or direct file suffix

* chore: update test

---------

Co-authored-by: brightwu <1521488775@qq.com>

* Version Packages (#2194)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: browser mode, resolve mainFiled without import kind (#2197)

* feat: browser mode, resolve mainFiled without import kind

* chore: add changefile

* Version Packages (#2198)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: support output.asciiOnly (#2200)

* chore: support output.asciiOnly

* fix: escape css unicode by padding 6 hex digits

* Version Packages (#2201)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: fully support concatenate modules

* chore: update test snapshot

* chore: fully support mangle exports

* feat: support library cjs

* feat: all rust test cases passed

* chore: all existing tests passed

* chore: add js plugins hooks tests

* fix: cjs require

* chore: all existing test cases passed

* fix: windows test

* fix: mangle exports panic

* fix: argo pro concatenate modules issue

* fix: clippy issue

---------

Co-authored-by: shulan <sshuang141@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: xiaoliyooo <73976311+18845778092@users.noreply.github.com>
Co-authored-by: 1600822305 <161661698+1600822305@users.noreply.github.com>
Co-authored-by: q1600822305 <q1600822305@noreply.gitcode.com>
Co-authored-by: 小康 <leokang2828@gmail.com>
Co-authored-by: leo.kang <leo.kang@gooseott.com>
Co-authored-by: Radman Siddiki <61620631+R4356th@users.noreply.github.com>
Co-authored-by: ADNY <66500121+ErKeLost@users.noreply.github.com>
Co-authored-by: wumingliang <wumingliang.9801@bytedance.com>
* feat: upgrade swc and rkyv

* fix: concatenate modules issues

* chore: update test snapshots

* fix: ci build

* chore: update napi-rs/cli of create farm pacakge

* fix: ci issues

* fix: ci issues

* fix: build without config file

* chore: all example build success

---------

Co-authored-by: wumingliang <wumingliang.9801@bytedance.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: concatenate module issues

* chore: remove setup zig

* chore: replace zig setup action

* fix: tree shake useless ident

* fix: reexport ident map are not removed when tree shaking

* fix: mangle exports issue

* fix: example build error

---------

Co-authored-by: wumingliang <wumingliang.9801@bytedance.com>
* feat: support ast merge sourcemap generation

* chore(refactor): custom moudle meta data

* chore: stash code

* chore: bundle adapting ast merge

* feat: bundle support merge sourceMap & comment

* fix: type issue

* chore: stash code

* feat: support dynamic input

* feat: refactor runtime

* chore: stash code

* chore: support dynamic entries bundle

* chore: support generate dynamic entry resource pots

* feat: full support dynamic entry

* chore: stash code

* chore: stash code

* chore: script entry example test passed

* feat: arco pro dev available

* feat: cache module metadata & cachable deserialize

* feat: improve cache api

* feat: write cache

* feat: combine cache item to files

* feat: conflict & clippy

* chore: stash code

* feat: stash code

* feat: use matedate api for plugin

* feat: improve matedata

* feat: improve cache write

* chore: remove not exists dependent

* feat: remove unnecessary code

* feat: optimize deserialize usage

* chore: ci pnpm version unified version

* fix: cspell & mangle_export test case fix

* fix: lint

---------

Co-authored-by: brightwu <1521488775@qq.com>
Co-authored-by: 苏向夜 <46275354+fu050409@users.noreply.github.com>
Co-authored-by: wumingliang <wumingliang.9801@bytedance.com>
* fix: windows ts test issue

* fix: plugin resolvePath normalize

* fix: windows example build

* fix: windows example build

* fix: publicPath

* fix: e2e test issues

* fix: tests

---------

Co-authored-by: wumingliang <wumingliang.9801@bytedance.com>
fix cache restore dead lock
@changeset-bot
Copy link

changeset-bot bot commented Aug 21, 2025

🦋 Changeset detected

Latest commit: 9835a25

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "farm-docs" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "bench" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@coderabbitai
Copy link

coderabbitai bot commented Aug 21, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/hmr

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@Nirvana-Jie Nirvana-Jie force-pushed the refactor/hmr branch 2 times, most recently from be2db7a to 60fadbd Compare August 22, 2025 03:11
@Nirvana-Jie Nirvana-Jie requested a review from Copilot August 22, 2025 09:00
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 refactors the HMR (Hot Module Replacement) system by breaking down the monolithic HmrEngine class into specialized components for better separation of concerns.

  • Splits HMR functionality into coordinator, broadcaster, and error handler components
  • Introduces an update queue system with priority and deduplication support
  • Improves error handling and retry mechanisms for HMR operations

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/core/src/server/index.ts Reorders HMR engine initialization to occur after websocket server setup
packages/core/src/server/hmr/updateQueue.ts Adds new update queue management with batching and priority support
packages/core/src/server/hmr/index.ts Provides exports for the new HMR module components
packages/core/src/server/hmr/hmrErrorHandler.ts Implements centralized error handling with retry logic and error history
packages/core/src/server/hmr/hmrCoordinator.ts Coordinates HMR update process with queue management and compilation
packages/core/src/server/hmr/hmrBroadcaster.ts Handles broadcasting update messages to WebSocket clients
packages/core/src/server/hmr-engine.ts Refactored to use the new component-based architecture
.changeset/spicy-kings-shave.md Adds changeset entry for the HMR refactoring

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

@wre232114 wre232114 changed the base branch from v2-dev to main August 30, 2025 15:00
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.

9 participants