-
-
Notifications
You must be signed in to change notification settings - Fork 376
fix: syncMode - default
: use append
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this 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 the syncMode: "default"
behavior to properly use append
strategy during development and overwrite
strategy during build. Previously, the default mode was incorrectly using overwrite
strategy when using the dev server.
- Introduces environment-based logic to determine the appropriate sync mode when
syncMode
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 or learn how to get started.
src/core/context.ts
Outdated
this._removeUnused = this.options.syncMode === 'overwrite' | ||
|
||
// syncMode - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build. | ||
const syncMode = this.options.syncMode === 'default' ? (process.env.NODE_ENV === 'development' ? 'append' : 'overwrite') : this.options.syncMode |
There was a problem hiding this comment.
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 like resolveSyncMode()
for better maintainability.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
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.
@xiaweiss IMO we should never relay on environment variables at this level. Development server being present does not mean running in Just have a look on previous implementation, it was using 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. |
…r, `overwrite` strategy when using build.
update: process.env.NODE_ENV has been deprecated, and replaced with the setupWatcher hook. |
fix: syncMode -
default
: useappend
strategy when using dev server,overwrite
strategy when using build.Description
Setting is:
syncMode: "default"
The
overwrite
was executed when using dev server.Updated: PR handles the
default
option within thesetupWatcher
hook, and dev-server usesappend
by default.The PR has added an environment variable check to handle the default behavior of "default".Relevant Pull Request
feat: introduce syncMode to control the behavior of generating files