@ms-cloudpack/package-utilities 5.1.13 → 5.2.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.
@@ -5,6 +5,11 @@ export interface ImportMap {
5
5
  imports: Record<string, string>;
6
6
  scopes?: Record<string, Record<string, string>>;
7
7
  }
8
+ export type CreateImportMapContext = {
9
+ packages: PackageDefinitionsCache;
10
+ packageImportPaths?: PackageImportPaths;
11
+ getPackageHash: (packagePath: string) => Promise<string>;
12
+ };
8
13
  /**
9
14
  * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.
10
15
  */
@@ -14,8 +19,5 @@ export declare function createImportMap(options: {
14
19
  sessionVersion?: number;
15
20
  targetVersions?: Record<string, number>;
16
21
  hashPackages?: boolean;
17
- }, context: {
18
- packages: PackageDefinitionsCache;
19
- packageImportPaths?: PackageImportPaths;
20
- }): Promise<ImportMap>;
22
+ }, context: CreateImportMapContext): Promise<ImportMap>;
21
23
  //# 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,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAOxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CA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ackage } from './isExternalPackage.js';
8
8
  */
9
9
  export async function createImportMap(options, context) {
10
10
  const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions, hashPackages } = options;
11
- const { packages, packageImportPaths } = context;
11
+ const { packageImportPaths } = context;
12
12
  const importMap = {
13
13
  imports: {},
14
14
  };
15
15
  packageImportPaths?.clear();
16
16
  for (const resolveEntry of Object.values(resolveMap)) {
17
- merge(importMap.imports, await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages));
17
+ merge(importMap.imports, await getImportMapFromEntry({
18
+ options: { entry: resolveEntry, bundleServerUrl, targetVersions, sessionVersion, hashPackages },
19
+ context,
20
+ }));
18
21
  if (resolveEntry.scopedVersions) {
19
22
  // Initialize scopes
20
23
  importMap.scopes ??= {};
21
24
  for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {
22
- const importMapForEntry = await getImportMapFromEntry(scopedEntry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages);
25
+ const importMapForEntry = await getImportMapFromEntry({
26
+ options: { entry: scopedEntry, bundleServerUrl, sessionVersion, targetVersions, hashPackages },
27
+ context,
28
+ });
23
29
  for (const requiredById of Object.keys(scopedEntry.requiredBy)) {
24
30
  const scopes = (importMap.scopes[`${bundleServerUrl}/${requiredById}/`] ??= {});
25
31
  merge(scopes, importMapForEntry);
@@ -29,7 +35,10 @@ export async function createImportMap(options, context) {
29
35
  }
30
36
  return importMap;
31
37
  }
32
- async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages) {
38
+ async function getImportMapFromEntry(params) {
39
+ const { options, context } = params;
40
+ const { entry, bundleServerUrl, sessionVersion, targetVersions, hashPackages } = options;
41
+ const { packages, packageImportPaths, getPackageHash } = context;
33
42
  const importMap = {};
34
43
  const definition = await packages.get(entry.path);
35
44
  const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });
@@ -52,7 +61,7 @@ async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVe
52
61
  const isExternal = isExternalPackage(entry.path);
53
62
  const targetVersion = targetVersions?.[entry.path];
54
63
  const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;
55
- const hash = hashPackages ? (isExternal ? `h-${await packages.getHash(entry.path)}/` : 'h-pending/') : '';
64
+ const hash = hashPackages ? (isExternal ? `h-${await getPackageHash(entry.path)}/` : 'h-pending/') : '';
56
65
  // Add the bundled entries to the import map, but prefer unbundled if the entry exists.
57
66
  for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {
58
67
  const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQ3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAMC,EACD,OAGC;IAED,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAClG,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,SAAS,GAAc;QAC3B,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,kBAAkB,EAAE,KAAK,EAAE,CAAC;IAE5B,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QACpD,KAAK,CACH,SAAS,CAAC,OAAO,EACjB,MAAM,qBAA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AAa,iBAAiB,EAAE,CAAC,CAAC,CAAC,WAAW,eAAe,EAAE,CAAC;QAE3G,gBAAgB,GAAG,GAAG,IAAI,GAAG,WAAW,GAAG,gBAAgB,EAAE,CAAC;QAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAE3C,qBAAqB;QACrB,IAAI,CAAC,iBAAiB,EAAE;YACtB,uBAAuB;YACvB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACtC,SAAS;aACV;YAED,0EAA0E;YAC1E,IAAI,GAAG,KAAK,KAAK,EAAE;gBACjB,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAC1B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC9B,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAC9E,CAAC;aACH;YAED,kDAAkD;YAClD,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACzD;QAED,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QACzE,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACxD,SAAS,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;KACzE;IAED,uGAAuG;IACvG,mGAAmG;IACnG,2DAA2D;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nimport { merge } from 'merge';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport path from 'path';\nimport { getExportsMap } from './getExportsMap.js';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport type { PackageImportPaths } from './PackageImportPaths.js';\n\nexport interface ImportMap {\n imports: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\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 hashPackages?: boolean;\n },\n context: {\n packages: PackageDefinitionsCache;\n packageImportPaths?: PackageImportPaths;\n },\n): Promise<ImportMap> {\n const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions, hashPackages } = options;\n const { packages, 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 resolveEntry,\n bundleServerUrl,\n packages,\n sessionVersion,\n packageImportPaths,\n targetVersions,\n hashPackages,\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 scopedEntry,\n bundleServerUrl,\n packages,\n sessionVersion,\n packageImportPaths,\n targetVersions,\n hashPackages,\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(\n entry: ResolveMapEntry,\n bundleServerUrl: string,\n packages: PackageDefinitionsCache,\n sessionVersion: number,\n packageImportPaths?: PackageImportPaths,\n targetVersions?: Record<string, number>,\n hashPackages?: boolean,\n): Promise<Record<string, string>> {\n const importMap: Record<string, string> = {};\n const definition = await packages.get(entry.path);\n const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });\n\n if (\n !definition ||\n !definition.name ||\n !definition.version ||\n !exportsMap ||\n Object.keys(exportsMap).length === 0 ||\n definition.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 = `${entry.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 = hashPackages ? (isExternal ? `h-${await packages.getHash(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 unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`;\n\n resolvedFilePath = `${hash}${cacheBuster}${resolvedFilePath}`;\n const ext = path.extname(resolvedFilePath);\n\n // For bundled files:\n if (!unbundledFilePath) {\n // Ignore .d.ts entries\n if (resolvedFilePath.endsWith('.d.ts')) {\n continue;\n }\n\n // We always expect responses to come back as javascript (.js extensions.)\n if (ext !== '.js') {\n resolvedFilePath = path.join(\n path.dirname(resolvedFilePath),\n path.basename(resolvedFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'),\n );\n }\n\n // Plus signs should be replaced with underscores.\n resolvedFilePath = resolvedFilePath.replace(/\\+/g, '_');\n }\n\n const resolvedImportPath = importPath.replace('.', `${definition.name}`);\n packageImportPaths?.add(entry.path, resolvedImportPath);\n importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;\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"]}
1
+ {"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAc3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAMC,EACD,OAA+B;IAE/B,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAClG,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,SAAS,GAAc;QAC3B,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,kBAAkB,EAAE,KAAK,EAAE,CAAC;IAE5B,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QACpD,KAAK,CACH,SAAS,CAAC,OAAO,EACjB,MAAM,qBAAqB,CAAC;YAC1B,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE;YAC/F,OAAO;SACR,CAAC,CACH,CAAC;QAEF,IAAI,YAAY,CAAC,cAAc,EAAE;YAC/B,oBAAoB;YACpB,SAAS,CAAC,MAAM,KAAK,EAAE,CAAC;YAExB,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,cA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,IAAI,GAAG,WAAW,GAAG,gBAAgB,EAAE,CAAC;QAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAE3C,qBAAqB;QACrB,IAAI,CAAC,iBAAiB,EAAE;YACtB,uBAAuB;YACvB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACtC,SAAS;aACV;YAED,0EAA0E;YAC1E,IAAI,GAAG,KAAK,KAAK,EAAE;gBACjB,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAC1B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC9B,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAC9E,CAAC;aACH;YAED,kDAAkD;YAClD,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACzD;QAED,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QACzE,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACxD,SAAS,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;KACzE;IAED,uGAAuG;IACvG,mGAAmG;IACnG,2DAA2D;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nimport { merge } from 'merge';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport path from 'path';\nimport { getExportsMap } from './getExportsMap.js';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport type { PackageImportPaths } from './PackageImportPaths.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};\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 hashPackages?: boolean;\n },\n context: CreateImportMapContext,\n): Promise<ImportMap> {\n const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions, hashPackages } = 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, hashPackages },\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, hashPackages },\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 hashPackages?: boolean;\n };\n context: CreateImportMapContext;\n}): Promise<Record<string, string>> {\n const { options, context } = params;\n const { entry, bundleServerUrl, sessionVersion, targetVersions, hashPackages } = options;\n const { packages, packageImportPaths, getPackageHash } = context;\n const importMap: Record<string, string> = {};\n const definition = await packages.get(entry.path);\n const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });\n\n if (\n !definition ||\n !definition.name ||\n !definition.version ||\n !exportsMap ||\n Object.keys(exportsMap).length === 0 ||\n definition.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 = `${entry.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 = hashPackages ? (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 unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`;\n\n resolvedFilePath = `${hash}${cacheBuster}${resolvedFilePath}`;\n const ext = path.extname(resolvedFilePath);\n\n // For bundled files:\n if (!unbundledFilePath) {\n // Ignore .d.ts entries\n if (resolvedFilePath.endsWith('.d.ts')) {\n continue;\n }\n\n // We always expect responses to come back as javascript (.js extensions.)\n if (ext !== '.js') {\n resolvedFilePath = path.join(\n path.dirname(resolvedFilePath),\n path.basename(resolvedFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'),\n );\n }\n\n // Plus signs should be replaced with underscores.\n resolvedFilePath = resolvedFilePath.replace(/\\+/g, '_');\n }\n\n const resolvedImportPath = importPath.replace('.', `${definition.name}`);\n packageImportPaths?.add(entry.path, resolvedImportPath);\n importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAI3E,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AAEH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,uBAAuB,CAAC,CAuFlC"}
1
+ {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAO3E,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,uBAAuB,CAAC,CAoFlC"}
@@ -1,10 +1,12 @@
1
1
  import path from 'path';
2
- import { intermediateToSourcePath, sourceToIntermediatePath, isFile } from '@ms-cloudpack/path-utilities';
3
- import { isExternalPackage } from './isExternalPackage.js';
4
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
+ import { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';
3
+ import { safeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';
5
4
  import { getExportsMap } from './getExportsMap.js';
6
5
  import { flattenExportsMap } from './flattenExportsMap.js';
7
- const typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
6
+ import { getCandidates } from './getCandidates.js';
7
+ import { isExternalPackage } from './isExternalPackage.js';
8
+ const sourceExtensions = ['.ts', '.tsx', '.cts', '.mts', '.jsx'];
9
+ const javascriptExtensions = ['.js', '.mjs', '.cjs'];
8
10
  /**
9
11
  * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special
10
12
  * consideration for internal packages, which may not have intermediate files but only source files. Paths returned
@@ -16,48 +18,17 @@ const typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
16
18
  * exist, then we should not include it in the exports map.
17
19
  */
18
20
  export async function findFileInPackage(options, context) {
19
- const { packagePath } = options;
20
- let filePath = safeRelativePath(options.filePath);
21
+ const originalPath = safeRelativePath(options.filePath);
22
+ const packagePath = slash(options.packagePath);
23
+ let filePath;
21
24
  let sourcePath;
22
25
  let typesPath;
23
26
  const isInternal = !isExternalPackage(packagePath);
24
- const candidates = [
25
- filePath,
26
- filePath + '.js',
27
- filePath + '.mjs',
28
- filePath + '.cjs',
29
- safeRelativePath(path.join(filePath, 'index.js')),
30
- safeRelativePath(path.join(filePath, 'package.json')),
31
- ];
32
- filePath = undefined;
33
- for (const candidate of candidates) {
34
- if (await isFile(path.join(packagePath, candidate))) {
35
- filePath = candidate;
36
- break;
37
- }
38
- }
39
- // For internal packages, try and find source/typings and convert to intermediate (which may be missing.)
40
- if (isInternal) {
41
- for (const candidate of candidates) {
42
- sourcePath = intermediateToSourcePath(candidate, packagePath);
43
- if (sourcePath) {
44
- break;
45
- }
46
- }
47
- // If the discovered source file is the same as the provided file, resolve the intermediate path.
48
- if (sourcePath && (!filePath || sourcePath === filePath)) {
49
- filePath = sourceToIntermediatePath(sourcePath);
50
- }
51
- // If the sourcePath is the same as the filePath, clear it. By this point we should have resolved
52
- // the true intermediate path.
53
- if (sourcePath === filePath) {
54
- sourcePath = undefined;
55
- }
56
- if (sourcePath && typescriptExtensions.includes(path.extname(sourcePath))) {
57
- typesPath = filePath && path.extname(filePath) === '.js' ? filePath.replace(/\.js$/, '.d.ts') : undefined;
58
- }
59
- }
60
- const isNestedPackageDefinition = filePath && path.basename(filePath) === 'package.json' && path.basename(options.filePath) !== 'package.json';
27
+ const candidates = getCandidates({ filePath: originalPath, packagePath });
28
+ // Try and resolve a physical file given the candidates.
29
+ // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem
30
+ filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));
31
+ const isNestedPackageDefinition = filePath && path.basename(filePath) === 'package.json' && path.basename(originalPath) !== 'package.json';
61
32
  const result = {};
62
33
  if (isNestedPackageDefinition) {
63
34
  const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath));
@@ -74,6 +45,32 @@ export async function findFileInPackage(options, context) {
74
45
  };
75
46
  }
76
47
  }
48
+ // If the resolved file is a typescript file in an internal package, try to resolve the intermediate.
49
+ if (filePath && sourceExtensions.includes(path.extname(filePath))) {
50
+ sourcePath = filePath;
51
+ filePath = isInternal ? sourceToIntermediatePath(filePath) : undefined;
52
+ }
53
+ // If we haven't resolved a sourcePath, try to resolve it from the intermediate.
54
+ if (isInternal && filePath && !sourcePath) {
55
+ const ext = path.extname(filePath);
56
+ const isJavaScriptExt = javascriptExtensions.includes(ext);
57
+ if (isJavaScriptExt) {
58
+ // Not a TS file, but a JS file. Try to find the source.
59
+ sourcePath = intermediateToSourcePath(filePath, packagePath);
60
+ // If we couldn't find a TS file, clear sourcePath.
61
+ if (sourcePath === filePath) {
62
+ sourcePath = undefined;
63
+ }
64
+ }
65
+ }
66
+ // Try to resolve the typesPath
67
+ if (sourcePath && filePath) {
68
+ typesPath = filePath.replace(/\.js$/, '.d.ts');
69
+ // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem
70
+ if (!isInternal && !isFileSync(path.join(packagePath, typesPath))) {
71
+ typesPath = undefined;
72
+ }
73
+ }
77
74
  if (typesPath) {
78
75
  result.typesPath = safeRelativePath(typesPath);
79
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAa7D;;;;;;;;;GASG;AAEH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAiC,EACjC,OAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,IAAI,QAAQ,GAAuB,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtE,IAAI,UAA8B,CAAC;IACnC,IAAI,SAA6B,CAAC;IAClC,MAAM,UAAU,GAAG,C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AAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;KAClD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\nimport { intermediateToSourcePath, sourceToIntermediatePath, isFile } from '@ms-cloudpack/path-utilities';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { getExportsMap } from './getExportsMap.js';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\n\nconst typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];\n\nexport type FindFileInPackageOptions = {\n packagePath: string;\n filePath: string;\n};\n\nexport type FindFileInPackageResult = {\n filePath?: string;\n typesPath?: string;\n sourcePath?: string;\n};\n\n/**\n * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special\n * consideration for internal packages, which may not have intermediate files but only source files. Paths returned\n * are always relative and start with `./`.\n *\n * This helper is used in deriving if the given package.json entries are actual validate candidates when constructing an\n * exports map from existing metadata. For example, a package.json may list `main` as `lib/index.js`. If this file\n * exists, or in internal packages, if `src/index.tsx` exists, then this is a valid candidate. If the file does not\n * exist, then we should not include it in the exports map.\n */\n\nexport async function findFileInPackage(\n options: FindFileInPackageOptions,\n context: { packages: PackageDefinitionsCache },\n): Promise<FindFileInPackageResult> {\n const { packagePath } = options;\n let filePath: string | undefined = safeRelativePath(options.filePath);\n let sourcePath: string | undefined;\n let typesPath: string | undefined;\n const isInternal = !isExternalPackage(packagePath);\n const candidates = [\n filePath,\n filePath + '.js',\n filePath + '.mjs',\n filePath + '.cjs',\n safeRelativePath(path.join(filePath, 'index.js')),\n safeRelativePath(path.join(filePath, 'package.json')),\n ];\n\n filePath = undefined;\n for (const candidate of candidates) {\n if (await isFile(path.join(packagePath, candidate))) {\n filePath = candidate;\n break;\n }\n }\n\n // For internal packages, try and find source/typings and convert to intermediate (which may be missing.)\n if (isInternal) {\n for (const candidate of candidates) {\n sourcePath = intermediateToSourcePath(candidate, packagePath);\n if (sourcePath) {\n break;\n }\n }\n\n // If the discovered source file is the same as the provided file, resolve the intermediate path.\n if (sourcePath && (!filePath || sourcePath === filePath)) {\n filePath = sourceToIntermediatePath(sourcePath);\n }\n\n // If the sourcePath is the same as the filePath, clear it. By this point we should have resolved\n // the true intermediate path.\n if (sourcePath === filePath) {\n sourcePath = undefined;\n }\n\n if (sourcePath && typescriptExtensions.includes(path.extname(sourcePath))) {\n typesPath = filePath && path.extname(filePath) === '.js' ? filePath.replace(/\\.js$/, '.d.ts') : undefined;\n }\n }\n\n const isNestedPackageDefinition =\n filePath && path.basename(filePath) === 'package.json' && path.basename(options.filePath) !== 'package.json';\n const result: FindFileInPackageResult = {};\n\n if (isNestedPackageDefinition) {\n const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath as string));\n const exportsMap = await getExportsMap({ packagePath: nestedDefinitionPath }, context);\n const entryPath = flattenExportsMap(exportsMap)['.'];\n\n if (entryPath) {\n typesPath = flattenExportsMap(exportsMap, { conditions: ['types'] })['.'];\n\n return {\n ...(await findFileInPackage(\n {\n packagePath,\n filePath: safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n )),\n typesPath:\n typesPath && safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),\n };\n }\n }\n\n if (typesPath) {\n result.typesPath = safeRelativePath(typesPath);\n }\n\n if (filePath) {\n result.filePath = safeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = safeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,UAAU,EAAE,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QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,eAAe,GAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE3D,IAAI,eAAe,EAAE;YACnB,wDAAwD;YACxD,UAAU,GAAG,wBAAwB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAE7D,mDAAmD;YACnD,IAAI,UAAU,KAAK,QAAQ,EAAE;gBAC3B,UAAU,GAAG,SAAS,CAAC;aACxB;SACF;KACF;IAED,+BAA+B;IAC/B,IAAI,UAAU,IAAI,QAAQ,EAAE;QAC1B,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE/C,qEAAqE;QACrE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE;YACjE,SAAS,GAAG,SAAS,CAAC;SACvB;KACF;IAED,IAAI,SAAS,EAAE;QACb,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;KAChD;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;KAClD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\nimport { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';\nimport { safeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport { getExportsMap } from './getExportsMap.js';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { getCandidates } from './getCandidates.js';\nimport { isExternalPackage } from './isExternalPackage.js';\n\nconst sourceExtensions = ['.ts', '.tsx', '.cts', '.mts', '.jsx'];\nconst javascriptExtensions = ['.js', '.mjs', '.cjs'];\n\nexport type FindFileInPackageOptions = {\n packagePath: string;\n filePath: string;\n};\n\nexport type FindFileInPackageResult = {\n filePath?: string;\n typesPath?: string;\n sourcePath?: string;\n};\n\n/**\n * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special\n * consideration for internal packages, which may not have intermediate files but only source files. Paths returned\n * are always relative and start with `./`.\n *\n * This helper is used in deriving if the given package.json entries are actual validate candidates when constructing an\n * exports map from existing metadata. For example, a package.json may list `main` as `lib/index.js`. If this file\n * exists, or in internal packages, if `src/index.tsx` exists, then this is a valid candidate. If the file does not\n * exist, then we should not include it in the exports map.\n */\nexport async function findFileInPackage(\n options: FindFileInPackageOptions,\n context: { packages: PackageDefinitionsCache },\n): Promise<FindFileInPackageResult> {\n const originalPath = safeRelativePath(options.filePath);\n const packagePath = slash(options.packagePath);\n let filePath: string | undefined;\n let sourcePath: string | undefined;\n let typesPath: string | undefined;\n const isInternal = !isExternalPackage(packagePath);\n const candidates = getCandidates({ filePath: originalPath, packagePath });\n\n // Try and resolve a physical file given the candidates.\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));\n\n const isNestedPackageDefinition =\n filePath && path.basename(filePath) === 'package.json' && path.basename(originalPath) !== 'package.json';\n const result: FindFileInPackageResult = {};\n\n if (isNestedPackageDefinition) {\n const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath as string));\n const exportsMap = await getExportsMap({ packagePath: nestedDefinitionPath }, context);\n const entryPath = flattenExportsMap(exportsMap)['.'];\n\n if (entryPath) {\n typesPath = flattenExportsMap(exportsMap, { conditions: ['types'] })['.'];\n\n return {\n ...(await findFileInPackage(\n {\n packagePath,\n filePath: safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n )),\n typesPath:\n typesPath && safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),\n };\n }\n }\n\n // If the resolved file is a typescript file in an internal package, try to resolve the intermediate.\n if (filePath && sourceExtensions.includes(path.extname(filePath))) {\n sourcePath = filePath;\n filePath = isInternal ? sourceToIntermediatePath(filePath) : undefined;\n }\n\n // If we haven't resolved a sourcePath, try to resolve it from the intermediate.\n if (isInternal && filePath && !sourcePath) {\n const ext = path.extname(filePath);\n const isJavaScriptExt = javascriptExtensions.includes(ext);\n\n if (isJavaScriptExt) {\n // Not a TS file, but a JS file. Try to find the source.\n sourcePath = intermediateToSourcePath(filePath, packagePath);\n\n // If we couldn't find a TS file, clear sourcePath.\n if (sourcePath === filePath) {\n sourcePath = undefined;\n }\n }\n }\n\n // Try to resolve the typesPath\n if (sourcePath && filePath) {\n typesPath = filePath.replace(/\\.js$/, '.d.ts');\n\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n if (!isInternal && !isFileSync(path.join(packagePath, typesPath))) {\n typesPath = undefined;\n }\n }\n\n if (typesPath) {\n result.typesPath = safeRelativePath(typesPath);\n }\n\n if (filePath) {\n result.filePath = safeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = safeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths
3
+ * to look for the physical file in order of priority. For internal packages, we try to discover
4
+ * source files first, and then fallback to the original file name. We also search for index files
5
+ * and expand folder paths as well for ambiguous references. For external packages, we prioritize
6
+ * intermediate paths.
7
+ */
8
+ export declare function getCandidates(options: {
9
+ filePath: string;
10
+ packagePath: string;
11
+ }): string[];
12
+ //# sourceMappingURL=getCandidates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCandidates.d.ts","sourceRoot":"","sources":["../src/getCandidates.ts"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,YAoD/E"}
@@ -0,0 +1,98 @@
1
+ import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
+ import path from 'path';
3
+ import { isExternalPackage } from './isExternalPackage.js';
4
+ // Mappings to possible candidate extensions for a given input extension.
5
+ const externalExtensions = ['.js', '.mjs', '.cjs'];
6
+ const internalExtensions = ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js', '.mjs', '.cjs'];
7
+ const internalExtensionMap = {
8
+ '.ts': ['.ts', '.js'],
9
+ '.tsx': ['.tsx', '.js'],
10
+ '.mts': ['.mts', '.mjs', '.js'],
11
+ '.cts': ['.cts', '.cjs', '.js'],
12
+ '.jsx': ['.jsx', '.js'],
13
+ '.js': ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js'],
14
+ '.mjs': ['.mjs', '.js'],
15
+ '.cjs': ['.cjs', '.js'],
16
+ };
17
+ const externalExtensionMap = {
18
+ '.ts': ['.ts', '.js'],
19
+ '.tsx': ['.js'],
20
+ '.mts': ['.mjs', '.js'],
21
+ '.cts': ['.mts', '.cts'],
22
+ '.jsx': ['.js'],
23
+ '.js': ['.js'],
24
+ };
25
+ /**
26
+ * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths
27
+ * to look for the physical file in order of priority. For internal packages, we try to discover
28
+ * source files first, and then fallback to the original file name. We also search for index files
29
+ * and expand folder paths as well for ambiguous references. For external packages, we prioritize
30
+ * intermediate paths.
31
+ */
32
+ export function getCandidates(options) {
33
+ const { filePath, packagePath } = options;
34
+ const isBlankPath = !filePath || filePath === '.';
35
+ const originalPath = isBlankPath ? './index' : safeRelativePath(filePath);
36
+ const originalExt = path.extname(originalPath);
37
+ const isInternal = !isExternalPackage(packagePath);
38
+ const endsWithSlash = originalPath.endsWith('/');
39
+ const candidates = [];
40
+ const defaultExtensions = isInternal ? internalExtensions : externalExtensions;
41
+ const extensions = (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensions;
42
+ const pathsToAdd = [originalPath];
43
+ if (isInternal && originalPath.startsWith('./lib')) {
44
+ pathsToAdd.unshift(originalPath.replace(/^\.\/lib/, './src'));
45
+ }
46
+ for (let currentPath of pathsToAdd) {
47
+ const unrecognizedExt = originalExt && !extensions.includes(path.extname(currentPath));
48
+ // For internal packages, we try and resolve the original file name first.
49
+ if (isInternal && unrecognizedExt) {
50
+ candidates.push(currentPath);
51
+ }
52
+ // If the path doesn't end with a slash, it could be a file. Add extensions.
53
+ if (!endsWithSlash) {
54
+ candidates.push(...expandExtensions(currentPath, extensions));
55
+ }
56
+ // For non-extension references, we might be referring to a folder, or a barrel file within a folder. Add the
57
+ // appropriate extensions for the barrel file, and fall back to a package.json in the case of nested definitions.
58
+ if (!originalExt) {
59
+ if (isBlankPath) {
60
+ candidates.push('./package.json');
61
+ }
62
+ else {
63
+ // Trim trailing slash
64
+ if (endsWithSlash) {
65
+ currentPath = currentPath.slice(0, -1);
66
+ }
67
+ candidates.push(...expandExtensions(currentPath + '/index', extensions));
68
+ candidates.push(currentPath + '/package.json');
69
+ }
70
+ }
71
+ // For external packages, we try and resolve the original file name last.
72
+ if (!isInternal && unrecognizedExt) {
73
+ candidates.push(currentPath);
74
+ }
75
+ }
76
+ return candidates;
77
+ }
78
+ /**
79
+ * Given a filepath and list of extensions, maps extensions to prepend the filepath. In the case that
80
+ * the filepath has an extension already in the list, avoids appending the extension twice.
81
+ *
82
+ * For example, filePath = './foo/bar.js' with extensions ['.ts', '.js'] would result in:
83
+ *
84
+ * ['./foo/bar.ts.js', './foo/bar.js'].
85
+ *
86
+ */
87
+ function expandExtensions(filePath, extensions) {
88
+ const result = [];
89
+ const ext = path.extname(filePath);
90
+ if (extensions.includes(ext)) {
91
+ filePath = `${filePath.slice(0, -ext.length)}`;
92
+ }
93
+ for (const currentExt of extensions) {
94
+ result.push(filePath + currentExt);
95
+ }
96
+ return result;
97
+ }
98
+ //# sourceMappingURL=get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AC","sourcesContent":["import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport { isExternalPackage } from './isExternalPackage.js';\n\n// Mappings to possible candidate extensions for a given input extension.\nconst externalExtensions = ['.js', '.mjs', '.cjs'];\nconst internalExtensions = ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js', '.mjs', '.cjs'];\nconst internalExtensionMap: Record<string, string[]> = {\n '.ts': ['.ts', '.js'],\n '.tsx': ['.tsx', '.js'],\n '.mts': ['.mts', '.mjs', '.js'],\n '.cts': ['.cts', '.cjs', '.js'],\n '.jsx': ['.jsx', '.js'],\n '.js': ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js'],\n '.mjs': ['.mjs', '.js'],\n '.cjs': ['.cjs', '.js'],\n};\nconst externalExtensionMap: Record<string, string[]> = {\n '.ts': ['.ts', '.js'],\n '.tsx': ['.js'],\n '.mts': ['.mjs', '.js'],\n '.cts': ['.mts', '.cts'],\n '.jsx': ['.js'],\n '.js': ['.js'],\n};\n\n/**\n * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths\n * to look for the physical file in order of priority. For internal packages, we try to discover\n * source files first, and then fallback to the original file name. We also search for index files\n * and expand folder paths as well for ambiguous references. For external packages, we prioritize\n * intermediate paths.\n */\nexport function getCandidates(options: { filePath: string; packagePath: string }) {\n const { filePath, packagePath } = options;\n const isBlankPath = !filePath || filePath === '.';\n const originalPath = isBlankPath ? './index' : safeRelativePath(filePath);\n const originalExt = path.extname(originalPath);\n const isInternal = !isExternalPackage(packagePath);\n const endsWithSlash = originalPath.endsWith('/');\n const candidates = [];\n const defaultExtensions = isInternal ? internalExtensions : externalExtensions;\n const extensions = (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensions;\n const pathsToAdd = [originalPath];\n\n if (isInternal && originalPath.startsWith('./lib')) {\n pathsToAdd.unshift(originalPath.replace(/^\\.\\/lib/, './src'));\n }\n\n for (let currentPath of pathsToAdd) {\n const unrecognizedExt = originalExt && !extensions.includes(path.extname(currentPath));\n\n // For internal packages, we try and resolve the original file name first.\n if (isInternal && unrecognizedExt) {\n candidates.push(currentPath);\n }\n\n // If the path doesn't end with a slash, it could be a file. Add extensions.\n if (!endsWithSlash) {\n candidates.push(...expandExtensions(currentPath, extensions));\n }\n\n // For non-extension references, we might be referring to a folder, or a barrel file within a folder. Add the\n // appropriate extensions for the barrel file, and fall back to a package.json in the case of nested definitions.\n if (!originalExt) {\n if (isBlankPath) {\n candidates.push('./package.json');\n } else {\n // Trim trailing slash\n if (endsWithSlash) {\n currentPath = currentPath.slice(0, -1);\n }\n\n candidates.push(...expandExtensions(currentPath + '/index', extensions));\n candidates.push(currentPath + '/package.json');\n }\n }\n\n // For external packages, we try and resolve the original file name last.\n if (!isInternal && unrecognizedExt) {\n candidates.push(currentPath);\n }\n }\n\n return candidates;\n}\n\n/**\n * Given a filepath and list of extensions, maps extensions to prepend the filepath. In the case that\n * the filepath has an extension already in the list, avoids appending the extension twice.\n *\n * For example, filePath = './foo/bar.js' with extensions ['.ts', '.js'] would result in:\n *\n * ['./foo/bar.ts.js', './foo/bar.js'].\n *\n */\nfunction expandExtensions(filePath: string, extensions: string[]) {\n const result: string[] = [];\n const ext = path.extname(filePath);\n\n if (extensions.includes(ext)) {\n filePath = `${filePath.slice(0, -ext.length)}`;\n }\n\n for (const currentExt of extensions) {\n result.push(filePath + currentExt);\n }\n\n return result;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { flattenExportsMap } from './flattenExportsMap.js';
10
10
  export { createExportsMap } from './createExportsMap.js';
11
11
  export { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExportsMapEntry.js';
12
12
  export { getExportsMap } from './getExportsMap.js';
13
- export { createImportMap, type ImportMap } from './createImportMap.js';
13
+ export { createImportMap, type ImportMap, type CreateImportMapContext } from './createImportMap.js';
14
14
  export { addImportMapHash } from './addImportMapHash.js';
15
15
  export { PackageImportPaths } from './PackageImportPaths.js';
16
16
  export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,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// 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';\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","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';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "5.1.13",
3
+ "version": "5.2.0",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",