@ms-cloudpack/package-utilities 7.6.0 → 7.7.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/lib/createResolveMap/createResolveMap.js +1 -1
- package/lib/createResolveMap/createResolveMap.js.map +1 -1
- package/lib/createResolveMap/dedupeLinkedPackages.d.ts +6 -2
- package/lib/createResolveMap/dedupeLinkedPackages.d.ts.map +1 -1
- package/lib/createResolveMap/dedupeLinkedPackages.js +41 -9
- package/lib/createResolveMap/dedupeLinkedPackages.js.map +1 -1
- package/lib/createResolveMap/linkPath.d.ts +1 -0
- package/lib/createResolveMap/linkPath.d.ts.map +1 -1
- package/lib/createResolveMap/linkPath.js +2 -2
- package/lib/createResolveMap/linkPath.js.map +1 -1
- package/lib/detectModuleType.d.ts +1 -4
- package/lib/detectModuleType.d.ts.map +1 -1
- package/lib/detectModuleType.js +11 -2
- package/lib/detectModuleType.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -24,7 +24,7 @@ export async function createResolveMap(options, context) {
|
|
|
24
24
|
}, context);
|
|
25
25
|
// Next, we iterate through linked paths to inject them into the packageMap.
|
|
26
26
|
for (const linkedPath of linkedPaths) {
|
|
27
|
-
await linkPath({ linkedPath, appMap, repoDefinition }, context);
|
|
27
|
+
await linkPath({ rootPath, linkedPath, appMap, repoDefinition }, context);
|
|
28
28
|
}
|
|
29
29
|
// Finally we condense into a resolve map.
|
|
30
30
|
return convertToResolveMap({ appMap, rootPaths: [appPath, ...additionalPaths] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createResolveMap.js","sourceRoot":"","sources":["../../src/createResolveMap/createResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,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AM,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEpE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvF,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnF,kDAAkD;IAClD,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC;QACE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC;QAC1C,QAAQ;KACT,EACD,OAAO,CACR,CAAC;IAEF,4EAA4E;IAC5E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED,0CAA0C;IAC1C,OAAO,mBAAmB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { findProjectRoot } from '../findProjectRoot.js';\nimport type { ResolveMap } from '../types/ResolveMap.js';\nimport { convertToResolveMap } from './convertToResolveMap.js';\nimport { findPackagesFromPath } from './findPackagesFromPath.js';\nimport { linkPath } from './linkPath.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { LinkedPath } from '../types/LinkedPath.js';\n\n/**\n * Create a resolve map for a given `appPath`.\n * 1. Walk the dependency tree to build a map of all packages and their dependencies.\n * 2. If `linkedPaths` are provided, for each one:\n * 1. Walk its dependency tree to build a map as above.\n * 2. Redirect any existing dependencies to the linked package.\n * 3. Ensure that any transitive dependencies of the linked package which aren't already\n * satisfied in the resolve map are added as scoped versions.\n * 3. For each dependency, sort the versions by the number of packages that depend on that version.\n * The most popular version will be considered the \"default\", to reduce the size of scoped versions.\n */\nexport async function createResolveMap(\n options: {\n /** Path to the app whose dependencies we want to resolve. */\n appPath: string;\n\n /** Any additional packages whose dependencies we want to resolve. */\n additionalPaths?: string[];\n\n /** See `createResolveMap` comment. */\n linkedPaths?: LinkedPath[];\n\n /**\n * Where to stop looking for packages (mainly used for testing).\n * If not specified, will look for the project/git root of the `appPath`.\n */\n rootPath?: string;\n\n /** @deprecated Not used */\n useStrictVersioning?: boolean;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<ResolveMap> {\n const { appPath, additionalPaths = [], linkedPaths = [] } = options;\n\n const rootPath = options.rootPath || findProjectRoot(appPath, { noPackageRoot: true });\n\n const repoDefinition = rootPath ? await context.packages.get(rootPath) : undefined;\n\n // First we discover the dependencies for the app.\n const appMap = await findPackagesFromPath(\n {\n searchPaths: [appPath, ...additionalPaths],\n rootPath,\n },\n context,\n );\n\n // Next, we iterate through linked paths to inject them into the packageMap.\n for (const linkedPath of linkedPaths) {\n await linkPath({ rootPath, linkedPath, appMap, repoDefinition }, context);\n }\n\n // Finally we condense into a resolve map.\n return convertToResolveMap({ appMap, rootPaths: [appPath, ...additionalPaths] });\n}\n"]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { PackageMap } from '../types/PackageMap.js';
|
|
2
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
2
3
|
/**
|
|
3
4
|
* Deduplicates linked packages by removing all but the highest version,
|
|
4
5
|
* that satisfies the semver requirements of all the requiredBy entries.
|
|
5
6
|
*/
|
|
6
|
-
export declare function dedupeLinkedPackages(
|
|
7
|
+
export declare function dedupeLinkedPackages(options: {
|
|
7
8
|
appMap: PackageMap;
|
|
8
9
|
allDuplicates: Set<string>;
|
|
9
|
-
|
|
10
|
+
rootPath?: string;
|
|
11
|
+
}, context: {
|
|
12
|
+
packages: PackageDefinitionsCache;
|
|
13
|
+
}): Promise<void>;
|
|
10
14
|
//# sourceMappingURL=dedupeLinkedPackages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupeLinkedPackages.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"dedupeLinkedPackages.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,OAAO,KAAK,EAAE,uBAAuB,EAAmB,MAAM,4BAA4B,CAAC;AAK3F;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9E,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,iBAgG/C"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { satisfies, compare as semverCompare } from 'semver';
|
|
2
2
|
import { parseRequiredBy } from './parseRequiredBy.js';
|
|
3
3
|
import { detachEntry } from './detachEntry.js';
|
|
4
|
+
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
4
5
|
/**
|
|
5
6
|
* Deduplicates linked packages by removing all but the highest version,
|
|
6
7
|
* that satisfies the semver requirements of all the requiredBy entries.
|
|
7
8
|
*/
|
|
8
|
-
export function dedupeLinkedPackages(
|
|
9
|
+
export async function dedupeLinkedPackages(options, context) {
|
|
10
|
+
const { rootPath, appMap, allDuplicates } = options;
|
|
11
|
+
const { packages } = context;
|
|
9
12
|
console.debug(`The following packages were duplicated by linking:\n ${Array.from(allDuplicates).join(', ')}`);
|
|
10
13
|
for (const duplicate of allDuplicates) {
|
|
11
14
|
const packageName = parseRequiredBy(duplicate).name;
|
|
@@ -14,6 +17,13 @@ export function dedupeLinkedPackages({ appMap, allDuplicates }) {
|
|
|
14
17
|
if (Object.keys(entries).length <= 1) {
|
|
15
18
|
continue;
|
|
16
19
|
}
|
|
20
|
+
let dedupeStrategy = 'allow-duplication';
|
|
21
|
+
for (const entry of Object.values(entries)) {
|
|
22
|
+
const packageJson = await packages.get(entry.path);
|
|
23
|
+
if (packageJson?.cloudpack?.link?.duplicatedDependencyBehavior) {
|
|
24
|
+
dedupeStrategy = packageJson.cloudpack.link.duplicatedDependencyBehavior;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
17
27
|
const availableVersions = Object.keys(entries);
|
|
18
28
|
const versionRequirements = new Set();
|
|
19
29
|
// Find if any of the duplicate entries satisfy the semver requirement of all the requiredBy entries.
|
|
@@ -30,16 +40,38 @@ export function dedupeLinkedPackages({ appMap, allDuplicates }) {
|
|
|
30
40
|
const satisfiedVersions = availableVersions
|
|
31
41
|
.filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))
|
|
32
42
|
.sort(semverCompare);
|
|
33
|
-
|
|
43
|
+
let satisfiedVersion;
|
|
44
|
+
if (dedupeStrategy === 'force-host-version') {
|
|
45
|
+
if (!rootPath) {
|
|
46
|
+
console.error('Root path for project not found and is required when using the "force-host-version" dedupe strategy.');
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// Use the app host's version of the package.
|
|
50
|
+
// Find the version of the package that belongs to the host.
|
|
51
|
+
// We assume that the host has a single version of the package.
|
|
52
|
+
const hostVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(rootPath)));
|
|
53
|
+
if (!hostVersion) {
|
|
54
|
+
console.error(`Could not find a version of "${packageName}" that is belongs to the host.`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
satisfiedVersion = hostVersion;
|
|
58
|
+
}
|
|
59
|
+
else if (dedupeStrategy === 'allow-duplication' && satisfiedVersions.length > 0) {
|
|
60
|
+
// Select the highest version that satisfies the semver requirements of all the requiredBy entries.
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
+
satisfiedVersion = satisfiedVersions.pop();
|
|
63
|
+
console.debug(`Version "${satisfiedVersion}" of "${packageName}" satisfies the semver requirements of all the requiredBy entries.`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// If the deduplication strategy allows duplicates and
|
|
67
|
+
// no version satisfies the semver requirements for all dependents,
|
|
68
|
+
// then deduplication of this package is not possible.
|
|
34
69
|
console.debug(`Could not find a version of "${packageName}" that satisfies the semver requirements of all the requiredBy entries.`);
|
|
35
70
|
continue;
|
|
36
71
|
}
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
39
|
-
const highestSatisfiedVersion = satisfiedVersions.pop();
|
|
40
|
-
entries[highestSatisfiedVersion].requiredBy = requiredBy;
|
|
72
|
+
entries[satisfiedVersion].requiredBy = requiredBy;
|
|
41
73
|
for (const version of availableVersions) {
|
|
42
|
-
if (version ==
|
|
74
|
+
if (version == satisfiedVersion) {
|
|
43
75
|
continue;
|
|
44
76
|
}
|
|
45
77
|
detachEntry({ appMap, entry: entries[version] });
|
|
@@ -47,9 +79,9 @@ export function dedupeLinkedPackages({ appMap, allDuplicates }) {
|
|
|
47
79
|
}
|
|
48
80
|
for (const requiredById of Object.keys(requiredBy)) {
|
|
49
81
|
const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);
|
|
50
|
-
appMap[requiredByName][requiredByVersion].dependencies[packageName] =
|
|
82
|
+
appMap[requiredByName][requiredByVersion].dependencies[packageName] = satisfiedVersion;
|
|
51
83
|
}
|
|
52
|
-
console.debug(`Removed versions of "${packageName}" except for "${
|
|
84
|
+
console.debug(`Removed versions of "${packageName}" except for "${satisfiedVersion}".`);
|
|
53
85
|
}
|
|
54
86
|
}
|
|
55
87
|
//# sourceMappingURL=dedupeLinkedPackages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,
|
|
1
|
+
{"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAI1D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA8E,EAC9E,OAA8C;IAE9C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,wDAAwD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9G,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAEpD,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;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E,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;YAC3F,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC;QACzF,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,wBAAwB,WAAW,iBAAiB,gBAAgB,IAAI,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["import { satisfies, compare as semverCompare } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport type { ResolveMapEntry } from '../types/ResolveMapEntry.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { detachEntry } from './detachEntry.js';\nimport type { PackageDefinitionsCache, PackageSettings } from '@ms-cloudpack/common-types';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\ntype DuplicatedDependencyBehavior = NonNullable<NonNullable<PackageSettings['link']>['duplicatedDependencyBehavior']>;\n\n/**\n * Deduplicates linked packages by removing all but the highest version,\n * that satisfies the semver requirements of all the requiredBy entries.\n */\nexport async function dedupeLinkedPackages(\n options: { appMap: PackageMap; allDuplicates: Set<string>; rootPath?: string },\n context: { packages: PackageDefinitionsCache },\n) {\n const { rootPath, appMap, allDuplicates } = options;\n const { packages } = context;\n console.debug(`The following packages were duplicated by linking:\\n ${Array.from(allDuplicates).join(', ')}`);\n for (const duplicate of allDuplicates) {\n const packageName = parseRequiredBy(duplicate).name;\n\n const entries = appMap[packageName] || {};\n\n // Sanity check to ensure that it is a duplicate.\n if (Object.keys(entries).length <= 1) {\n continue;\n }\n\n let dedupeStrategy: DuplicatedDependencyBehavior = 'allow-duplication';\n for (const entry of Object.values(entries)) {\n const packageJson = await packages.get(entry.path);\n if (packageJson?.cloudpack?.link?.duplicatedDependencyBehavior) {\n dedupeStrategy = packageJson.cloudpack.link.duplicatedDependencyBehavior;\n }\n }\n\n const availableVersions = Object.keys(entries);\n\n const versionRequirements = new Set<string>();\n // Find if any of the duplicate entries satisfy the semver requirement of all the requiredBy entries.\n const requiredBy: ResolveMapEntry['requiredBy'] = {};\n for (const entry of Object.values(entries)) {\n for (const [requiredById, range] of Object.entries(entry.requiredBy) as [`${string}@${string}`, string][]) {\n requiredBy[requiredById] = range;\n // We only care about satisfying version requirements that are already satisfied.\n if (satisfies(entry.version, range)) {\n versionRequirements.add(range);\n }\n }\n }\n\n const satisfiedVersions = availableVersions\n .filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))\n .sort(semverCompare);\n\n let satisfiedVersion: string | undefined;\n\n if (dedupeStrategy === 'force-host-version') {\n if (!rootPath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-host-version\" dedupe strategy.',\n );\n continue;\n }\n // Use the app host's version of the package.\n // Find the version of the package that belongs to the host.\n // We assume that the host has a single version of the package.\n const hostVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(rootPath)));\n\n if (!hostVersion) {\n console.error(`Could not find a version of \"${packageName}\" that is belongs to the host.`);\n continue;\n }\n\n satisfiedVersion = hostVersion;\n } else if (dedupeStrategy === 'allow-duplication' && satisfiedVersions.length > 0) {\n // Select the highest version that satisfies the semver requirements of all the requiredBy entries.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n satisfiedVersion = satisfiedVersions.pop()!;\n console.debug(\n `Version \"${satisfiedVersion}\" of \"${packageName}\" satisfies the semver requirements of all the requiredBy entries.`,\n );\n } else {\n // If the deduplication strategy allows duplicates and\n // no version satisfies the semver requirements for all dependents,\n // then deduplication of this package is not possible.\n console.debug(\n `Could not find a version of \"${packageName}\" that satisfies the semver requirements of all the requiredBy entries.`,\n );\n continue;\n }\n\n entries[satisfiedVersion].requiredBy = requiredBy;\n\n for (const version of availableVersions) {\n if (version == satisfiedVersion) {\n continue;\n }\n detachEntry({ appMap, entry: entries[version] });\n delete appMap[packageName][version];\n }\n\n for (const requiredById of Object.keys(requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n appMap[requiredByName][requiredByVersion].dependencies[packageName] = satisfiedVersion;\n }\n\n console.debug(`Removed versions of \"${packageName}\" except for \"${satisfiedVersion}\".`);\n }\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-
|
|
|
7
7
|
export declare function linkPath(options: {
|
|
8
8
|
linkedPath: LinkedPath;
|
|
9
9
|
appMap: PackageMap;
|
|
10
|
+
rootPath?: string;
|
|
10
11
|
repoDefinition?: PackageJson;
|
|
11
12
|
}, context: {
|
|
12
13
|
packages: PackageDefinitionsCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/linkPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGvF;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,cAAc,CAAC,EAAE,WAAW,CAAC;CAC9B,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,iBAsGF"}
|
|
1
|
+
{"version":3,"file":"linkPath.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/linkPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGvF;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,WAAW,CAAC;CAC9B,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,iBAsGF"}
|
|
@@ -8,7 +8,7 @@ import { dedupeLinkedPackages } from './dedupeLinkedPackages.js';
|
|
|
8
8
|
* Given a linked path, an appMap, find packages from the linked path and add them to the appMap.
|
|
9
9
|
*/
|
|
10
10
|
export async function linkPath(options, context) {
|
|
11
|
-
const { linkedPath, appMap, repoDefinition } = options;
|
|
11
|
+
const { linkedPath, appMap, rootPath, repoDefinition } = options;
|
|
12
12
|
const linkMap = await findPackagesFromPath({
|
|
13
13
|
searchPaths: [linkedPath.path],
|
|
14
14
|
discoverPackages: true,
|
|
@@ -82,7 +82,7 @@ export async function linkPath(options, context) {
|
|
|
82
82
|
allDuplicates.push(...duplicates);
|
|
83
83
|
}
|
|
84
84
|
if (linkedPath.resolveStrategy !== 'duplicate') {
|
|
85
|
-
dedupeLinkedPackages({ appMap, allDuplicates: new Set(allDuplicates) });
|
|
85
|
+
await dedupeLinkedPackages({ appMap, allDuplicates: new Set(allDuplicates), rootPath }, context);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
function isContainedInPath(path, basePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../src/createResolveMap/lin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,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,cAAc,IAAI,GAAG,CAAC;IACxB,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import type { LinkedPath } from '../types/LinkedPath.js';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport type { ResolveMapEntry } from '../types/ResolveMapEntry.js';\nimport { addLinkedEntryDependencies } from './addLinkedEntryDependencies.js';\nimport { detachEntry } from './detachEntry.js';\nimport { findPackagesFromPath } from './findPackagesFromPath.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';\nimport { dedupeLinkedPackages } from './dedupeLinkedPackages.js';\n\n/**\n * Given a linked path, an appMap, find packages from the linked path and add them to the appMap.\n */\nexport async function linkPath(\n options: {\n linkedPath: LinkedPath;\n appMap: PackageMap;\n rootPath?: string;\n repoDefinition?: PackageJson;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n) {\n const { linkedPath, appMap, rootPath, repoDefinition } = options;\n const linkMap = await findPackagesFromPath(\n {\n searchPaths: [linkedPath.path],\n discoverPackages: true,\n },\n context,\n );\n const entriesToLink: ResolveMapEntry[] = [];\n const { path, ignoredPackages = [], includeAll } = linkedPath;\n const resolutions = linkedPath.ignoreResolutions ? undefined : repoDefinition?.resolutions;\n\n // Iterate through the linkMap, looking for internal packages to link to the appMap.\n for (const [packageName, packageVersions] of Object.entries(linkMap)) {\n const appEntries = Object.values(appMap[packageName] || {});\n\n if (!appEntries.length) {\n continue;\n }\n\n const linkedEntries = Object.values(packageVersions);\n const linkedEntry = linkedEntries.length === 1 ? linkedEntries[0] : undefined;\n\n // For linked dependencies, we don't want multiple versions referenced. Remove them\n // all and add them in a second pass.\n if (\n linkedEntry &&\n !linkedEntry.isExternal &&\n ignoredPackages.indexOf(packageName) === -1 &&\n (includeAll || isContainedInPath(linkedEntry.path, path))\n ) {\n // Linked packages use an asterisk for the version description. This keeps it semver compatible with\n // anything.\n linkedEntry.version += '-linked';\n linkedEntry.isLinked = true;\n\n entriesToLink.push(linkedEntry);\n }\n }\n\n // We now have a list of paths to link. Iterate through them, add them to the appMap,\n // and ensure their dependencies are satisfied.\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n linkedEntry.requiredBy = {};\n for (const entry of existingEntries) {\n for (const [requiredById, requirement] of Object.entries(entry.requiredBy)) {\n const requiredByName = parseRequiredBy(requiredById).name;\n const linkedParentEntry = Object.values(linkMap[requiredByName] || {})[0];\n const requiredByKey = linkedParentEntry?.isLinked\n ? (`${linkedParentEntry.name}@${linkedParentEntry.version}` as const)\n : requiredById;\n linkedEntry.requiredBy[requiredByKey as `${string}@${string}`] = requirement;\n }\n }\n }\n\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n // We need to detach all existing entries from the appMap, along with their dependencies. Note - detaching just means that\n // we disconnect the entry from its parent and children. If the children have no other parents, we disconnect them as well\n // and recurse through their children.\n for (const existingEntry of existingEntries) {\n detachEntry({ appMap, entry: existingEntry });\n }\n\n // Attach the linked entry to the parents' dependencies.\n for (const requiredById of Object.keys(linkedEntry.requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n let requiredByEntry = appMap[requiredByName][requiredByVersion];\n\n // If we can't find the requiredBy entry, it likely means that the entry was already replaced with a linked entry\n // in the app map. Fall back to the first entry.\n requiredByEntry ??= Object.values(appMap[requiredByName])[0];\n\n requiredByEntry.dependencies[name] = linkedEntry.version;\n }\n\n // Add the linked entry\n appMap[linkedEntry.name] = { [linkedEntry.version]: linkedEntry };\n }\n\n const allDuplicates = [];\n\n // Once all linked entries have been added, ensure their dependencies are resolved.\n for (const linkedEntry of entriesToLink) {\n const { duplicates } = await addLinkedEntryDependencies(\n { linkedEntry, appMap: appMap, linkMap, resolutions },\n context,\n );\n allDuplicates.push(...duplicates);\n }\n\n if (linkedPath.resolveStrategy !== 'duplicate') {\n await dedupeLinkedPackages({ appMap, allDuplicates: new Set(allDuplicates), rootPath }, context);\n }\n}\n\nfunction isContainedInPath(path: string, basePath: string) {\n path = normalizePath(path);\n basePath = normalizePath(basePath);\n\n return path.startsWith(basePath);\n}\n\nfunction normalizePath(path: string) {\n let normalizedPath = slash(path);\n\n if (!normalizedPath.endsWith('/')) {\n normalizedPath += '/';\n }\n\n return normalizedPath;\n}\n"]}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Module type of a source file. Undefined implies that we can not determine the module type.
|
|
3
|
-
*/
|
|
4
|
-
export type ModuleType = 'esm' | 'cjs' | undefined;
|
|
1
|
+
import type { ModuleType } from '@ms-cloudpack/common-types';
|
|
5
2
|
export declare function detectModuleTypeFromSource(source: string): ModuleType;
|
|
6
3
|
/**
|
|
7
4
|
* Determines if the given file is commonjs or esm.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectModuleType.d.ts","sourceRoot":"","sources":["../src/detectModuleType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detectModuleType.d.ts","sourceRoot":"","sources":["../src/detectModuleType.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK7D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CA+GrE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB5E"}
|
package/lib/detectModuleType.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fsPromises from 'fs/promises';
|
|
2
2
|
import { parse } from 'acorn';
|
|
3
|
-
import { simple } from 'acorn-walk';
|
|
3
|
+
import { simple as simpleWalk } from 'acorn-walk';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { javascriptExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities';
|
|
6
6
|
const cjsExtensions = [...javascriptExtensions, ...typescriptExtensions].filter((ext) => ext.startsWith('.c'));
|
|
@@ -26,6 +26,15 @@ export function detectModuleTypeFromSource(source) {
|
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
// Basic check for AMD-style modules.
|
|
30
|
+
const firstNode = ast.body[0];
|
|
31
|
+
if (firstNode &&
|
|
32
|
+
firstNode.type === 'ExpressionStatement' &&
|
|
33
|
+
firstNode.expression.type === 'CallExpression' &&
|
|
34
|
+
firstNode.expression.callee.type === 'Identifier' &&
|
|
35
|
+
firstNode.expression.callee.name === 'define') {
|
|
36
|
+
return 'amd';
|
|
37
|
+
}
|
|
29
38
|
let isCJS = false;
|
|
30
39
|
let isESM = false;
|
|
31
40
|
const returnESM = () => {
|
|
@@ -38,7 +47,7 @@ export function detectModuleTypeFromSource(source) {
|
|
|
38
47
|
// for CommonJS, and short circuiting too soon might miss ESM syntax.
|
|
39
48
|
};
|
|
40
49
|
try {
|
|
41
|
-
|
|
50
|
+
simpleWalk(ast, {
|
|
42
51
|
// ESM checks
|
|
43
52
|
ImportDeclaration: returnESM,
|
|
44
53
|
ExportNamedDeclaration: returnESM,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectModuleType.js","sourceRoot":"","sources":["../src/detectModuleType.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"detectModuleType.js","sourceRoot":"","sources":["../src/detectModuleType.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAUrC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,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E,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4EAA4E;IAC5E,IAAI,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,IAAU;IACxC,OAAO,IAAI,CAAC,IAAI,KAAK,sBAAsB,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,IAAU;IAC9B,OAAO,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAU;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC;AACzC,CAAC","sourcesContent":["import fsPromises from 'fs/promises';\nimport type {\n AssignmentExpression,\n CallExpression,\n Identifier,\n MemberExpression,\n Node,\n Program,\n UnaryExpression,\n} from 'acorn';\nimport { parse } from 'acorn';\nimport { simple as simpleWalk } from 'acorn-walk';\nimport path from 'path';\nimport { javascriptExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities';\nimport type { ModuleType } from '@ms-cloudpack/common-types';\n\nconst cjsExtensions = [...javascriptExtensions, ...typescriptExtensions].filter((ext) => ext.startsWith('.c'));\nconst esmExtensions = [...javascriptExtensions, ...typescriptExtensions].filter((ext) => ext.startsWith('.m'));\n\nexport function detectModuleTypeFromSource(source: string): ModuleType {\n let ast: Program;\n\n try {\n ast = parse(source, {\n ecmaVersion: 'latest',\n sourceType: 'module', // Try to parse as a module first.\n });\n } catch (err) {\n // If the parse fails, try again as a script.\n try {\n ast = parse(source, {\n ecmaVersion: 'latest',\n sourceType: 'script', // Parse as a script for CommonJS.\n });\n } catch (e) {\n // If parsing fails again, the code is not valid JavaScript or too complex for a simple parse.\n return undefined;\n }\n }\n\n // Basic check for AMD-style modules.\n const firstNode = ast.body[0];\n if (\n firstNode &&\n firstNode.type === 'ExpressionStatement' &&\n firstNode.expression.type === 'CallExpression' &&\n firstNode.expression.callee.type === 'Identifier' &&\n firstNode.expression.callee.name === 'define'\n ) {\n return 'amd';\n }\n\n let isCJS = false;\n let isESM = false;\n\n const returnESM = () => {\n isESM = true;\n throw new Error('Found moduleType.');\n };\n\n const returnCJS = () => {\n isCJS = true;\n // Note, we do not throw for CJS and instead parse the full file. Sometimes ESM output can still have checks\n // for CommonJS, and short circuiting too soon might miss ESM syntax.\n };\n\n try {\n simpleWalk(ast, {\n // ESM checks\n ImportDeclaration: returnESM,\n ExportNamedDeclaration: returnESM,\n ExportAllDeclaration: returnESM,\n ExportDefaultDeclaration: returnESM,\n\n // CommonJS checks\n CallExpression(node: Node) {\n if (isCallExpression(node) && node.callee.type === 'Identifier' && node.callee.name === 'require') {\n returnCJS();\n }\n },\n Identifier(node: Node) {\n if (isIdentifier(node) && node.name === 'exports') {\n returnCJS();\n }\n },\n UnaryExpression(node: Node) {\n if (isUnaryExpression(node) && node.operator === 'typeof') {\n const argument = node.argument;\n\n // Handle expressions like `typeof exports`\n if (isIdentifier(argument) && argument.name === 'exports') {\n returnCJS();\n }\n }\n },\n AssignmentExpression(node: Node) {\n if (isAssignmentExpression(node)) {\n const left = node.left;\n // Handle expressions like `module.exports = ...`\n if (isMemberExpression(left)) {\n if (\n 'object' in left &&\n left.object.type === 'Identifier' &&\n left.object.name === 'module' &&\n isIdentifier(left.property) &&\n left.property.name === 'exports'\n ) {\n returnCJS();\n }\n // Handle expressions like `exports.someProperty = ...`\n else if ('object' in left && left.object.type === 'Identifier' && left.object.name === 'exports') {\n returnCJS();\n }\n }\n }\n },\n });\n } catch {\n /* no-op */\n }\n\n if (isESM) {\n // Note: While it's possible for a file to include both styles, we'll prefer ESM if we find it.\n return 'esm';\n } else if (isCJS) {\n return 'cjs';\n }\n\n // We didn't find either.\n return undefined;\n}\n\n/**\n * Determines if the given file is commonjs or esm.\n */\nexport async function detectModuleType(filePath: string): Promise<ModuleType> {\n // Check for explicit commonjs or ESM extensions.\n const fileExt = path.extname(filePath);\n if (cjsExtensions.includes(fileExt)) {\n return 'cjs';\n }\n if (esmExtensions.includes(fileExt)) {\n return 'esm';\n }\n\n // For typescript files which aren't explicitly cjs, return esm immediately.\n if (typescriptExtensions.includes(fileExt)) {\n return 'esm';\n }\n\n let source: string;\n try {\n source = (await fsPromises.readFile(filePath, 'utf8')).toString();\n } catch (e) {\n return undefined;\n }\n\n return detectModuleTypeFromSource(source);\n}\n\n/**\n * Type guard for CallExpression.\n */\nfunction isCallExpression(node: Node): node is CallExpression {\n return node.type === 'CallExpression';\n}\n\n/**\n * Type guard for AssignmentExpression.\n */\nfunction isAssignmentExpression(node: Node): node is AssignmentExpression {\n return node.type === 'AssignmentExpression';\n}\n\n/**\n * Type guard for MemberExpression.\n */\nfunction isMemberExpression(node: Node): node is MemberExpression {\n return node.type === 'MemberExpression';\n}\n\n/**\n * Type guard for Identifier.\n */\nfunction isIdentifier(node: Node): node is Identifier {\n return node.type === 'Identifier';\n}\n\n/**\n * Type guard for UnaryExpression.\n */\nfunction isUnaryExpression(node: Node): node is UnaryExpression {\n return node.type === 'UnaryExpression';\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExports
|
|
|
12
12
|
export { getExportsMap } from './getExportsMap.js';
|
|
13
13
|
export { ensureResolveMapEntry } from './ensureResolveMapEntry.js';
|
|
14
14
|
export { resolve } from './resolve.js';
|
|
15
|
-
export { detectModuleType
|
|
15
|
+
export { detectModuleType } from './detectModuleType.js';
|
|
16
16
|
export { isExternalPackage } from './isExternalPackage.js';
|
|
17
17
|
export { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';
|
|
18
18
|
export { getDisplayVersion } from './getDisplayVersion.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO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EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,sBAAsB;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,sBAAsB;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAA+D,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './PackageDefinitions.js';\n\n// ResolveMap creation\nexport { createResolveMap } from './createResolveMap/createResolveMap.js';\nexport type { ResolveMap } from './types/ResolveMap.js';\nexport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nexport { findResolveMapEntry } from './findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './createResolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './createResolveMap/diffResolveMaps.js';\nexport type { LinkedPath } from './types/LinkedPath.js';\n\n// ExportsMap parsing and creation\nexport { flattenExportsMap } from './flattenExportsMap.js';\nexport { createExportsMap } from './createExportsMap.js';\nexport { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExportsMapEntry.js';\nexport { getExportsMap } from './getExportsMap.js';\nexport { ensureResolveMapEntry } from './ensureResolveMapEntry.js';\n\n// Import resolution utilities\nexport { resolve } from './resolve.js';\n\n// Other package utilities\nexport { detectModuleType } from './detectModuleType.js';\nexport { isExternalPackage } from './isExternalPackage.js';\nexport { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';\nexport { getDisplayVersion } from './getDisplayVersion.js';\nexport { getVersion } from './getVersion.js';\nexport { getDependencies } from './getDependencies.js';\nexport { getUnusedDependencies } from './getUnusedDependencies.js';\nexport { findProjectRoot } from './findProjectRoot.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\nexport { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';\nexport { getSourceEntry } from './getSourceEntry.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.8.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.8.2",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
19
|
-
"@ms-cloudpack/package-overrides": "^0.9.
|
|
19
|
+
"@ms-cloudpack/package-overrides": "^0.9.5",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.2.3",
|
|
21
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
21
|
+
"@ms-cloudpack/path-utilities": "^2.7.20",
|
|
22
22
|
"@ms-cloudpack/task-reporter": "^0.14.1",
|
|
23
23
|
"acorn": "^8.11.2",
|
|
24
24
|
"acorn-walk": "^8.2.1",
|