@boundaries/elements 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -0
- package/dist/index.browser.d.mts +68 -13
- package/dist/index.browser.d.ts +68 -13
- package/dist/index.browser.js +153 -54
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +153 -54
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +68 -13
- package/dist/index.d.ts +68 -13
- package/dist/index.js +153 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
* Type representing a micromatch pattern, which can be a string or an array of strings.
|
|
3
3
|
*/
|
|
4
4
|
type MicromatchPattern = string | string[];
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for categorizing dependencies as external or local.
|
|
7
|
+
*/
|
|
8
|
+
type FlagAsExternalOptions = {
|
|
9
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external (default: true) */
|
|
10
|
+
unresolvableAlias?: boolean;
|
|
11
|
+
/** When true, non-relative paths that include node_modules are categorized as external (default: true) */
|
|
12
|
+
inNodeModules?: boolean;
|
|
13
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external (default: false) */
|
|
14
|
+
outsideRootPath?: boolean;
|
|
15
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external (default: []) */
|
|
16
|
+
customSourcePatterns?: string[];
|
|
17
|
+
};
|
|
5
18
|
/** Configuration options for the Config class */
|
|
6
19
|
type ConfigOptions = {
|
|
7
20
|
/** An array of path patterns to include when resolving elements. Defaults to all files if not specified */
|
|
@@ -15,15 +28,33 @@ type ConfigOptions = {
|
|
|
15
28
|
legacyTemplates?: boolean;
|
|
16
29
|
/** Whether to enable caching */
|
|
17
30
|
cache?: boolean;
|
|
31
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
32
|
+
flagAsExternal?: FlagAsExternalOptions;
|
|
33
|
+
/** Root path of the project, used for determining if dependencies are outside the project */
|
|
34
|
+
rootPath?: string;
|
|
35
|
+
};
|
|
36
|
+
type FlagAsExternalOptionsNormalized = {
|
|
37
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external */
|
|
38
|
+
unresolvableAlias: boolean;
|
|
39
|
+
/** When true, non-relative paths that include node_modules are categorized as external */
|
|
40
|
+
inNodeModules: boolean;
|
|
41
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external */
|
|
42
|
+
outsideRootPath: boolean;
|
|
43
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external */
|
|
44
|
+
customSourcePatterns: string[];
|
|
18
45
|
};
|
|
19
|
-
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache"> & {
|
|
46
|
+
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache" | "flagAsExternal"> & {
|
|
20
47
|
/** Whether to enable legacy template support */
|
|
21
48
|
legacyTemplates: boolean;
|
|
22
49
|
/** Cache configuration options */
|
|
23
50
|
cache: boolean;
|
|
51
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
52
|
+
flagAsExternal: FlagAsExternalOptionsNormalized;
|
|
53
|
+
/** Root path of the project, already normalized, and finishing with a slash, used for determining if dependencies are outside the project */
|
|
54
|
+
rootPath: string | undefined;
|
|
24
55
|
};
|
|
25
56
|
/** Options for descriptors */
|
|
26
|
-
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache">;
|
|
57
|
+
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache" | "flagAsExternal" | "rootPath">;
|
|
27
58
|
/** Options for element matchers */
|
|
28
59
|
type MatchersOptionsNormalized = Pick<ConfigOptionsNormalized, "legacyTemplates">;
|
|
29
60
|
|
|
@@ -1544,14 +1575,37 @@ declare class ElementsDescriptor {
|
|
|
1544
1575
|
* @returns The base source of the external module. (e.g., for "@scope/package/submodule", it returns "@scope/package")
|
|
1545
1576
|
*/
|
|
1546
1577
|
private _getExternalOrCoreModuleBaseSource;
|
|
1578
|
+
/**
|
|
1579
|
+
* Determines if a file path is outside the configured root path.
|
|
1580
|
+
* @param filePath The file path to check.
|
|
1581
|
+
* @returns True if the file path is outside the root path, false otherwise.
|
|
1582
|
+
*/
|
|
1583
|
+
private _isOutsideRootPath;
|
|
1584
|
+
/**
|
|
1585
|
+
* Converts an absolute file path to a relative path if rootPath is configured.
|
|
1586
|
+
* If rootPath is not configured, returns the path as-is (maintains backward compatibility).
|
|
1587
|
+
* @param filePath The file path to convert (can be absolute or relative)
|
|
1588
|
+
* @returns The relative path if rootPath is configured and path is absolute, otherwise the original path
|
|
1589
|
+
*/
|
|
1590
|
+
private _toRelativePath;
|
|
1591
|
+
/**
|
|
1592
|
+
* Checks if a source string matches any of the provided patterns using micromatch.
|
|
1593
|
+
* @param patterns - Array of micromatch patterns
|
|
1594
|
+
* @param source - The source string to match against patterns
|
|
1595
|
+
* @returns True if the source matches any pattern, false otherwise
|
|
1596
|
+
*/
|
|
1597
|
+
private _matchesAnyPattern;
|
|
1547
1598
|
/**
|
|
1548
1599
|
* Determines if an element is external based on its file path and dependency source.
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
* @
|
|
1600
|
+
* Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:
|
|
1601
|
+
* - unresolvableAlias: Files whose path cannot be resolved (filePath is null)
|
|
1602
|
+
* - inNodeModules: Non-relative paths that include "node_modules"
|
|
1603
|
+
* - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)
|
|
1604
|
+
* - customSourcePatterns: Source matches any of the configured patterns
|
|
1605
|
+
* @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.
|
|
1606
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1607
|
+
* @param dependencySource The import/export source string
|
|
1608
|
+
* @returns True if any of the configured conditions is met, false otherwise
|
|
1555
1609
|
*/
|
|
1556
1610
|
private _isExternalDependency;
|
|
1557
1611
|
/**
|
|
@@ -1599,27 +1653,28 @@ declare class ElementsDescriptor {
|
|
|
1599
1653
|
/**
|
|
1600
1654
|
* Returns an external or core dependency element given its dependency source and file path.
|
|
1601
1655
|
* @param dependencySource The source of the dependency.
|
|
1602
|
-
* @param
|
|
1656
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1657
|
+
* @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.
|
|
1603
1658
|
* @returns The external or core dependency element, or null if it is a local dependency.
|
|
1604
1659
|
*/
|
|
1605
1660
|
private _getExternalOrCoreDependencyElement;
|
|
1606
1661
|
/**
|
|
1607
1662
|
* Describes an element given its file path and dependency source, if any.
|
|
1608
|
-
* @param filePath The path of the file to describe.
|
|
1663
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1609
1664
|
* @param dependencySource The source of the dependency, if the element to describe is so. It refers to the import/export path used to reference the file or external module.
|
|
1610
1665
|
* @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.
|
|
1611
1666
|
*/
|
|
1612
1667
|
private _describeElement;
|
|
1613
1668
|
/**
|
|
1614
1669
|
* Describes an element given its file path.
|
|
1615
|
-
* @param filePath The path of the file to describe.
|
|
1670
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1616
1671
|
* @returns The description of the element.
|
|
1617
1672
|
*/
|
|
1618
1673
|
describeElement(filePath?: string): FileElement;
|
|
1619
1674
|
/**
|
|
1620
1675
|
* Describes a dependency element given its dependency source and file path.
|
|
1621
1676
|
* @param dependencySource The source of the dependency.
|
|
1622
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
1677
|
+
* @param filePath The path of the file being the dependency, if known. Can be absolute if rootPath is configured, or relative if not.
|
|
1623
1678
|
* @returns The description of the dependency element.
|
|
1624
1679
|
*/
|
|
1625
1680
|
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
@@ -1791,4 +1846,4 @@ declare class CacheManager<CacheKey extends NotUndefined, CachedValue> {
|
|
|
1791
1846
|
setFromSerialized(serializedCache: Record<string, CachedValue>): void;
|
|
1792
1847
|
}
|
|
1793
1848
|
|
|
1794
|
-
export { type BaseDependencyElement, type BaseElement, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreDependencyElement, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_TYPEOF, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDescription, type DependencyElementDescription, type DependencyElementSelector, type DependencyElementSelectorData, type DependencyElementSelectorWithOptions, type DependencyElementsSelector, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, type DescriptionsSerializedCache, type DescriptorOptionsNormalized, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorData, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalDependencyElement, type ExternalLibrariesSelector, type ExternalLibrarySelector, type ExternalLibrarySelectorOptions, type ExternalLibrarySelectorWithOptions, type ExternalLibrarySelectors, type FileElement, type FileElementsSerializedCache, type IgnoredDependencyElement, type IgnoredElement, type LocalDependencyElement, type LocalDependencyElementKnown, type LocalDependencyElementUnknown, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherOptionsDependencySelectorsGlobals, type MatcherSerializedCache, type MatchersOptionsNormalized, type MicromatchPattern, type MicromatchSerializedCache, type NotUndefined, type ObjectCacheKey, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDescription, isDependencyElementDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isExternalLibrariesSelector, isExternalLibrarySelector, isExternalLibrarySelectorOptions, isExternalLibrarySelectorOptionsWithPath, isExternalLibrarySelectorOptionsWithSpecifiers, isExternalLibrarySelectorWithOptions, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementsSelector };
|
|
1849
|
+
export { type BaseDependencyElement, type BaseElement, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreDependencyElement, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_TYPEOF, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDescription, type DependencyElementDescription, type DependencyElementSelector, type DependencyElementSelectorData, type DependencyElementSelectorWithOptions, type DependencyElementsSelector, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, type DescriptionsSerializedCache, type DescriptorOptionsNormalized, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorData, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalDependencyElement, type ExternalLibrariesSelector, type ExternalLibrarySelector, type ExternalLibrarySelectorOptions, type ExternalLibrarySelectorWithOptions, type ExternalLibrarySelectors, type FileElement, type FileElementsSerializedCache, type FlagAsExternalOptions, type FlagAsExternalOptionsNormalized, type IgnoredDependencyElement, type IgnoredElement, type LocalDependencyElement, type LocalDependencyElementKnown, type LocalDependencyElementUnknown, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherOptionsDependencySelectorsGlobals, type MatcherSerializedCache, type MatchersOptionsNormalized, type MicromatchPattern, type MicromatchSerializedCache, type NotUndefined, type ObjectCacheKey, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDescription, isDependencyElementDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isExternalLibrariesSelector, isExternalLibrarySelector, isExternalLibrarySelectorOptions, isExternalLibrarySelectorOptionsWithPath, isExternalLibrarySelectorOptionsWithSpecifiers, isExternalLibrarySelectorWithOptions, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementsSelector };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
* Type representing a micromatch pattern, which can be a string or an array of strings.
|
|
3
3
|
*/
|
|
4
4
|
type MicromatchPattern = string | string[];
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for categorizing dependencies as external or local.
|
|
7
|
+
*/
|
|
8
|
+
type FlagAsExternalOptions = {
|
|
9
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external (default: true) */
|
|
10
|
+
unresolvableAlias?: boolean;
|
|
11
|
+
/** When true, non-relative paths that include node_modules are categorized as external (default: true) */
|
|
12
|
+
inNodeModules?: boolean;
|
|
13
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external (default: false) */
|
|
14
|
+
outsideRootPath?: boolean;
|
|
15
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external (default: []) */
|
|
16
|
+
customSourcePatterns?: string[];
|
|
17
|
+
};
|
|
5
18
|
/** Configuration options for the Config class */
|
|
6
19
|
type ConfigOptions = {
|
|
7
20
|
/** An array of path patterns to include when resolving elements. Defaults to all files if not specified */
|
|
@@ -15,15 +28,33 @@ type ConfigOptions = {
|
|
|
15
28
|
legacyTemplates?: boolean;
|
|
16
29
|
/** Whether to enable caching */
|
|
17
30
|
cache?: boolean;
|
|
31
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
32
|
+
flagAsExternal?: FlagAsExternalOptions;
|
|
33
|
+
/** Root path of the project, used for determining if dependencies are outside the project */
|
|
34
|
+
rootPath?: string;
|
|
35
|
+
};
|
|
36
|
+
type FlagAsExternalOptionsNormalized = {
|
|
37
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external */
|
|
38
|
+
unresolvableAlias: boolean;
|
|
39
|
+
/** When true, non-relative paths that include node_modules are categorized as external */
|
|
40
|
+
inNodeModules: boolean;
|
|
41
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external */
|
|
42
|
+
outsideRootPath: boolean;
|
|
43
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external */
|
|
44
|
+
customSourcePatterns: string[];
|
|
18
45
|
};
|
|
19
|
-
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache"> & {
|
|
46
|
+
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache" | "flagAsExternal"> & {
|
|
20
47
|
/** Whether to enable legacy template support */
|
|
21
48
|
legacyTemplates: boolean;
|
|
22
49
|
/** Cache configuration options */
|
|
23
50
|
cache: boolean;
|
|
51
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
52
|
+
flagAsExternal: FlagAsExternalOptionsNormalized;
|
|
53
|
+
/** Root path of the project, already normalized, and finishing with a slash, used for determining if dependencies are outside the project */
|
|
54
|
+
rootPath: string | undefined;
|
|
24
55
|
};
|
|
25
56
|
/** Options for descriptors */
|
|
26
|
-
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache">;
|
|
57
|
+
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache" | "flagAsExternal" | "rootPath">;
|
|
27
58
|
/** Options for element matchers */
|
|
28
59
|
type MatchersOptionsNormalized = Pick<ConfigOptionsNormalized, "legacyTemplates">;
|
|
29
60
|
|
|
@@ -1544,14 +1575,37 @@ declare class ElementsDescriptor {
|
|
|
1544
1575
|
* @returns The base source of the external module. (e.g., for "@scope/package/submodule", it returns "@scope/package")
|
|
1545
1576
|
*/
|
|
1546
1577
|
private _getExternalOrCoreModuleBaseSource;
|
|
1578
|
+
/**
|
|
1579
|
+
* Determines if a file path is outside the configured root path.
|
|
1580
|
+
* @param filePath The file path to check.
|
|
1581
|
+
* @returns True if the file path is outside the root path, false otherwise.
|
|
1582
|
+
*/
|
|
1583
|
+
private _isOutsideRootPath;
|
|
1584
|
+
/**
|
|
1585
|
+
* Converts an absolute file path to a relative path if rootPath is configured.
|
|
1586
|
+
* If rootPath is not configured, returns the path as-is (maintains backward compatibility).
|
|
1587
|
+
* @param filePath The file path to convert (can be absolute or relative)
|
|
1588
|
+
* @returns The relative path if rootPath is configured and path is absolute, otherwise the original path
|
|
1589
|
+
*/
|
|
1590
|
+
private _toRelativePath;
|
|
1591
|
+
/**
|
|
1592
|
+
* Checks if a source string matches any of the provided patterns using micromatch.
|
|
1593
|
+
* @param patterns - Array of micromatch patterns
|
|
1594
|
+
* @param source - The source string to match against patterns
|
|
1595
|
+
* @returns True if the source matches any pattern, false otherwise
|
|
1596
|
+
*/
|
|
1597
|
+
private _matchesAnyPattern;
|
|
1547
1598
|
/**
|
|
1548
1599
|
* Determines if an element is external based on its file path and dependency source.
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
* @
|
|
1600
|
+
* Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:
|
|
1601
|
+
* - unresolvableAlias: Files whose path cannot be resolved (filePath is null)
|
|
1602
|
+
* - inNodeModules: Non-relative paths that include "node_modules"
|
|
1603
|
+
* - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)
|
|
1604
|
+
* - customSourcePatterns: Source matches any of the configured patterns
|
|
1605
|
+
* @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.
|
|
1606
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1607
|
+
* @param dependencySource The import/export source string
|
|
1608
|
+
* @returns True if any of the configured conditions is met, false otherwise
|
|
1555
1609
|
*/
|
|
1556
1610
|
private _isExternalDependency;
|
|
1557
1611
|
/**
|
|
@@ -1599,27 +1653,28 @@ declare class ElementsDescriptor {
|
|
|
1599
1653
|
/**
|
|
1600
1654
|
* Returns an external or core dependency element given its dependency source and file path.
|
|
1601
1655
|
* @param dependencySource The source of the dependency.
|
|
1602
|
-
* @param
|
|
1656
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1657
|
+
* @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.
|
|
1603
1658
|
* @returns The external or core dependency element, or null if it is a local dependency.
|
|
1604
1659
|
*/
|
|
1605
1660
|
private _getExternalOrCoreDependencyElement;
|
|
1606
1661
|
/**
|
|
1607
1662
|
* Describes an element given its file path and dependency source, if any.
|
|
1608
|
-
* @param filePath The path of the file to describe.
|
|
1663
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1609
1664
|
* @param dependencySource The source of the dependency, if the element to describe is so. It refers to the import/export path used to reference the file or external module.
|
|
1610
1665
|
* @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.
|
|
1611
1666
|
*/
|
|
1612
1667
|
private _describeElement;
|
|
1613
1668
|
/**
|
|
1614
1669
|
* Describes an element given its file path.
|
|
1615
|
-
* @param filePath The path of the file to describe.
|
|
1670
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1616
1671
|
* @returns The description of the element.
|
|
1617
1672
|
*/
|
|
1618
1673
|
describeElement(filePath?: string): FileElement;
|
|
1619
1674
|
/**
|
|
1620
1675
|
* Describes a dependency element given its dependency source and file path.
|
|
1621
1676
|
* @param dependencySource The source of the dependency.
|
|
1622
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
1677
|
+
* @param filePath The path of the file being the dependency, if known. Can be absolute if rootPath is configured, or relative if not.
|
|
1623
1678
|
* @returns The description of the dependency element.
|
|
1624
1679
|
*/
|
|
1625
1680
|
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
@@ -1791,4 +1846,4 @@ declare class CacheManager<CacheKey extends NotUndefined, CachedValue> {
|
|
|
1791
1846
|
setFromSerialized(serializedCache: Record<string, CachedValue>): void;
|
|
1792
1847
|
}
|
|
1793
1848
|
|
|
1794
|
-
export { type BaseDependencyElement, type BaseElement, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreDependencyElement, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_TYPEOF, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDescription, type DependencyElementDescription, type DependencyElementSelector, type DependencyElementSelectorData, type DependencyElementSelectorWithOptions, type DependencyElementsSelector, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, type DescriptionsSerializedCache, type DescriptorOptionsNormalized, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorData, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalDependencyElement, type ExternalLibrariesSelector, type ExternalLibrarySelector, type ExternalLibrarySelectorOptions, type ExternalLibrarySelectorWithOptions, type ExternalLibrarySelectors, type FileElement, type FileElementsSerializedCache, type IgnoredDependencyElement, type IgnoredElement, type LocalDependencyElement, type LocalDependencyElementKnown, type LocalDependencyElementUnknown, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherOptionsDependencySelectorsGlobals, type MatcherSerializedCache, type MatchersOptionsNormalized, type MicromatchPattern, type MicromatchSerializedCache, type NotUndefined, type ObjectCacheKey, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDescription, isDependencyElementDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isExternalLibrariesSelector, isExternalLibrarySelector, isExternalLibrarySelectorOptions, isExternalLibrarySelectorOptionsWithPath, isExternalLibrarySelectorOptionsWithSpecifiers, isExternalLibrarySelectorWithOptions, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementsSelector };
|
|
1849
|
+
export { type BaseDependencyElement, type BaseElement, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreDependencyElement, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_TYPEOF, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDescription, type DependencyElementDescription, type DependencyElementSelector, type DependencyElementSelectorData, type DependencyElementSelectorWithOptions, type DependencyElementsSelector, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, type DescriptionsSerializedCache, type DescriptorOptionsNormalized, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorData, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalDependencyElement, type ExternalLibrariesSelector, type ExternalLibrarySelector, type ExternalLibrarySelectorOptions, type ExternalLibrarySelectorWithOptions, type ExternalLibrarySelectors, type FileElement, type FileElementsSerializedCache, type FlagAsExternalOptions, type FlagAsExternalOptionsNormalized, type IgnoredDependencyElement, type IgnoredElement, type LocalDependencyElement, type LocalDependencyElementKnown, type LocalDependencyElementUnknown, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherOptionsDependencySelectorsGlobals, type MatcherSerializedCache, type MatchersOptionsNormalized, type MicromatchPattern, type MicromatchSerializedCache, type NotUndefined, type ObjectCacheKey, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDescription, isDependencyElementDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isExternalLibrariesSelector, isExternalLibrarySelector, isExternalLibrarySelectorOptions, isExternalLibrarySelectorOptionsWithPath, isExternalLibrarySelectorOptionsWithSpecifiers, isExternalLibrarySelectorWithOptions, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementsSelector };
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,46 @@ __export(src_exports, {
|
|
|
80
80
|
});
|
|
81
81
|
module.exports = __toCommonJS(src_exports);
|
|
82
82
|
|
|
83
|
+
// src/Support/TypeGuards.ts
|
|
84
|
+
function isString(value) {
|
|
85
|
+
return typeof value === "string";
|
|
86
|
+
}
|
|
87
|
+
function isNullish(value) {
|
|
88
|
+
return value === null || value === void 0;
|
|
89
|
+
}
|
|
90
|
+
function isNull(value) {
|
|
91
|
+
return value === null;
|
|
92
|
+
}
|
|
93
|
+
function isBoolean(value) {
|
|
94
|
+
return typeof value === "boolean";
|
|
95
|
+
}
|
|
96
|
+
function isObject(value) {
|
|
97
|
+
return !isNullish(value) && !isBoolean(value) && !isArray(value) && typeof value === "object";
|
|
98
|
+
}
|
|
99
|
+
function isEmptyObject(obj) {
|
|
100
|
+
return isObject(obj) && Object.keys(obj).length === 0;
|
|
101
|
+
}
|
|
102
|
+
function isArray(value) {
|
|
103
|
+
return Array.isArray(value);
|
|
104
|
+
}
|
|
105
|
+
function isEmptyArray(arr) {
|
|
106
|
+
return arr.length === 0;
|
|
107
|
+
}
|
|
108
|
+
function isStringArray(value) {
|
|
109
|
+
return isArray(value) && value.every(isString);
|
|
110
|
+
}
|
|
111
|
+
function isObjectWithProperty(value, key) {
|
|
112
|
+
return isObject(value) && Object.hasOwn(value, key);
|
|
113
|
+
}
|
|
114
|
+
function isObjectWithAnyOfProperties(value, keys) {
|
|
115
|
+
return isObject(value) && keys.some((key) => key in value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/Support/Paths.ts
|
|
119
|
+
function normalizePath(filePath) {
|
|
120
|
+
return filePath.replaceAll("\\", "/");
|
|
121
|
+
}
|
|
122
|
+
|
|
83
123
|
// src/Config/Config.ts
|
|
84
124
|
var Config = class {
|
|
85
125
|
/** The ignore paths */
|
|
@@ -90,6 +130,10 @@ var Config = class {
|
|
|
90
130
|
_legacyTemplates;
|
|
91
131
|
/** Whether the cache is enabled */
|
|
92
132
|
_cache;
|
|
133
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
134
|
+
_flagAsExternal;
|
|
135
|
+
/** Root path of the project */
|
|
136
|
+
_rootPath;
|
|
93
137
|
/**
|
|
94
138
|
* Creates a new Config instance
|
|
95
139
|
* @param options Configuration options
|
|
@@ -99,6 +143,18 @@ var Config = class {
|
|
|
99
143
|
this._includePaths = options?.includePaths;
|
|
100
144
|
this._legacyTemplates = options?.legacyTemplates ?? true;
|
|
101
145
|
this._cache = options?.cache ?? true;
|
|
146
|
+
this._flagAsExternal = {
|
|
147
|
+
unresolvableAlias: options?.flagAsExternal?.unresolvableAlias ?? true,
|
|
148
|
+
inNodeModules: options?.flagAsExternal?.inNodeModules ?? true,
|
|
149
|
+
outsideRootPath: options?.flagAsExternal?.outsideRootPath ?? false,
|
|
150
|
+
customSourcePatterns: options?.flagAsExternal?.customSourcePatterns ?? []
|
|
151
|
+
};
|
|
152
|
+
if (options?.rootPath) {
|
|
153
|
+
const normalizedRoot = normalizePath(options.rootPath);
|
|
154
|
+
this._rootPath = normalizedRoot.endsWith("/") ? normalizedRoot : `${normalizedRoot}/`;
|
|
155
|
+
} else {
|
|
156
|
+
this._rootPath = void 0;
|
|
157
|
+
}
|
|
102
158
|
}
|
|
103
159
|
/**
|
|
104
160
|
* The normalized configuration options
|
|
@@ -108,7 +164,9 @@ var Config = class {
|
|
|
108
164
|
ignorePaths: this._ignorePaths,
|
|
109
165
|
includePaths: this._includePaths,
|
|
110
166
|
legacyTemplates: this._legacyTemplates,
|
|
111
|
-
cache: this._cache
|
|
167
|
+
cache: this._cache,
|
|
168
|
+
flagAsExternal: this._flagAsExternal,
|
|
169
|
+
rootPath: this._rootPath
|
|
112
170
|
};
|
|
113
171
|
}
|
|
114
172
|
/**
|
|
@@ -118,7 +176,9 @@ var Config = class {
|
|
|
118
176
|
return {
|
|
119
177
|
ignorePaths: this._ignorePaths,
|
|
120
178
|
includePaths: this._includePaths,
|
|
121
|
-
cache: this._cache
|
|
179
|
+
cache: this._cache,
|
|
180
|
+
flagAsExternal: this._flagAsExternal,
|
|
181
|
+
rootPath: this._rootPath
|
|
122
182
|
};
|
|
123
183
|
}
|
|
124
184
|
/**
|
|
@@ -140,41 +200,6 @@ var Config = class {
|
|
|
140
200
|
// src/Matcher/BaseElementsMatcher.ts
|
|
141
201
|
var import_handlebars = __toESM(require("handlebars"));
|
|
142
202
|
|
|
143
|
-
// src/Support/TypeGuards.ts
|
|
144
|
-
function isString(value) {
|
|
145
|
-
return typeof value === "string";
|
|
146
|
-
}
|
|
147
|
-
function isNullish(value) {
|
|
148
|
-
return value === null || value === void 0;
|
|
149
|
-
}
|
|
150
|
-
function isNull(value) {
|
|
151
|
-
return value === null;
|
|
152
|
-
}
|
|
153
|
-
function isBoolean(value) {
|
|
154
|
-
return typeof value === "boolean";
|
|
155
|
-
}
|
|
156
|
-
function isObject(value) {
|
|
157
|
-
return !isNullish(value) && !isBoolean(value) && !isArray(value) && typeof value === "object";
|
|
158
|
-
}
|
|
159
|
-
function isEmptyObject(obj) {
|
|
160
|
-
return isObject(obj) && Object.keys(obj).length === 0;
|
|
161
|
-
}
|
|
162
|
-
function isArray(value) {
|
|
163
|
-
return Array.isArray(value);
|
|
164
|
-
}
|
|
165
|
-
function isEmptyArray(arr) {
|
|
166
|
-
return arr.length === 0;
|
|
167
|
-
}
|
|
168
|
-
function isStringArray(value) {
|
|
169
|
-
return isArray(value) && value.every(isString);
|
|
170
|
-
}
|
|
171
|
-
function isObjectWithProperty(value, key) {
|
|
172
|
-
return isObject(value) && Object.hasOwn(value, key);
|
|
173
|
-
}
|
|
174
|
-
function isObjectWithAnyOfProperties(value, keys) {
|
|
175
|
-
return isObject(value) && keys.some((key) => key in value);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
203
|
// src/Matcher/MatcherHelpers.ts
|
|
179
204
|
function isCapturedValuesSelector(value) {
|
|
180
205
|
if (!isObject(value) || isArray(value)) {
|
|
@@ -1605,17 +1630,72 @@ var ElementsDescriptor = class {
|
|
|
1605
1630
|
return pkg;
|
|
1606
1631
|
}
|
|
1607
1632
|
/**
|
|
1608
|
-
* Determines if
|
|
1609
|
-
*
|
|
1610
|
-
*
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1633
|
+
* Determines if a file path is outside the configured root path.
|
|
1634
|
+
* @param filePath The file path to check.
|
|
1635
|
+
* @returns True if the file path is outside the root path, false otherwise.
|
|
1636
|
+
*/
|
|
1637
|
+
_isOutsideRootPath(filePath) {
|
|
1638
|
+
if (!this._config.rootPath) {
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1641
|
+
return !filePath.startsWith(this._config.rootPath);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Converts an absolute file path to a relative path if rootPath is configured.
|
|
1645
|
+
* If rootPath is not configured, returns the path as-is (maintains backward compatibility).
|
|
1646
|
+
* @param filePath The file path to convert (can be absolute or relative)
|
|
1647
|
+
* @returns The relative path if rootPath is configured and path is absolute, otherwise the original path
|
|
1648
|
+
*/
|
|
1649
|
+
_toRelativePath(filePath) {
|
|
1650
|
+
if (!this._config.rootPath || this._isOutsideRootPath(filePath)) {
|
|
1651
|
+
return filePath;
|
|
1652
|
+
}
|
|
1653
|
+
return filePath.replace(this._config.rootPath, "");
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Checks if a source string matches any of the provided patterns using micromatch.
|
|
1657
|
+
* @param patterns - Array of micromatch patterns
|
|
1658
|
+
* @param source - The source string to match against patterns
|
|
1659
|
+
* @returns True if the source matches any pattern, false otherwise
|
|
1615
1660
|
*/
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1661
|
+
_matchesAnyPattern(patterns, source) {
|
|
1662
|
+
if (!source || patterns.length === 0) {
|
|
1663
|
+
return false;
|
|
1664
|
+
}
|
|
1665
|
+
return this._micromatch.isMatch(source, patterns);
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Determines if an element is external based on its file path and dependency source.
|
|
1669
|
+
* Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:
|
|
1670
|
+
* - unresolvableAlias: Files whose path cannot be resolved (filePath is null)
|
|
1671
|
+
* - inNodeModules: Non-relative paths that include "node_modules"
|
|
1672
|
+
* - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)
|
|
1673
|
+
* - customSourcePatterns: Source matches any of the configured patterns
|
|
1674
|
+
* @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.
|
|
1675
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1676
|
+
* @param dependencySource The import/export source string
|
|
1677
|
+
* @returns True if any of the configured conditions is met, false otherwise
|
|
1678
|
+
*/
|
|
1679
|
+
_isExternalDependency(filePath, isOutsideRootPath, dependencySource) {
|
|
1680
|
+
const {
|
|
1681
|
+
unresolvableAlias,
|
|
1682
|
+
inNodeModules,
|
|
1683
|
+
outsideRootPath,
|
|
1684
|
+
customSourcePatterns
|
|
1685
|
+
} = this._config.flagAsExternal;
|
|
1686
|
+
if (outsideRootPath && isOutsideRootPath) {
|
|
1687
|
+
return true;
|
|
1688
|
+
}
|
|
1689
|
+
if (inNodeModules && filePath?.includes("node_modules")) {
|
|
1690
|
+
return true;
|
|
1691
|
+
}
|
|
1692
|
+
if (unresolvableAlias && !filePath && dependencySource && this._dependencySourceIsExternalOrScoped(dependencySource)) {
|
|
1693
|
+
return true;
|
|
1694
|
+
}
|
|
1695
|
+
if (this._matchesAnyPattern(customSourcePatterns, dependencySource)) {
|
|
1696
|
+
return true;
|
|
1697
|
+
}
|
|
1698
|
+
return false;
|
|
1619
1699
|
}
|
|
1620
1700
|
/**
|
|
1621
1701
|
* Determines if a given path is included based on the configuration.
|
|
@@ -1683,6 +1763,16 @@ var ElementsDescriptor = class {
|
|
|
1683
1763
|
}
|
|
1684
1764
|
return `${[...allPathSegments].reverse().join("/").split(result)[0]}${result}`;
|
|
1685
1765
|
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Determines if an element descriptor matches the given parameters in the provided path.
|
|
1768
|
+
* @param options The options for matching the descriptor.
|
|
1769
|
+
* @param options.elementDescriptor The element descriptor to match.
|
|
1770
|
+
* @param options.filePath The file path to match against the descriptor.
|
|
1771
|
+
* @param options.currentPathSegments The current path segments leading to the element.
|
|
1772
|
+
* @param options.lastPathSegmentMatching The last path segment that was matched.
|
|
1773
|
+
* @param options.alreadyMatched Whether the element matched previously.
|
|
1774
|
+
* @returns The result of the match, including whether it matched.
|
|
1775
|
+
*/
|
|
1686
1776
|
_fileDescriptorMatch({
|
|
1687
1777
|
elementDescriptor,
|
|
1688
1778
|
filePath,
|
|
@@ -1837,10 +1927,11 @@ var ElementsDescriptor = class {
|
|
|
1837
1927
|
/**
|
|
1838
1928
|
* Returns an external or core dependency element given its dependency source and file path.
|
|
1839
1929
|
* @param dependencySource The source of the dependency.
|
|
1840
|
-
* @param
|
|
1930
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1931
|
+
* @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.
|
|
1841
1932
|
* @returns The external or core dependency element, or null if it is a local dependency.
|
|
1842
1933
|
*/
|
|
1843
|
-
_getExternalOrCoreDependencyElement(dependencySource, filePath) {
|
|
1934
|
+
_getExternalOrCoreDependencyElement(dependencySource, isOutsideRootPath, filePath) {
|
|
1844
1935
|
const baseDependencySource = this._getExternalOrCoreModuleBaseSource(dependencySource);
|
|
1845
1936
|
const isCore = this._dependencySourceIsCoreModule(
|
|
1846
1937
|
dependencySource,
|
|
@@ -1857,6 +1948,7 @@ var ElementsDescriptor = class {
|
|
|
1857
1948
|
}
|
|
1858
1949
|
const isExternal = this._isExternalDependency(
|
|
1859
1950
|
filePath || null,
|
|
1951
|
+
isOutsideRootPath,
|
|
1860
1952
|
dependencySource
|
|
1861
1953
|
);
|
|
1862
1954
|
if (isExternal) {
|
|
@@ -1877,12 +1969,19 @@ var ElementsDescriptor = class {
|
|
|
1877
1969
|
if (this._descriptionsCache.has(cacheKey)) {
|
|
1878
1970
|
return this._descriptionsCache.get(cacheKey);
|
|
1879
1971
|
}
|
|
1880
|
-
const
|
|
1972
|
+
const normalizedFilePath = filePath ? normalizePath(filePath) : filePath;
|
|
1973
|
+
const isOutsideRootPath = normalizedFilePath ? this._isOutsideRootPath(normalizedFilePath) : false;
|
|
1974
|
+
const relativePath = normalizedFilePath && this._config.rootPath ? this._toRelativePath(normalizedFilePath) : normalizedFilePath;
|
|
1975
|
+
const externalOrCoreDependencyElement = dependencySource ? this._getExternalOrCoreDependencyElement(
|
|
1976
|
+
dependencySource,
|
|
1977
|
+
isOutsideRootPath,
|
|
1978
|
+
relativePath
|
|
1979
|
+
) : null;
|
|
1881
1980
|
if (externalOrCoreDependencyElement) {
|
|
1882
1981
|
this._descriptionsCache.set(cacheKey, externalOrCoreDependencyElement);
|
|
1883
1982
|
return externalOrCoreDependencyElement;
|
|
1884
1983
|
}
|
|
1885
|
-
const fileDescription = this._describeFile(
|
|
1984
|
+
const fileDescription = this._describeFile(relativePath);
|
|
1886
1985
|
const elementResult = dependencySource ? {
|
|
1887
1986
|
...fileDescription,
|
|
1888
1987
|
source: dependencySource
|
|
@@ -1892,7 +1991,7 @@ var ElementsDescriptor = class {
|
|
|
1892
1991
|
}
|
|
1893
1992
|
/**
|
|
1894
1993
|
* Describes an element given its file path.
|
|
1895
|
-
* @param filePath The path of the file to describe.
|
|
1994
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1896
1995
|
* @returns The description of the element.
|
|
1897
1996
|
*/
|
|
1898
1997
|
describeElement(filePath) {
|
|
@@ -1901,7 +2000,7 @@ var ElementsDescriptor = class {
|
|
|
1901
2000
|
/**
|
|
1902
2001
|
* Describes a dependency element given its dependency source and file path.
|
|
1903
2002
|
* @param dependencySource The source of the dependency.
|
|
1904
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
2003
|
+
* @param filePath The path of the file being the dependency, if known. Can be absolute if rootPath is configured, or relative if not.
|
|
1905
2004
|
* @returns The description of the dependency element.
|
|
1906
2005
|
*/
|
|
1907
2006
|
describeDependencyElement(dependencySource, filePath) {
|
|
@@ -2289,7 +2388,7 @@ var MatchersCache = class extends CacheManager {
|
|
|
2289
2388
|
config,
|
|
2290
2389
|
elementDescriptors
|
|
2291
2390
|
}) {
|
|
2292
|
-
const configHash = `${config.legacyTemplates}|${config.includePaths}|${config.ignorePaths}|${config.cache}`;
|
|
2391
|
+
const configHash = `${config.legacyTemplates}|${config.includePaths}|${config.ignorePaths}|${config.cache}|${config.rootPath}|${config.flagAsExternal.inNodeModules}|${config.flagAsExternal.unresolvableAlias}|${config.flagAsExternal.outsideRootPath}|${config.flagAsExternal.customSourcePatterns.join(",")}`;
|
|
2293
2392
|
const elementDescriptorsHash = elementDescriptors.map(
|
|
2294
2393
|
(descriptor) => `${descriptor.type}|${descriptor.category}|${descriptor.pattern}|${descriptor.basePattern}|${descriptor.mode}|${descriptor.capture}|${descriptor.baseCapture}`
|
|
2295
2394
|
).join(",");
|