Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: syncMode -default: useappend strategy when using dev serve…#887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
antfu merged 2 commits intounplugin:mainfromxiaweiss:sync-mode
Oct 19, 2025

Conversation

@xiaweiss
Copy link
Contributor

@xiaweissxiaweiss commentedSep 26, 2025
edited
Loading

fix: syncMode -default: useappend strategy when using dev server,overwrite strategy when using build.

Description

Setting is:syncMode: "default"

Theoverwrite was executed when using dev server.

Updated: PR handles thedefault option within thesetupWatcher hook, and dev-server usesappend by default.

// setupWatcher, setupViteServer, setupWatcherWebpacksetupWatcher(){this._removeUnused=this.options.syncMode==='overwrite'// ...}

The PR has added an environment variable check to handle the default behavior of "default".

// deprecatedconstsyncMode=this.options.syncMode==='default' ?(process.env.NODE_ENV==='development' ?'append' :'overwrite') :this.options.syncMode

Relevant Pull Request

feat: introduce syncMode to control the behavior of generating files

CopilotAI review requested due to automatic review settingsSeptember 26, 2025 07:06
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

Copy link

CopilotAI 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 fixes thesyncMode: "default" behavior to properly useappend strategy during development andoverwrite strategy during build. Previously, the default mode was incorrectly usingoverwrite strategy when using the dev server.

  • Introduces environment-based logic to determine the appropriate sync mode whensyncMode is set to"default"
  • Removes duplicate sync mode assignment that was overriding the intended behavior in dev server setup
  • Adds clarifying comment explaining the default behavior logic

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

this._removeUnused=this.options.syncMode==='overwrite'

// syncMode - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
constsyncMode=this.options.syncMode==='default' ?(process.env.NODE_ENV==='development' ?'append' :'overwrite') :this.options.syncMode

Choose a reason for hiding this comment

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

[nitpick] The ternary operator is nested and difficult to read. Consider extracting this logic into a separate method likeresolveSyncMode() for better maintainability.

Copilot uses AI. Check for mistakes.
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, I have fixed this issue and moved the logic to the options.ts file.

@kevinmarrec
Copy link
Contributor

@xiaweiss IMO we should never relay on environment variables at this level.

Development server being present does not mean running indevelopment environment, in this Vite Plugin we always relay on a Vite hook that give us the dev server to determine if we're running a dev server.

Just have a look on previous implementation, it was usingremoveUnused = !this.server

Therefore my opinion is that this changed may even break more use cases.

If there's a bug we should have first a look at a reproduction that show something breaking when upgrading the version.

I don't have more time for now to dive more in this, I'll let@antfu hopefully have a decision about what to do here.

@xiaweiss
Copy link
ContributorAuthor

@xiaweiss IMO we should never relay on environment variables at this level.

Development server being present does not mean running indevelopment environment, in this Vite Plugin we always relay on a Vite hook that give us the dev server to determine if we're running a dev server.

Just have a look on previous implementation, it was usingremoveUnused = !this.server

Therefore my opinion is that this changed may even break more use cases.

If there's a bug we should have first a look at a reproduction that show something breaking when upgrading the version.

I don't have more time for now to dive more in this, I'll let@antfu hopefully have a decision about what to do here.

Thank you very much for your feedback. I will further research and explore how to determine the status of the dev-server.

@xiaweiss
Copy link
ContributorAuthor

update: process.env.NODE_ENV has been deprecated, and replaced with the setupWatcher hook.

@pkg-pr-new
Copy link

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-vue-components@887

commit:51daa76

@antfuantfu merged commit5794591 intounplugin:mainOct 19, 2025
8 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@antfuantfuantfu approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@xiaweiss@kevinmarrec@antfu

[8]ページ先頭

©2009-2025 Movatter.jp