@ms-cloudpack/package-utilities 10.0.5 → 10.1.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.
@@ -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;AAGzD,OAAO,KAAK,EAAE,uBAAuB,EAAoC,MAAM,4BAA4B,CAAC;AAK5G;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACnG,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,iBAoH/C"}
1
+ {"version":3,"file":"dedupeLinkedPackages.d.ts","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,uBAAuB,EAAgC,MAAM,4BAA4B,CAAC;AAKxG;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACnG,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,iBAoH/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"m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AAG,UAAU,CAAC;QAElD,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;YACxC,IAAI,OAAO,IAAI,gBAAgB,EAAE,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, rcompare as semverReverseCompare } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { detachEntry } from './detachEntry.js';\nimport type { PackageDefinitionsCache, PackageSettings, ResolveMapEntry } 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>; remotePath?: string; rootPath?: string },\n context: { packages: PackageDefinitionsCache },\n) {\n const { rootPath, appMap, allDuplicates, remotePath } = 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 // Find the versions that satisfy the semver requirements of all the requiredBy entries.\n // Sort the versions in descending order.\n const satisfiedVersions = availableVersions\n .filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))\n .sort(semverReverseCompare);\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 === 'force-remote-version') {\n if (!remotePath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-remote-version\" dedupe strategy.',\n );\n continue;\n }\n\n // Use the version of the package that is the remote.\n // Find the version of the package that does not belong to the host.\n // We assume that the remote has a single version of the package.\n const remoteVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(remotePath)));\n\n if (!remoteVersion) {\n console.error(`Could not find a version of \"${packageName}\" that is belongs to the remote.`);\n continue;\n }\n\n satisfiedVersion = remoteVersion;\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 satisfiedVersion = satisfiedVersions[0];\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"]}
1
+ {"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../src/createResolveMap/dedupeLinkedPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAErE,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,oBAAo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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, rcompare as semverReverseCompare } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { detachEntry } from './detachEntry.js';\nimport type { PackageDefinitionsCache, ResolveMapEntry, LinkOptions } from '@ms-cloudpack/common-types';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\ntype DuplicatedDependencyBehavior = NonNullable<LinkOptions['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>; remotePath?: string; rootPath?: string },\n context: { packages: PackageDefinitionsCache },\n) {\n const { rootPath, appMap, allDuplicates, remotePath } = 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 // Find the versions that satisfy the semver requirements of all the requiredBy entries.\n // Sort the versions in descending order.\n const satisfiedVersions = availableVersions\n .filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))\n .sort(semverReverseCompare);\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 === 'force-remote-version') {\n if (!remotePath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-remote-version\" dedupe strategy.',\n );\n continue;\n }\n\n // Use the version of the package that is the remote.\n // Find the version of the package that does not belong to the host.\n // We assume that the remote has a single version of the package.\n const remoteVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(remotePath)));\n\n if (!remoteVersion) {\n console.error(`Could not find a version of \"${packageName}\" that is belongs to the remote.`);\n continue;\n }\n\n satisfiedVersion = remoteVersion;\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 satisfiedVersion = satisfiedVersions[0];\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"]}
package/lib/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export { getUnusedDependencies } from './getUnusedDependencies.js';
20
20
  export { findProjectRoot } from './findProjectRoot.js';
21
21
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
22
22
  export { getSourceEntry } from './getSourceEntry.js';
23
+ export { resolveModule } from './resolveModule.js';
23
24
  export { mergeArrayDefaults } from './mergeArrayDefaults.js';
24
25
  export { mergeObjects } from './mergeObjects.js';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -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,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,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AO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/lib/index.js CHANGED
@@ -23,6 +23,7 @@ export { getUnusedDependencies } from './getUnusedDependencies.js';
23
23
  export { findProjectRoot } from './findProjectRoot.js';
24
24
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
25
25
  export { getSourceEntry } from './getSourceEntry.js';
26
+ export { resolveModule } from './resolveModule.js';
26
27
  // Object utilities which could be moved to a separate package if we add more of them
27
28
  export { mergeArrayDefaults } from './mergeArrayDefaults.js';
28
29
  export { mergeObjects } from './mergeObjects.js';
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;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qFAAqF;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './PackageDefinitions.js';\n\n// ResolveMap creation\nexport { createResolveMap } from './createResolveMap/createResolveMap.js';\nexport type { ResolveMap, ResolveMapEntry, LinkedPath } from '@ms-cloudpack/common-types';\nexport { findResolveMapEntry } from './findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './createResolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './createResolveMap/diffResolveMaps.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 { getSourceEntry } from './getSourceEntry.js';\n\n// Object utilities which could be moved to a separate package if we add more of them\nexport { mergeArrayDefaults } from './mergeArrayDefaults.js';\nexport { mergeObjects } from './mergeObjects.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;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qFAAqF;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './PackageDefinitions.js';\n\n// ResolveMap creation\nexport { createResolveMap } from './createResolveMap/createResolveMap.js';\nexport type { ResolveMap, ResolveMapEntry, LinkedPath } from '@ms-cloudpack/common-types';\nexport { findResolveMapEntry } from './findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './createResolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './createResolveMap/diffResolveMaps.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 { getSourceEntry } from './getSourceEntry.js';\nexport { resolveModule } from './resolveModule.js';\n\n// Object utilities which could be moved to a separate package if we add more of them\nexport { mergeArrayDefaults } from './mergeArrayDefaults.js';\nexport { mergeObjects } from './mergeObjects.js';\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
3
+ * @returns - The resolved file url as a string.
4
+ */
5
+ export declare function resolveModule(params: {
6
+ importSpecifier: string;
7
+ parentUrl: string;
8
+ }): string;
9
+ //# sourceMappingURL=resolveModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveModule.d.ts","sourceRoot":"","sources":["../src/resolveModule.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK5F"}
@@ -0,0 +1,15 @@
1
+ import { moduleResolve } from 'import-meta-resolve';
2
+ import { pathToFileURL } from 'url';
3
+ // Conditions used for resolution if the package has an exports map.
4
+ // More could be added later if desired ("default" is implicitly included).
5
+ const conditions = new Set(['import', 'require', 'node']);
6
+ /**
7
+ * Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
8
+ * @returns - The resolved file url as a string.
9
+ */
10
+ export function resolveModule(params) {
11
+ const { importSpecifier, parentUrl } = params;
12
+ const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);
13
+ return resolvedUrl.toString();
14
+ }
15
+ //# sourceMappingURL=resolveModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveModule.js","sourceRoot":"","sources":["../src/resolveModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,oEAAoE;AACpE,2EAA2E;AAC3E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAsD;IAClF,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAE9C,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACzF,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import { moduleResolve } from 'import-meta-resolve';\nimport { pathToFileURL } from 'url';\n\n// Conditions used for resolution if the package has an exports map.\n// More could be added later if desired (\"default\" is implicitly included).\nconst conditions = new Set(['import', 'require', 'node']);\n\n/**\n * Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.\n * @returns - The resolved file url as a string.\n */\nexport function resolveModule(params: { importSpecifier: string; parentUrl: string }): string {\n const { importSpecifier, parentUrl } = params;\n\n const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);\n return resolvedUrl.toString();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "10.0.5",
3
+ "version": "10.1.0",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,15 +14,16 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/common-types": "^0.19.5",
17
+ "@ms-cloudpack/common-types": "^0.19.7",
18
18
  "@ms-cloudpack/json-utilities": "^0.1.7",
19
- "@ms-cloudpack/package-overrides": "^0.9.28",
19
+ "@ms-cloudpack/package-overrides": "^0.9.30",
20
20
  "@ms-cloudpack/path-string-parsing": "^1.2.4",
21
- "@ms-cloudpack/path-utilities": "^2.7.42",
21
+ "@ms-cloudpack/path-utilities": "^2.7.44",
22
22
  "@ms-cloudpack/task-reporter": "^0.14.4",
23
23
  "acorn": "^8.11.2",
24
24
  "acorn-walk": "^8.2.1",
25
25
  "fast-glob": "^3.2.12",
26
+ "import-meta-resolve": "^4.0.0",
26
27
  "resolve": "^1.22.0",
27
28
  "semver": "^7.6.0",
28
29
  "workspace-tools": "^0.36.4"