@ms-cloudpack/package-utilities 3.1.4 → 3.1.6
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.
|
@@ -38,15 +38,17 @@ export async function linkPath(options) {
|
|
|
38
38
|
for (const linkedEntry of entriesToLink) {
|
|
39
39
|
const { name } = linkedEntry;
|
|
40
40
|
const existingEntries = Object.values(appMap[name]);
|
|
41
|
-
linkedEntry.requiredBy =
|
|
41
|
+
linkedEntry.requiredBy = {};
|
|
42
|
+
for (const entry of existingEntries) {
|
|
42
43
|
for (const [requiredById, requirement] of Object.entries(entry.requiredBy)) {
|
|
43
44
|
const [requiredByName] = parseRequiredBy(requiredById);
|
|
44
45
|
const linkedParentEntry = Object.values(linkMap[requiredByName] || {})[0];
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const requiredByKey = linkedParentEntry?.isLinked
|
|
47
|
+
? `${linkedParentEntry.name}@${linkedParentEntry.version}`
|
|
48
|
+
: requiredById;
|
|
49
|
+
linkedEntry.requiredBy[requiredByKey] = requirement;
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
}, {});
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
53
|
for (const linkedEntry of entriesToLink) {
|
|
52
54
|
const { name } = linkedEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../src/createResolveMap/linkPath.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAK9B;IACC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAA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YAC3C,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;SAC/C;QAED,wDAAwD;QACxD,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;YAC9D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;YAC1E,IAAI,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,CAAC;YAEhE,iHAAiH;YACjH,gDAAgD;YAChD,IAAI,CAAC,eAAe,EAAE;gBACpB,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5D;YAED,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;SAC1D;QAED,uBAAuB;QACvB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;KACnE;IAED,mFAAmF;IACnF,KAAK,MAAM,WAAW,IAAI,aAAa,EAAE;QACvC,MAAM,0BAA0B,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;KACtF;AACH,CAAC","sourcesContent":["import type { PackageDefinitions } from '../PackageDefinitions.js';\nimport type { PackageMap } from './PackageMap.js';\nimport { findPackagesFromPath } from './findPackagesFromPath.js';\nimport { addLinkedEntryDependencies } from './addLinkedEntryDependencies.js';\nimport type { ResolveMapEntry } from './ResolveMapEntry.js';\nimport { detachEntry } from './detachEntry.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\n\n/**\n * Given a linked path, an appMap, find packages from the linked path and add them to the appMap.\n * @param options\n */\nexport async function linkPath(options: {\n linkedPath: string;\n appMap: PackageMap;\n packages: PackageDefinitions;\n ignoredLinkedPackages?: string[];\n}) {\n const { linkedPath, appMap, packages, ignoredLinkedPackages } = options;\n const linkMap = await findPackagesFromPath({\n paths: [linkedPath],\n packages,\n discoverPackages: true,\n });\n const entriesToLink: ResolveMapEntry[] = [];\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 const linkedEntries = Object.values(packageVersions);\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 linkedEntries.length == 1 &&\n !linkedEntries[0].isExternal &&\n (!ignoredLinkedPackages || ignoredLinkedPackages.indexOf(packageName) === -1)\n ) {\n const linkedEntry = linkedEntries[0];\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\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);\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 [requiredByName, 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 if (!requiredByEntry) {\n requiredByEntry = Object.values(appMap[requiredByName])[0];\n }\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, packages });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenExportsMap.d.ts","sourceRoot":"","sources":["../src/flattenExportsMap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"flattenExportsMap.d.ts","sourceRoot":"","sources":["../src/flattenExportsMap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAKhG;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,kBAAkB,EAC9B,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,GACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBxB"}
|
package/lib/flattenExportsMap.js
CHANGED
|
@@ -37,9 +37,9 @@ function extractExports(exports, conditions, requiredConditions, exportsMap = {}
|
|
|
37
37
|
else if (exports && typeof exports === 'object') {
|
|
38
38
|
// Iterate through condition matches and go deeper if a match is found.
|
|
39
39
|
for (const condition of conditions) {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
extractExports(
|
|
40
|
+
const exportsObject = exports[condition];
|
|
41
|
+
if (exportsObject) {
|
|
42
|
+
extractExports(exportsObject, conditions, requiredConditions, exportsMap, importMatch, matchedConditions.concat(condition));
|
|
43
43
|
// Stop at the first match.
|
|
44
44
|
return exportsMap;
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenExportsMap.js","sourceRoot":"","sources":["../src/flattenExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA8B,EAC9B,UAGI,EAAE;IAEN,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC;IACvC,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE7B,IAAI,UAAU,EAAE;QACd,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;YACvB,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,GAAG,iBAAiB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;SAClH;KACF;SAAM;QACL,UAAU,GAAG,iBAAiB,CAAC;KAChC;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACpE,OAAO;YACL,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC;SAC5B,CAAC;KACH;IAED,OAAO,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;AACpE,CAAC;AAED,SA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AAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAChH,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;KACrC;AACH,CAAC","sourcesContent":["import path from 'path';\nimport type { PackageJsonExportsObject, PackageJsonExports } from '@ms-cloudpack/bundler-types';\nimport { cleanEntry } from './cleanEntry.js';\n\nconst defaultConditions = ['browser', 'module', 'import', 'default'];\n\n/**\n * Given a package definition and applicable conditions, return a flat map of package import to physical (relative) path.\n * Optionally return the exports map fully qualified with conditions intact using the `fullExports` option.\n */\nexport function flattenExportsMap(\n exportsMap: PackageJsonExports,\n options: {\n conditions?: string[];\n requiredConditions?: string[];\n } = {},\n): Record<string, string> {\n const { requiredConditions } = options;\n let { conditions } = options;\n\n if (conditions) {\n const defaultIndex = conditions.indexOf('...');\n if (defaultIndex !== -1) {\n conditions = [...conditions.slice(0, defaultIndex), ...defaultConditions, ...conditions.slice(defaultIndex + 1)];\n }\n } else {\n conditions = defaultConditions;\n }\n\n if (typeof exportsMap === 'string' && conditions.includes('default')) {\n return {\n '.': cleanEntry(exportsMap),\n };\n }\n\n return extractExports(exportsMap, conditions, requiredConditions);\n}\n\nfunction extractExports(\n exports: PackageJsonExports,\n conditions: string[],\n requiredConditions?: string[],\n exportsMap: Record<string, string> = {},\n importMatch = '.',\n matchedConditions: string[] = [],\n) {\n if (\n typeof exports === 'string' &&\n (!requiredConditions || requiredConditions.every((condition) => matchedConditions.includes(condition)))\n ) {\n addExportsEntry(exportsMap, importMatch, exports);\n } else if (Array.isArray(exports)) {\n for (const exportEntry of exports) {\n extractExports(exportEntry, conditions, requiredConditions, exportsMap, importMatch, matchedConditions);\n }\n } else if (exports && typeof exports === 'object') {\n // Iterate through condition matches and go deeper if a match is found.\n for (const condition of conditions) {\n const exportsObject = (exports as PackageJsonExportsObject)[condition];\n\n if (exportsObject) {\n extractExports(\n exportsObject as PackageJsonExports,\n conditions,\n requiredConditions,\n exportsMap,\n importMatch,\n matchedConditions.concat(condition),\n );\n // Stop at the first match.\n return exportsMap;\n }\n }\n\n // No conditions are available. Check for import entries.\n for (const [key, value] of Object.entries(exports)) {\n if (key.startsWith('.')) {\n importMatch = key;\n\n if (typeof value === 'string') {\n if (!exportsMap[importMatch] && (!requiredConditions || requiredConditions?.includes(key))) {\n addExportsEntry(exportsMap, importMatch, value);\n }\n } else if (value) {\n extractExports(value, conditions, requiredConditions, exportsMap, importMatch, [...matchedConditions, key]);\n }\n }\n }\n }\n\n return exportsMap;\n}\n\nfunction addExportsEntry(exportsMap: Record<string, string>, key: string, value: string) {\n const basename = path.basename(value);\n const isFilename = basename !== '' && basename !== '.' && !value.endsWith('/');\n\n if (!exportsMap[key] && isFilename && key.indexOf('*') === -1 && !key.endsWith('/') && value.indexOf('*') === -1) {\n exportsMap[key] = cleanEntry(value);\n }\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/parser": "^7.16.12",
|
|
17
17
|
"@babel/traverse": "^7.16.10",
|
|
18
|
-
"@ms-cloudpack/bundler-types": "^0.
|
|
18
|
+
"@ms-cloudpack/bundler-types": "^0.15.0",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.0.6",
|
|
20
|
-
"@ms-cloudpack/package-overrides": "^0.3.
|
|
21
|
-
"@ms-cloudpack/path-utilities": "^2.
|
|
20
|
+
"@ms-cloudpack/package-overrides": "^0.3.10",
|
|
21
|
+
"@ms-cloudpack/path-utilities": "^2.3.0",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.0.2",
|
|
23
23
|
"fast-glob": "^3.2.12",
|
|
24
24
|
"merge": "^2.1.1",
|