-
-
Notifications
You must be signed in to change notification settings - Fork 183
feat(vue)!: separate include and exclude from api.options and add filter
#582
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6399fd4
feat(vue): add filter
sapphi-red 18470c6
chore: merge main
sapphi-red a7b2987
refactor: use exactRegex from @rolldown/pluginutils
sapphi-red 116eb35
feat!: separate include and exclude from api.options and pass them to…
sapphi-red 962d845
chore: remove unused import
sapphi-red File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export function exactRegex(input: string): RegExp { | ||
| return new RegExp(`^${escapeRegex(input)}$`) | ||
| } | ||
|
|
||
| const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g | ||
| function escapeRegex(str: string): string { | ||
| return str.replace(escapeRegexRE, '\\$&') | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To have this part of change, we need to introduce a breaking change.
The
filterhas to have a same value afterconfigResolvedhook is called (because the value is passed to rolldown and cannot be modified), but currentlyoptions.value.include/options.value.excludecan be changed in any time.I can revert this part for now so we can merge the other parts and make a separate PR if that's better.
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.
The same applies to other cases where
options.include/.excludeexists (e.g. in https://github.com/TheAlexLichter/unplugin-auto-import/blob/9c06cb618ca5fcabfe4ec1729e24eea2d87a48be/src/core/unplugin.ts#L20-L22)?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.
I think it doesn't apply to those cases.
In this plugin-vue's case,
options.valueis exposed viaapi, which is meant to be used to update theoption.value. So I think the contract here is that settingapi.optionswill update the option.On the other hand, in that
unplugin-auto-importcase, I think people won't expectoptions.includeto be modified after the plugin is instantiated. For example, the code below would do that, but I guess people won't expect this to work unless explicitly documented.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.
@sxzz What are your thoughts on this? (since you introduced this feature)
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.
Vue Macros is using this API to modify some options like
template.compilerOptions.Can we make
api.include/excludeas a getter/setter, linking totransform.filter?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.
Do you mean something like below?
Is it to make it clear that
include/excludecannot be updated afterconfigResolvedhook is called?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.
Yes, we can add a jsdoc
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.
@sxzz I've updated the PR 👍