@ms-cloudpack/package-utilities 5.10.2 → 5.10.3
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/createImportMap.d.ts +0 -1
- package/lib/createImportMap.d.ts.map +1 -1
- package/lib/createImportMap.js +5 -5
- package/lib/createImportMap.js.map +1 -1
- package/lib/ensurePackageJsonDependencies.d.ts +3 -0
- package/lib/ensurePackageJsonDependencies.d.ts.map +1 -0
- package/lib/ensurePackageJsonDependencies.js +15 -0
- package/lib/ensurePackageJsonDependencies.js.map +1 -0
- package/lib/getUnusedDependencies.d.ts +7 -0
- package/lib/getUnusedDependencies.d.ts.map +1 -0
- package/lib/getUnusedDependencies.js +16 -0
- package/lib/getUnusedDependencies.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/lib/createImportMap.d.ts
CHANGED
|
@@ -20,6 +20,5 @@ export declare function createImportMap(options: {
|
|
|
20
20
|
bundleServerUrl: string;
|
|
21
21
|
sessionVersion?: number;
|
|
22
22
|
targetVersions?: Record<string, number>;
|
|
23
|
-
hashPackages?: boolean;
|
|
24
23
|
}, context: CreateImportMapContext): Promise<ImportMap>;
|
|
25
24
|
//# sourceMappingURL=createImportMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createImportMap.d.ts","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM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AK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,EACD,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,SAAS,CAAC,CAqCpB"}
|
package/lib/createImportMap.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isExternalPackage } from './isExternalPackage.js';
|
|
|
8
8
|
* Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.
|
|
9
9
|
*/
|
|
10
10
|
export async function createImportMap(options, context) {
|
|
11
|
-
const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions
|
|
11
|
+
const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions } = options;
|
|
12
12
|
const { packageImportPaths } = context;
|
|
13
13
|
const importMap = {
|
|
14
14
|
imports: {},
|
|
@@ -16,7 +16,7 @@ export async function createImportMap(options, context) {
|
|
|
16
16
|
packageImportPaths?.clear();
|
|
17
17
|
for (const resolveEntry of Object.values(resolveMap)) {
|
|
18
18
|
merge(importMap.imports, await getImportMapFromEntry({
|
|
19
|
-
options: { entry: resolveEntry, bundleServerUrl, targetVersions, sessionVersion
|
|
19
|
+
options: { entry: resolveEntry, bundleServerUrl, targetVersions, sessionVersion },
|
|
20
20
|
context,
|
|
21
21
|
}));
|
|
22
22
|
if (resolveEntry.scopedVersions) {
|
|
@@ -24,7 +24,7 @@ export async function createImportMap(options, context) {
|
|
|
24
24
|
importMap.scopes ??= {};
|
|
25
25
|
for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {
|
|
26
26
|
const importMapForEntry = await getImportMapFromEntry({
|
|
27
|
-
options: { entry: scopedEntry, bundleServerUrl, sessionVersion, targetVersions
|
|
27
|
+
options: { entry: scopedEntry, bundleServerUrl, sessionVersion, targetVersions },
|
|
28
28
|
context,
|
|
29
29
|
});
|
|
30
30
|
for (const requiredById of Object.keys(scopedEntry.requiredBy)) {
|
|
@@ -38,7 +38,7 @@ export async function createImportMap(options, context) {
|
|
|
38
38
|
}
|
|
39
39
|
async function getImportMapFromEntry(params) {
|
|
40
40
|
const { options, context } = params;
|
|
41
|
-
const { entry, bundleServerUrl, sessionVersion, targetVersions
|
|
41
|
+
const { entry, bundleServerUrl, sessionVersion, targetVersions } = options;
|
|
42
42
|
const { name } = entry;
|
|
43
43
|
const { packages, packageImportPaths, getPackageHash, config } = context;
|
|
44
44
|
const importMap = {};
|
|
@@ -62,7 +62,7 @@ async function getImportMapFromEntry(params) {
|
|
|
62
62
|
const isExternal = isExternalPackage(entry.path);
|
|
63
63
|
const targetVersion = targetVersions?.[entry.path];
|
|
64
64
|
const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;
|
|
65
|
-
const hash =
|
|
65
|
+
const hash = isExternal ? `h-${await getPackageHash(entry.path)}/` : 'h-pending/';
|
|
66
66
|
// Add the bundled entries to the import map, but prefer unbundled if the entry exists.
|
|
67
67
|
for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {
|
|
68
68
|
const resolvedFilePath = getResolvedFilePath({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAA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kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;YAC9D,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;YACxD,SAAS,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,uGAAuG;IACvG,mGAAmG;IACnG,2DAA2D;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { merge } from 'merge';\nimport type { PackageImportPaths } from './PackageImportPaths.js';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport { getExportsMap } from './getExportsMap.js';\nimport { getResolvedFilePath } from './getResolvedFilePath.js';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\n\nexport interface ImportMap {\n imports: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\n}\n\nexport type CreateImportMapContext = {\n packages: PackageDefinitionsCache;\n packageImportPaths?: PackageImportPaths;\n getPackageHash: (packagePath: string) => Promise<string>;\n config: CloudpackConfig;\n};\n\n/**\n * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.\n */\nexport async function createImportMap(\n options: {\n resolveMap: ResolveMap;\n bundleServerUrl: string;\n sessionVersion?: number;\n targetVersions?: Record<string, number>;\n },\n context: CreateImportMapContext,\n): Promise<ImportMap> {\n const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions } = options;\n const { packageImportPaths } = context;\n const importMap: ImportMap = {\n imports: {},\n };\n\n packageImportPaths?.clear();\n\n for (const resolveEntry of Object.values(resolveMap)) {\n merge(\n importMap.imports,\n await getImportMapFromEntry({\n options: { entry: resolveEntry, bundleServerUrl, targetVersions, sessionVersion },\n context,\n }),\n );\n\n if (resolveEntry.scopedVersions) {\n // Initialize scopes\n importMap.scopes ??= {};\n\n for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {\n const importMapForEntry = await getImportMapFromEntry({\n options: { entry: scopedEntry, bundleServerUrl, sessionVersion, targetVersions },\n context,\n });\n\n for (const requiredById of Object.keys(scopedEntry.requiredBy)) {\n const scopes = (importMap.scopes[`${bundleServerUrl}/${requiredById}/`] ??= {});\n merge(scopes, importMapForEntry);\n }\n }\n }\n }\n\n return importMap;\n}\n\nasync function getImportMapFromEntry(params: {\n options: {\n entry: ResolveMapEntry;\n bundleServerUrl: string;\n sessionVersion: number;\n targetVersions?: Record<string, number>;\n };\n context: CreateImportMapContext;\n}): Promise<Record<string, string>> {\n const { options, context } = params;\n const { entry, bundleServerUrl, sessionVersion, targetVersions } = options;\n const { name } = entry;\n const { packages, packageImportPaths, getPackageHash, config } = context;\n const importMap: Record<string, string> = {};\n const definition = await packages.get(entry.path);\n const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages, config });\n\n if (\n !definition ||\n !definition.version ||\n !exportsMap ||\n Object.keys(exportsMap).length === 0 ||\n name.startsWith('@types/')\n ) {\n return importMap;\n }\n\n // Get both the unbundled entries from the exports map\n const unbundledExportsMap = flattenExportsMap(exportsMap, {\n conditions: ['browser-esm'],\n requiredConditions: ['browser-esm'],\n });\n const bundledExportsMap = flattenExportsMap(exportsMap);\n const packagePrefix = `${name}@${entry.version}/`;\n const baseUrl = `${bundleServerUrl}/${packagePrefix}`;\n const isExternal = isExternalPackage(entry.path);\n const targetVersion = targetVersions?.[entry.path];\n const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;\n const hash = isExternal ? `h-${await getPackageHash(entry.path)}/` : 'h-pending/';\n\n // Add the bundled entries to the import map, but prefer unbundled if the entry exists.\n for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {\n const resolvedFilePath = getResolvedFilePath({\n entryPath: importPath,\n isExternal,\n unbundledExportsMap,\n bundledFilePath,\n bundledPrefix: `${hash}${cacheBuster}bundled/`,\n unbundledPrefix: `${hash}${cacheBuster}unbundled/`,\n });\n\n if (resolvedFilePath !== undefined) {\n const resolvedImportPath = importPath.replace('.', `${name}`);\n packageImportPaths?.add(entry.path, resolvedImportPath);\n importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;\n }\n }\n\n // Finally add a fallback for all other unexpected bundle entries. (Note, this should point to a script\n // which logs this as an error to the user and offers a way to add the entry to exports overrides.)\n // importMap[definition.name + '/'] = baseUrl + 'missing/';\n\n return importMap;\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PackageJsonDependencies } from '@ms-cloudpack/config-types';
|
|
2
|
+
export declare function ensurePackageJsonDependencies(dependencies: PackageJsonDependencies | string[] | undefined): PackageJsonDependencies;
|
|
3
|
+
//# sourceMappingURL=ensurePackageJsonDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensurePackageJsonDependencies.d.ts","sourceRoot":"","sources":["../src/ensurePackageJsonDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,uBAAuB,GAAG,MAAM,EAAE,GAAG,SAAS,GAC3D,uBAAuB,CAWzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function ensurePackageJsonDependencies(dependencies) {
|
|
2
|
+
if (!dependencies) {
|
|
3
|
+
return {};
|
|
4
|
+
}
|
|
5
|
+
else if (Array.isArray(dependencies)) {
|
|
6
|
+
return dependencies.reduce((acc, curr) => {
|
|
7
|
+
acc[curr] = '*';
|
|
8
|
+
return acc;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return dependencies;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ensurePackageJsonDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensurePackageJsonDependencies.js","sourceRoot":"","sources":["../src/ensurePackageJsonDependencies.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,6BAA6B,CAC3C,YAA4D;IAE5D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACvC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACvC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;YAChB,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAA6B,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC","sourcesContent":["import type { PackageJsonDependencies } from '@ms-cloudpack/config-types';\n\nexport function ensurePackageJsonDependencies(\n dependencies: PackageJsonDependencies | string[] | undefined,\n): PackageJsonDependencies {\n if (!dependencies) {\n return {};\n } else if (Array.isArray(dependencies)) {\n return dependencies.reduce((acc, curr) => {\n acc[curr] = '*';\n return acc;\n }, {} as PackageJsonDependencies);\n } else {\n return dependencies;\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/config-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the dependencies that are not potentially used at runtime and not considered for bundling by cloudpack
|
|
4
|
+
* (currently bundle, bundled, and optional).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getUnusedDependencies(definition: PackageJson): PackageJsonDependencies;
|
|
7
|
+
//# sourceMappingURL=getUnusedDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnusedDependencies.d.ts","sourceRoot":"","sources":["../src/getUnusedDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGvF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,WAAW,GAAG,uBAAuB,CAUtF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the dependencies that are not potentially used at runtime and not considered for bundling by cloudpack
|
|
4
|
+
* (currently bundle, bundled, and optional).
|
|
5
|
+
*/
|
|
6
|
+
export function getUnusedDependencies(definition) {
|
|
7
|
+
// This is very simple but needs to be consistent between multiple places,
|
|
8
|
+
// especially in case it needs to be changed somehow later.
|
|
9
|
+
return {
|
|
10
|
+
...definition.devDependencies,
|
|
11
|
+
...ensurePackageJsonDependencies(definition.bundleDependencies),
|
|
12
|
+
...ensurePackageJsonDependencies(definition.bundledDependencies),
|
|
13
|
+
...definition.optionalDependencies,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getUnusedDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnusedDependencies.js","sourceRoot":"","sources":["../src/getUnusedDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAuB;IAC3D,0EAA0E;IAC1E,2DAA2D;IAE3D,OAAO;QACL,GAAG,UAAU,CAAC,eAAe;QAC7B,GAAG,6BAA6B,CAAC,UAAU,CAAC,kBAAkB,CAAC;QAC/D,GAAG,6BAA6B,CAAC,UAAU,CAAC,mBAAmB,CAAC;QAChE,GAAG,UAAU,CAAC,oBAAoB;KACnC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/config-types';\nimport { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';\n\n/**\n * Get the dependencies that are not potentially used at runtime and not considered for bundling by cloudpack\n * (currently bundle, bundled, and optional).\n */\nexport function getUnusedDependencies(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\n return {\n ...definition.devDependencies,\n ...ensurePackageJsonDependencies(definition.bundleDependencies),\n ...ensurePackageJsonDependencies(definition.bundledDependencies),\n ...definition.optionalDependencies,\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export { isExternalPackage } from './isExternalPackage.js';
|
|
|
19
19
|
export { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';
|
|
20
20
|
export { getVersion } from './getVersion.js';
|
|
21
21
|
export { getDependencies } from './getDependencies.js';
|
|
22
|
+
export { getUnusedDependencies } from './getUnusedDependencies.js';
|
|
22
23
|
export { findProjectRoot } from './findProjectRoot.js';
|
|
23
24
|
export { shouldExternalizePackage } from './shouldExternalizePackage.js';
|
|
24
25
|
export { getResolvedFilePath } from './getResolvedFilePath.js';
|
|
26
|
+
export { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';
|
|
25
27
|
//# 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,EAA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,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,9 @@ export { isExternalPackage } from './isExternalPackage.js';
|
|
|
23
23
|
export { findFileInPackage } from './findFileInPackage.js';
|
|
24
24
|
export { getVersion } from './getVersion.js';
|
|
25
25
|
export { getDependencies } from './getDependencies.js';
|
|
26
|
+
export { getUnusedDependencies } from './getUnusedDependencies.js';
|
|
26
27
|
export { findProjectRoot } from './findProjectRoot.js';
|
|
27
28
|
export { shouldExternalizePackage } from './shouldExternalizePackage.js';
|
|
28
29
|
export { getResolvedFilePath } from './getResolvedFilePath.js';
|
|
30
|
+
export { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';
|
|
29
31
|
//# 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,EAA+C,MAAM,sBAAsB,CAAC;AAEpG,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,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;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,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, type CreateImportMapContext } from './createImportMap.js';\n\n// ImportMap hashing\nexport { addImportMapHash } from './addImportMapHash.js';\n\n// Import paths caching\nexport { PackageImportPaths } from './PackageImportPaths.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';\nexport { findProjectRoot } from './findProjectRoot.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\nexport { getResolvedFilePath } from './getResolvedFilePath.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,EAA+C,MAAM,sBAAsB,CAAC;AAEpG,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,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;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,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,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, type CreateImportMapContext } from './createImportMap.js';\n\n// ImportMap hashing\nexport { addImportMapHash } from './addImportMapHash.js';\n\n// Import paths caching\nexport { PackageImportPaths } from './PackageImportPaths.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';\nexport { getUnusedDependencies } from './getUnusedDependencies.js';\nexport { findProjectRoot } from './findProjectRoot.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\nexport { getResolvedFilePath } from './getResolvedFilePath.js';\nexport { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.3",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-types": "^0.24.
|
|
18
|
-
"@ms-cloudpack/config-types": "^0.
|
|
17
|
+
"@ms-cloudpack/bundler-types": "^0.24.3",
|
|
18
|
+
"@ms-cloudpack/config-types": "^0.5.0",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
20
|
-
"@ms-cloudpack/package-overrides": "^0.6.
|
|
20
|
+
"@ms-cloudpack/package-overrides": "^0.6.19",
|
|
21
21
|
"@ms-cloudpack/path-utilities": "^2.5.0",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.1.3",
|
|
23
23
|
"acorn": "^8.11.2",
|