Currently, pub workspaces support inclusive glob patterns only. Workspace resolution effectively computes the union of all matched paths.
For example:
workspace:
# specify a package in a direct subdir of the root
- 'my-app'
# all packages in direct subdirs of packages/
- 'packages/*'
# all packages in subdirs of components/
- 'components/**'
# attempt to exclude packages inside test directories
- '!**/test/**' # ❌ Not supported
Negated patterns (!pattern) are not currently supported and are treated as literal glob strings rather than exclusions.
Proposal
Add support for negated glob patterns (!pattern) in the workspace: section of pubspec.yaml so workspace membership can explicitly exclude specific paths.
Proposed Resolution Semantics
Patterns would be evaluated in order:
-
Start with an empty workspace set.
-
For each pattern:
- Positive pattern → add matching directories.
- Negated pattern (
!pattern) → remove matching directories from the current set.
Example:
workspace:
- 'packages/*'
- '!packages/experimental'
This would include all packages under packages/ except packages/experimental.
Order would matter:
workspace:
- 'foo'
- '!foo'
- 'foo'
Final result: foo is included.
Negated patterns would only remove currently included workspace members; later positive patterns could add them again.
Reasoning
- Improves monorepo ergonomics
- Allows excluding test fixtures, experimental folders, or generated code
- Avoids forcing directory restructuring solely to satisfy workspace constraints
- Aligns with behavior in other workspace-based package managers
Currently,
pubworkspaces support inclusive glob patterns only. Workspace resolution effectively computes the union of all matched paths.For example:
Negated patterns (
!pattern) are not currently supported and are treated as literal glob strings rather than exclusions.Proposal
Add support for negated glob patterns (
!pattern) in theworkspace:section ofpubspec.yamlso workspace membership can explicitly exclude specific paths.Proposed Resolution Semantics
Patterns would be evaluated in order:
Start with an empty workspace set.
For each pattern:
!pattern) → remove matching directories from the current set.Example:
This would include all packages under
packages/exceptpackages/experimental.Order would matter:
Final result:
foois included.Negated patterns would only remove currently included workspace members; later positive patterns could add them again.
Reasoning