You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the sortBareImports option that allows sorting all bare imports within other imports.
the kind group matcher (e.g., { "kind": "bare" }) that allows to group bare imports.
This requires to turn on sortBareImports, otherwise these matchers are useless.
They impose two limitations:
It is not possible to group a subset of bare imports.
For example, a user might want to group bare style imports only.
This can create some confusion if the user forgets to turn on sortBareImports and use bare import matchers.
This PR solves these two limitations by allowing to group bare imports matched by a bare import matcher without requiring to turn on sortBareImports.
Because import "./x.js" is not matched, it still acts as an import chunk breaker.
A limitation of this system is that it doesn't play well with the implicit group.
For example if we want to group bare style imports at the end, a user could think it is enough to write the following config:
{"groups": [// Note the negated kind using the exclamation mark `!`{"kind": "!bare","source": ":STYLE:"}]}
Unfortunately, it is not the case because the implicit group doesn't match explicitly bare imports.
Thus, the user has to write:
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
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
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.
Summary
We recently added two features:
sortBareImportsoption that allows sorting all bare imports within other imports.{ "kind": "bare" }) that allows to group bare imports.This requires to turn on
sortBareImports, otherwise these matchers are useless.They impose two limitations:
For example, a user might want to group bare style imports only.
sortBareImportsand use bare import matchers.This PR solves these two limitations by allowing to group bare imports matched by a bare import matcher without requiring to turn on
sortBareImports.Given the following config...
{ "groups": [ { "kind": "bare", "source": ":STYLE:" } ] }We get the following sorting:
Because
import "./x.js"is not matched, it still acts as an import chunk breaker.A limitation of this system is that it doesn't play well with the implicit group.
For example if we want to group bare style imports at the end, a user could think it is enough to write the following config:
Unfortunately, it is not the case because the implicit group doesn't match explicitly bare imports.
Thus, the user has to write:
{ "groups": [ { "kind": "!bare" }, { "kind": "bare", "source": ":STYLE:" } ] }Also, I took the opportunity to do some renaming to make the code easier to read.
Docs
TODO