Skip to content

Enhance LookupByPath, Fix win32 paths in webpack-workspace-resolve-plugin #5050

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 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/lookup-by-path",
"comment": "Update all methods to accept optional override delimiters. Add `size`, `entries(), `get()`, `has()`, `removeItem()`. Make class iterable.\nExplicitly exclude `undefined` and `null` from the allowed types for the type parameter `TItem`.",
"type": "minor"
}
],
"packageName": "@rushstack/lookup-by-path"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/webpack-workspace-resolve-plugin",
"comment": "Fix a bug with path handling on Windows. Tap hooks earlier to ensure that these plugins run before builtin behavior.",
"type": "patch"
}
],
"packageName": "@rushstack/webpack-workspace-resolve-plugin"
}
32 changes: 22 additions & 10 deletions common/reviews/api/lookup-by-path.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,43 @@
```ts

// @beta
export interface IPrefixMatch<TItem> {
export interface IPrefixMatch<TItem extends {}> {
index: number;
lastMatch?: IPrefixMatch<TItem>;
value: TItem;
}

// @beta
export interface IReadonlyLookupByPath<TItem> {
findChildPath(childPath: string): TItem | undefined;
export interface IReadonlyLookupByPath<TItem extends {}> extends Iterable<[string, TItem]> {
[Symbol.iterator](query?: string, delimiter?: string): IterableIterator<[string, TItem]>;
entries(query?: string, delimiter?: string): IterableIterator<[string, TItem]>;
findChildPath(childPath: string, delimiter?: string): TItem | undefined;
findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;
findLongestPrefixMatch(query: string): IPrefixMatch<TItem> | undefined;
groupByChild<TInfo>(infoByPath: Map<string, TInfo>): Map<TItem, Map<string, TInfo>>;
findLongestPrefixMatch(query: string, delimiter?: string): IPrefixMatch<TItem> | undefined;
get(query: string, delimiter?: string): TItem | undefined;
groupByChild<TInfo>(infoByPath: Map<string, TInfo>, delimiter?: string): Map<TItem, Map<string, TInfo>>;
has(query: string, delimiter?: string): boolean;
get size(): number;
}

// @beta
export class LookupByPath<TItem> implements IReadonlyLookupByPath<TItem> {
export class LookupByPath<TItem extends {}> implements IReadonlyLookupByPath<TItem> {
[Symbol.iterator](query?: string, delimiter?: string): IterableIterator<[string, TItem]>;
constructor(entries?: Iterable<[string, TItem]>, delimiter?: string);
clear(): this;
deleteItem(query: string, delimeter?: string): boolean;
readonly delimiter: string;
findChildPath(childPath: string): TItem | undefined;
entries(query?: string, delimiter?: string): IterableIterator<[string, TItem]>;
findChildPath(childPath: string, delimiter?: string): TItem | undefined;
findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;
findLongestPrefixMatch(query: string): IPrefixMatch<TItem> | undefined;
groupByChild<TInfo>(infoByPath: Map<string, TInfo>): Map<TItem, Map<string, TInfo>>;
findLongestPrefixMatch(query: string, delimiter?: string): IPrefixMatch<TItem> | undefined;
get(key: string, delimiter?: string): TItem | undefined;
groupByChild<TInfo>(infoByPath: Map<string, TInfo>, delimiter?: string): Map<TItem, Map<string, TInfo>>;
has(key: string, delimiter?: string): boolean;
static iteratePathSegments(serializedPath: string, delimiter?: string): Iterable<string>;
setItem(serializedPath: string, value: TItem): this;
setItem(serializedPath: string, value: TItem, delimiter?: string): this;
setItemFromSegments(pathSegments: Iterable<string>, value: TItem): this;
get size(): number;
}

```
Loading
Loading