@ms-cloudpack/package-utilities 5.1.11 → 5.1.12
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/addLinkedEntryDependencies.d.ts.map +1 -1
- package/lib/createResolveMap/addLinkedEntryDependencies.js +2 -4
- package/lib/createResolveMap/addLinkedEntryDependencies.js.map +1 -1
- package/lib/createResolveMap/findPackagesFromPath.d.ts.map +1 -1
- package/lib/createResolveMap/findPackagesFromPath.js +5 -7
- package/lib/createResolveMap/findPackagesFromPath.js.map +1 -1
- package/lib/createResolveMap/linkPath.d.ts.map +1 -1
- package/lib/createResolveMap/linkPath.js +16 -15
- package/lib/createResolveMap/linkPath.js.map +1 -1
- package/lib/getDependencies.d.ts +7 -0
- package/lib/getDependencies.d.ts.map +1 -0
- package/lib/getDependencies.js +13 -0
- package/lib/getDependencies.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addLinkedEntryDependencies.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"addLinkedEntryDependencies.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE;IACP,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,eAAe,CAAC;CAC9B,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,iBAiFF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { satisfies } from 'semver';
|
|
2
|
+
import { getDependencies } from '../getDependencies.js';
|
|
2
3
|
/**
|
|
3
4
|
* Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,
|
|
4
5
|
* preferring packageMap dependencies over linkedMap dependencies.
|
|
@@ -19,10 +20,7 @@ export async function addLinkedEntryDependencies(options, context) {
|
|
|
19
20
|
const entry = entriesToVisit.pop();
|
|
20
21
|
const { name, version, dependencies } = entry;
|
|
21
22
|
const linkDefinition = await packages.get(entry.path);
|
|
22
|
-
const versionRequirements = {
|
|
23
|
-
...(linkDefinition?.dependencies || {}),
|
|
24
|
-
...(linkDefinition?.peerDependencies || {}),
|
|
25
|
-
};
|
|
23
|
+
const versionRequirements = getDependencies(linkDefinition || {});
|
|
26
24
|
// Iterate through the dependencies of the linked package.
|
|
27
25
|
for (const [dependencyName, linkedDependencyVersion] of Object.entries(dependencies)) {
|
|
28
26
|
const versionRequirement = versionRequirements[dependencyName];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addLinkedEntryDependencies.js","sourceRoot":"","sources":["../../src/createResolveMap/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"addLinkedEntryDependencies.js","sourceRoot":"","sources":["../../src/createResolveMap/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,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AAC,CAAC,EAAE,EAAE,CAC9E,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,CACzC,CAAC;oBACF,IAAI,eAAe,EAAE;wBACnB,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;wBACvD,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,uBAAuB,CAAC;wBAC7D,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC;wBAC5E,mDAAmD;wBACnD,OAAO,CAAC,eAAe,CAAC,CAAC;qBAC1B;iBACF;aACF;SACF;KACF;AACH,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { satisfies } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport type { ResolveMapEntry } from '../types/ResolveMapEntry.js';\nimport { getDependencies } from '../getDependencies.js';\n\n/**\n * Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,\n * preferring packageMap dependencies over linkedMap dependencies.\n */\nexport async function addLinkedEntryDependencies(\n options: {\n appMap: PackageMap;\n linkMap: PackageMap;\n linkedEntry: ResolveMapEntry;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n) {\n const { appMap, linkMap, linkedEntry } = options;\n const { packages } = context;\n const visitedEntryPaths = new Set<string>(linkedEntry.path);\n const entriesToVisit: ResolveMapEntry[] = [linkedEntry];\n\n function enqueue(newEntry: ResolveMapEntry) {\n if (!visitedEntryPaths.has(newEntry.path)) {\n visitedEntryPaths.add(newEntry.path);\n entriesToVisit.push(newEntry);\n }\n }\n\n while (entriesToVisit.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked the length\n const entry = entriesToVisit.pop()!;\n\n const { name, version, dependencies } = entry;\n\n const linkDefinition = await packages.get(entry.path);\n const versionRequirements = getDependencies(linkDefinition || {});\n\n // Iterate through the dependencies of the linked package.\n for (const [dependencyName, linkedDependencyVersion] of Object.entries(dependencies)) {\n const versionRequirement = versionRequirements[dependencyName];\n if (!versionRequirement) {\n continue;\n }\n\n const appVersions = appMap[dependencyName];\n\n if (!appVersions) {\n // The app does not have any version of this dependency, so we need to bring over the version\n // used by the linkedEntry.\n const dependencyEntry = linkMap[dependencyName]?.[linkedDependencyVersion];\n if (dependencyEntry) {\n appMap[dependencyName] = { [linkedDependencyVersion]: dependencyEntry };\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n\n // Recurse through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n } else {\n // We have one or more versions of this dependency already. If a sufficient version\n // of the dependency is already in the appMap, we we just need to update the linkedEntry's\n // dependency and the dependency's requiredBy record for the parent.\n const appDependencyVersions = Object.values(appVersions);\n\n if (appDependencyVersions.length === 1 && !appDependencyVersions[0]?.isExternal) {\n continue;\n }\n\n // See if an existing version of the dependency satisfies the semver.\n const appDependencyEntry = appDependencyVersions.find(\n (e) => e.isLinked || satisfies(e.version, versionRequirement),\n );\n\n if (appDependencyEntry) {\n // If the dependency satisfies the semver, use that!\n entry.dependencies[dependencyName] = appDependencyEntry.version;\n appDependencyEntry.requiredBy[`${name}@${version}`] = versionRequirement;\n\n enqueue(appDependencyEntry);\n } else {\n // We have at least one version of this dependency but nothing satisfies the requirement.\n // We need to introduce a duplicate. During the final pass, we will remove non-required deps.\n const dependencyEntry = Object.values(linkMap[dependencyName] || {}).find((e) =>\n satisfies(e.version, versionRequirement),\n );\n if (dependencyEntry) {\n appVersions[dependencyEntry.version] = dependencyEntry;\n entry.dependencies[dependencyName] = linkedDependencyVersion;\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n // Recursive through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPackagesFromPath.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/findPackagesFromPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAe,MAAM,6BAA6B,CAAC;AAOxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"findPackagesFromPath.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/findPackagesFromPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAe,MAAM,6BAA6B,CAAC;AAOxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IACP;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,EACD,OAAO,EAAE;IACP;;OAEG;IACH,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,UAAU,CAAC,CA0CrB"}
|
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { findGitRoot } from 'workspace-tools';
|
|
5
5
|
import { findPackage } from '../findPackage.js';
|
|
6
6
|
import { isExternalPackage } from '../isExternalPackage.js';
|
|
7
|
+
import { getDependencies } from '../getDependencies.js';
|
|
7
8
|
/**
|
|
8
9
|
* Find all packages from a given path. We do this by walking the dependency tree
|
|
9
10
|
* of the app to build a map of all packages and their dependencies.
|
|
@@ -25,13 +26,13 @@ export async function findPackagesFromPath(options, context) {
|
|
|
25
26
|
/* ignore */
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
let pathsToVisit;
|
|
29
30
|
if (discoverPackages) {
|
|
30
31
|
const packagePaths = await glob('**/package.json', { cwd: searchPath, ignore: ['**/node_modules/**'] });
|
|
31
|
-
pathsToVisit
|
|
32
|
+
pathsToVisit = packagePaths.map((p) => path.dirname(path.join(searchPath, p)));
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
pathsToVisit
|
|
35
|
+
pathsToVisit = [searchPath];
|
|
35
36
|
}
|
|
36
37
|
while (pathsToVisit.length) {
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked length
|
|
@@ -62,10 +63,7 @@ async function visitPackage(options, context) {
|
|
|
62
63
|
const { name, version } = packageDefinition;
|
|
63
64
|
const entry = ensurePackageEntry({ packagePath: packagePath, packageMap, definition: packageDefinition });
|
|
64
65
|
// Add all dependencies to the list of paths to visit.
|
|
65
|
-
const dependencies =
|
|
66
|
-
...(packageDefinition.dependencies || {}),
|
|
67
|
-
...(packageDefinition.peerDependencies || {}),
|
|
68
|
-
};
|
|
66
|
+
const dependencies = getDependencies(packageDefinition);
|
|
69
67
|
const dependencyPaths = [];
|
|
70
68
|
for (const [dependencyName, versionRequirement] of Object.entries(dependencies)) {
|
|
71
69
|
const dependencyPackage = await findPackage({ dependencyName, startPath: packagePath, gitRootPath }, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPackagesFromPath.js","sourceRoot":"","sources":["../../src/createResolveMap/findPackagesFromPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"findPackagesFromPath.js","sourceRoot":"","sources":["../../src/createResolveMap/findPackagesFromPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,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G,GAAG,EAAE,GAAG,UAAU,CAAC;IAEzD,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAExB,IAAI,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE;QACV,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG;YAClC,IAAI;YACJ,OAAO;YACP,IAAI,EAAE,WAAW;YACjB,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,EAAE;SACf,CAAC;QAEF,IAAI,iBAAiB,CAAC,WAAW,CAAC,EAAE;YAClC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;SACzB;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/bundler-types';\nimport { isFolder } from '@ms-cloudpack/path-utilities';\nimport glob from 'fast-glob';\nimport path from 'path';\nimport { findGitRoot } from 'workspace-tools';\nimport { findPackage } from '../findPackage.js';\nimport { isExternalPackage } from '../isExternalPackage.js';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport type { ResolveMapEntry } from '../types/ResolveMapEntry.js';\nimport { getDependencies } from '../getDependencies.js';\n\n/**\n * Find all packages from a given path. We do this by walking the dependency tree\n * of the app to build a map of all packages and their dependencies.\n */\nexport async function findPackagesFromPath(\n options: {\n /**\n * Paths to search for package.json files and traverse their dependencies to build a PackageMap.\n */\n searchPaths: string[];\n\n /**\n * Where to stop looking for packages. If not specified, will look for a git root. If one is not\n * found, will use the first path in the paths array.\n */\n gitRootPath?: string;\n\n /**\n * If true will glob for all package.json files in the path and add them to the map.\n */\n discoverPackages?: boolean;\n },\n context: {\n /**\n * Package cache.\n */\n packages: PackageDefinitionsCache;\n },\n): Promise<PackageMap> {\n const { searchPaths, discoverPackages } = options;\n const packageMap: PackageMap = {};\n const visitedPaths = new Set<string>();\n\n for (const searchPath of searchPaths) {\n if (!(await isFolder(searchPath))) {\n throw new Error(`Path ${searchPath} is not a folder.`);\n }\n\n let { gitRootPath } = options;\n if (!gitRootPath) {\n try {\n gitRootPath = findGitRoot(searchPath);\n } catch (e) {\n /* ignore */\n }\n }\n\n let pathsToVisit: string[];\n\n if (discoverPackages) {\n const packagePaths = await glob('**/package.json', { cwd: searchPath, ignore: ['**/node_modules/**'] });\n\n pathsToVisit = packagePaths.map((p) => path.dirname(path.join(searchPath, p)));\n } else {\n pathsToVisit = [searchPath];\n }\n\n while (pathsToVisit.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked length\n const packagePath = pathsToVisit.shift()!;\n if (!visitedPaths.has(packagePath)) {\n visitedPaths.add(packagePath);\n\n const dependencyPaths = await visitPackage({ packagePath, packageMap, gitRootPath }, context);\n pathsToVisit.push(...dependencyPaths);\n }\n }\n }\n\n return packageMap;\n}\n\n/**\n * Visit a package path, and add entries for the package and its dependencies to `packageMap`.\n * Returns a list of additional dependency paths to visit.\n */\nasync function visitPackage(\n options: {\n packagePath: string;\n packageMap: PackageMap;\n gitRootPath: string | undefined;\n },\n context: Parameters<typeof findPackage>[1],\n) {\n const { packagePath, packageMap, gitRootPath } = options;\n const { packages } = context;\n\n const packageDefinition = await packages.get(packagePath);\n if (!packageDefinition) {\n throw new Error(`Could not find package definition at \"${packagePath}\".`);\n }\n if (!(packageDefinition.name && packageDefinition.version)) {\n return [];\n }\n\n const { name, version } = packageDefinition;\n const entry = ensurePackageEntry({ packagePath: packagePath, packageMap, definition: packageDefinition });\n\n // Add all dependencies to the list of paths to visit.\n const dependencies = getDependencies(packageDefinition) as Record<string, string>;\n\n const dependencyPaths: string[] = [];\n\n for (const [dependencyName, versionRequirement] of Object.entries(dependencies)) {\n const dependencyPackage = await findPackage({ dependencyName, startPath: packagePath, gitRootPath }, context);\n if (!dependencyPackage) {\n if (packageDefinition.peerDependencies?.[dependencyName]) {\n // Ignore missing peer dependencies\n continue;\n }\n throw new Error(`Could not find dependency \"${dependencyName}\" at \"${packagePath}\".`);\n }\n\n const { packagePath: dependencyPath, definition: dependencyDefinition } = dependencyPackage;\n\n if (!(dependencyDefinition.name && dependencyDefinition.version)) {\n throw new Error(`\"${dependencyPath}/package.json\" is missing a name or version.`);\n }\n\n const dependencyEntry = ensurePackageEntry({\n packagePath: dependencyPath,\n packageMap,\n definition: dependencyDefinition,\n });\n\n entry.dependencies[dependencyDefinition.name] = dependencyDefinition.version;\n dependencyEntry.requiredBy[`${name}@${version}`] = versionRequirement;\n\n dependencyPaths.push(dependencyPath);\n }\n\n return dependencyPaths;\n}\n\n/**\n * If `packageMap` doesn't already have an entry for this package name and version, create one\n * and add it to `packageMap`. Returns the entry.\n */\nfunction ensurePackageEntry(options: {\n packagePath: string;\n packageMap: PackageMap;\n definition: PackageJson;\n}): ResolveMapEntry {\n const { packagePath = '', packageMap, definition } = options;\n const { name = '_no_name_', version = '*' } = definition;\n\n packageMap[name] ??= {};\n\n let entry = packageMap[name][version];\n if (!entry) {\n entry = packageMap[name][version] = {\n name,\n version,\n path: packagePath,\n dependencies: {},\n requiredBy: {},\n };\n\n if (isExternalPackage(packagePath)) {\n entry.isExternal = true;\n }\n }\n\n return entry;\n}\n"]}
|
|
@@ -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,MAAM,6BAA6B,CAAC;AAE3E;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;CACpB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,
|
|
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,MAAM,6BAA6B,CAAC;AAE3E;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;CACpB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,iBA2FF"}
|
|
@@ -17,21 +17,22 @@ export async function linkPath(options, context) {
|
|
|
17
17
|
// Iterate through the linkMap, looking for internal packages to link to the appMap.
|
|
18
18
|
for (const [packageName, packageVersions] of Object.entries(linkMap)) {
|
|
19
19
|
const appEntries = Object.values(appMap[packageName] || {});
|
|
20
|
-
if (appEntries.length) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
if (!appEntries.length) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const linkedEntries = Object.values(packageVersions);
|
|
24
|
+
const linkedEntry = linkedEntries.length === 1 ? linkedEntries[0] : undefined;
|
|
25
|
+
// For linked dependencies, we don't want multiple versions referenced. Remove them
|
|
26
|
+
// all and add them in a second pass.
|
|
27
|
+
if (linkedEntry &&
|
|
28
|
+
!linkedEntry.isExternal &&
|
|
29
|
+
ignoredPackages.indexOf(packageName) === -1 &&
|
|
30
|
+
(includeAll || isContainedInPath(linkedEntry.path, path))) {
|
|
31
|
+
// Linked packages use an asterisk for the version description. This keeps it semver compatible with
|
|
32
|
+
// anything.
|
|
33
|
+
linkedEntry.version += '-linked';
|
|
34
|
+
linkedEntry.isLinked = true;
|
|
35
|
+
entriesToLink.push(linkedEntry);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
// We now have a list of paths to link. Iterate through them, add them to the appMap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../src/createResolveMap/linkPath.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAG1D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAGC,EACD,OAEC;IAED,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,OAAO,GAAG,MAAM,oBAAoB,CACxC;QACE,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAC9B,gBAAgB,EAAE,IAAI;KACvB,EACD,OAAO,CACR,CAAC;IACF,MAAM,aAAa,GAAsB,EAAE,CAAC;IAC5C,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;IAE9D,oFAAoF;IACpF,KAAK,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACpE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QAE5D,IAAI,UAAU,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../src/create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AAC,CAAC;AACnC,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAEjC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,cAAc,IAAI,GAAG,CAAC;KACvB;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 } from '@ms-cloudpack/bundler-types';\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 },\n context: {\n packages: PackageDefinitionsCache;\n },\n) {\n const { linkedPath, appMap } = 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\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 dependences. 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 // Once all linked entries have been added, ensure their dependencies are resolved.\n for (const linkedEntry of entriesToLink) {\n await addLinkedEntryDependencies({ linkedEntry, appMap: appMap, linkMap }, 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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack
|
|
4
|
+
* (currently prod and peer).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getDependencies(definition: PackageJson): PackageJsonDependencies;
|
|
7
|
+
//# sourceMappingURL=getDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDependencies.d.ts","sourceRoot":"","sources":["../src/getDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAExF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,uBAAuB,CAOhF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack
|
|
3
|
+
* (currently prod and peer).
|
|
4
|
+
*/
|
|
5
|
+
export function getDependencies(definition) {
|
|
6
|
+
// This is very simple but needs to be consistent between multiple places,
|
|
7
|
+
// especially in case it needs to be changed somehow later.
|
|
8
|
+
return {
|
|
9
|
+
...definition.dependencies,
|
|
10
|
+
...definition.peerDependencies,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDependencies.js","sourceRoot":"","sources":["../src/getDependencies.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,UAAuB;IACrD,0EAA0E;IAC1E,2DAA2D;IAC3D,OAAO;QACL,GAAG,UAAU,CAAC,YAAY;QAC1B,GAAG,UAAU,CAAC,gBAAgB;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/bundler-types';\n\n/**\n * Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack\n * (currently prod and peer).\n */\nexport function getDependencies(definition: PackageJson): PackageJsonDependencies {\n // This is very simple but needs to be consistent between multiple places,\n // especially in case it needs to be changed somehow later.\n return {\n ...definition.dependencies,\n ...definition.peerDependencies,\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ export { detectModuleType, type ModuleType } from './detectModuleType.js';
|
|
|
16
16
|
export { isExternalPackage } from './isExternalPackage.js';
|
|
17
17
|
export { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';
|
|
18
18
|
export { getVersion } from './getVersion.js';
|
|
19
|
+
export { getDependencies } from './getDependencies.js';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
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,EAA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O,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -18,4 +18,5 @@ export { detectModuleType } from './detectModuleType.js';
|
|
|
18
18
|
export { isExternalPackage } from './isExternalPackage.js';
|
|
19
19
|
export { findFileInPackage } from './findFileInPackage.js';
|
|
20
20
|
export { getVersion } from './getVersion.js';
|
|
21
|
+
export { getDependencies } from './getDependencies.js';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
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;AAEnD,qBAAqB;AACrB,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAEvE,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAA+D,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,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';\n\n// ImportMap creation\nexport { createImportMap, type ImportMap } from './createImportMap.js';\n\n// Import resolution utilities\nexport { resolve } from './resolve.js';\n\n// Other package utilities\nexport { detectModuleType, type ModuleType } from './detectModuleType.js';\nexport { isExternalPackage } from './isExternalPackage.js';\nexport { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';\nexport { getVersion } from './getVersion.js';\n"]}
|
|
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;AAEnD,qBAAqB;AACrB,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAEvE,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAA+D,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,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';\n\n// ImportMap creation\nexport { createImportMap, type ImportMap } from './createImportMap.js';\n\n// Import resolution utilities\nexport { resolve } from './resolve.js';\n\n// Other package utilities\nexport { detectModuleType, type ModuleType } from './detectModuleType.js';\nexport { isExternalPackage } from './isExternalPackage.js';\nexport { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';\nexport { getVersion } from './getVersion.js';\nexport { getDependencies } from './getDependencies.js';\n"]}
|