@ms-cloudpack/package-utilities 5.10.5 → 5.11.1

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,5 +1,5 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
- import type { PackageJsonExports, CloudpackConfig } from '@ms-cloudpack/config-types';
2
+ import type { CloudpackConfig, PackageJsonExports } from '@ms-cloudpack/config-types';
3
3
  /**
4
4
  * Options fo addExportsMapEntry.
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"addExportsMapEntry.d.ts","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGtF;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,OAAO,CAAC,CAoDlB"}
1
+ {"version":3,"file":"addExportsMapEntry.d.ts","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAItF;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,OAAO,CAAC,CAoDlB"}
@@ -1,12 +1,12 @@
1
+ import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
1
2
  import { findFileInPackage } from './findFileInPackage.js';
2
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
3
3
  /**
4
4
  * Given an exports map and details about an import path, adds the entry.
5
5
  */
6
6
  export async function addExportsMapEntry(options, context) {
7
7
  const { exports, packagePath, condition = 'default' } = options;
8
8
  const importPath = makeSafeImportKey(options.importPath || '.');
9
- const { filePath, sourcePath, typesPath = options.typesPath ? safeRelativePath(options.typesPath) : undefined, } = await findFileInPackage({
9
+ const { filePath, sourcePath, typesPath = options.typesPath ? normalizeRelativePath(options.typesPath) : undefined, } = await findFileInPackage({
10
10
  packagePath,
11
11
  filePath: options.filePath || options.importPath || '',
12
12
  }, context);
@@ -1 +1 @@
1
- {"version":3,"file":"addExportsMapEntry.js","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAA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I,SAAS,EAAE,CAAC;YACd,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;QACpC,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,YAAY,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QACtC,CAAC;QAED,mCAAmC;QACnC,YAAY,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACtC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,4CAA4C;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { findFileInPackage } from './findFileInPackage.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { PackageJsonExports, CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Options fo addExportsMapEntry.\n */\nexport interface AddExportsMapEntryOptions {\n /**\n * The exports map to add the entry to.\n */\n exports: PackageJsonExports;\n\n /**\n * The package path to add the entry for. This is used to resolve relative paths.\n */\n packagePath: string;\n\n /**\n * The import path to add the entry for. This is used as the key in the exports map. Defaults\n * to \".\" being the package import.\n */\n importPath?: string;\n\n /**\n * The relative path to the physical file location, representing the \"key\" in the exports map. Can be a partial\n * location, in which case we will attempt to search for the file and associated source/d.ts files. Defaults to\n * assuming `index.js`.\n */\n filePath?: string;\n\n /**\n * Optional types path. If not provided, types will be discovered for internal packages that have source files.\n * This is useful mainly when converting the default import from a package.json that has explicit typings listed.\n */\n typesPath?: string;\n\n /**\n * The condition to add the entry for. (Example: \"import\", \"require\", \"browser\", \"types\") Defaults to \"default\"\n */\n condition?: string;\n}\n\n/**\n * Given an exports map and details about an import path, adds the entry.\n */\nexport async function addExportsMapEntry(\n options: AddExportsMapEntryOptions,\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<boolean> {\n const { exports, packagePath, condition = 'default' } = options;\n const importPath = makeSafeImportKey(options.importPath || '.');\n const {\n filePath,\n sourcePath,\n typesPath = options.typesPath ? safeRelativePath(options.typesPath) : undefined,\n } = await findFileInPackage(\n {\n packagePath,\n filePath: options.filePath || options.importPath || '',\n },\n context,\n );\n\n // Only do work if a file path was found.\n if (!filePath) {\n return false;\n }\n\n // Create a local for casting.\n const localExports = exports as Record<string, string | Record<string, string>>;\n\n // If this is the only entry we're adding, set it to a string to minimize the exports map.\n if (\n !typesPath &&\n !sourcePath &&\n condition === 'default' &&\n (!localExports[importPath] || typeof localExports[importPath] === 'string')\n ) {\n localExports[importPath] = filePath;\n } else {\n let exportsEntry = (localExports[importPath] ??= {});\n\n // Promote string-based exports into objects with default conditions.\n if (typeof exportsEntry === 'string') {\n exportsEntry = (exports as Record<string, Record<string, string>>)[importPath] = { default: exportsEntry };\n }\n\n if (typesPath) {\n exportsEntry['types'] = typesPath;\n }\n\n if (sourcePath) {\n exportsEntry['source'] = sourcePath;\n }\n\n // Add the entry for the condition.\n exportsEntry[condition] = filePath;\n }\n\n return true;\n}\n\nfunction makeSafeImportKey(key: string) {\n if (!key || key === '' || key === '.') {\n return '.';\n }\n\n // if the key starts with a slash, add a dot\n if (key.startsWith('/')) {\n key = '.' + key;\n }\n\n // if the key doesn't start with \"./\", add it\n if (!key.startsWith('./')) {\n key = './' + key;\n }\n\n return key;\n}\n"]}
1
+ {"version":3,"file":"addExportsMapEntry.js","sourceRoot":"","s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YAAY,GAAI,OAAkD,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAC7G,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;QACpC,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,YAAY,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QACtC,CAAC;QAED,mCAAmC;QACnC,YAAY,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACtC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,4CAA4C;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig, PackageJsonExports } from '@ms-cloudpack/config-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { findFileInPackage } from './findFileInPackage.js';\n\n/**\n * Options fo addExportsMapEntry.\n */\nexport interface AddExportsMapEntryOptions {\n /**\n * The exports map to add the entry to.\n */\n exports: PackageJsonExports;\n\n /**\n * The package path to add the entry for. This is used to resolve relative paths.\n */\n packagePath: string;\n\n /**\n * The import path to add the entry for. This is used as the key in the exports map. Defaults\n * to \".\" being the package import.\n */\n importPath?: string;\n\n /**\n * The relative path to the physical file location, representing the \"key\" in the exports map. Can be a partial\n * location, in which case we will attempt to search for the file and associated source/d.ts files. Defaults to\n * assuming `index.js`.\n */\n filePath?: string;\n\n /**\n * Optional types path. If not provided, types will be discovered for internal packages that have source files.\n * This is useful mainly when converting the default import from a package.json that has explicit typings listed.\n */\n typesPath?: string;\n\n /**\n * The condition to add the entry for. (Example: \"import\", \"require\", \"browser\", \"types\") Defaults to \"default\"\n */\n condition?: string;\n}\n\n/**\n * Given an exports map and details about an import path, adds the entry.\n */\nexport async function addExportsMapEntry(\n options: AddExportsMapEntryOptions,\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<boolean> {\n const { exports, packagePath, condition = 'default' } = options;\n const importPath = makeSafeImportKey(options.importPath || '.');\n const {\n filePath,\n sourcePath,\n typesPath = options.typesPath ? normalizeRelativePath(options.typesPath) : undefined,\n } = await findFileInPackage(\n {\n packagePath,\n filePath: options.filePath || options.importPath || '',\n },\n context,\n );\n\n // Only do work if a file path was found.\n if (!filePath) {\n return false;\n }\n\n // Create a local for casting.\n const localExports = exports as Record<string, string | Record<string, string>>;\n\n // If this is the only entry we're adding, set it to a string to minimize the exports map.\n if (\n !typesPath &&\n !sourcePath &&\n condition === 'default' &&\n (!localExports[importPath] || typeof localExports[importPath] === 'string')\n ) {\n localExports[importPath] = filePath;\n } else {\n let exportsEntry = (localExports[importPath] ??= {});\n\n // Promote string-based exports into objects with default conditions.\n if (typeof exportsEntry === 'string') {\n exportsEntry = (exports as Record<string, Record<string, string>>)[importPath] = { default: exportsEntry };\n }\n\n if (typesPath) {\n exportsEntry['types'] = typesPath;\n }\n\n if (sourcePath) {\n exportsEntry['source'] = sourcePath;\n }\n\n // Add the entry for the condition.\n exportsEntry[condition] = filePath;\n }\n\n return true;\n}\n\nfunction makeSafeImportKey(key: string) {\n if (!key || key === '' || key === '.') {\n return '.';\n }\n\n // if the key starts with a slash, add a dot\n if (key.startsWith('/')) {\n key = '.' + key;\n }\n\n // if the key doesn't start with \"./\", add it\n if (!key.startsWith('./')) {\n key = './' + key;\n }\n\n return key;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
- import type { PackageJsonExports, CloudpackConfig } from '@ms-cloudpack/config-types';
2
+ import type { CloudpackConfig, PackageJsonExports } from '@ms-cloudpack/config-types';
3
3
  /**
4
4
  * Given a package path, generates an export map for the package.
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAItF;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,kBAAkB,CAAC,CAsF7B"}
1
+ {"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAItF;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,kBAAkB,CAAC,CAsF7B"}
@@ -1,5 +1,5 @@
1
+ import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
1
2
  import { addExportsMapEntry } from './addExportsMapEntry.js';
2
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
3
3
  /**
4
4
  * Given a package path, generates an export map for the package.
5
5
  */
@@ -44,7 +44,7 @@ export async function createExportsMap(options, context) {
44
44
  if (!value || typeof value !== 'string') {
45
45
  continue;
46
46
  }
47
- const isDefaultImport = safeRelativePath(module || main) === safeRelativePath(key);
47
+ const isDefaultImport = normalizeRelativePath(module || main) === normalizeRelativePath(key);
48
48
  const importPaths = isDefaultImport ? ['.'] : [key];
49
49
  if (!isDefaultImport && key.endsWith('.js')) {
50
50
  importPaths.push(key.replace(/\.js$/, ''));
@@ -1 +1 @@
1
- {"version":3,"file":"createExportsMap.js","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAGC,EACD,OAAuE;IAEvE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAErG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,qEAAqE;IACrE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OA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Config } from '@ms-cloudpack/config-types';\nimport { addExportsMapEntry } from './addExportsMapEntry.js';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Given a package path, generates an export map for the package.\n */\nexport async function createExportsMap(\n options: {\n packagePath: string;\n disableTransforms?: boolean;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports> {\n const { packagePath } = options;\n const { packages } = context;\n const definition = await packages.get(packagePath, { disableTransforms: options.disableTransforms });\n\n if (!definition) {\n throw new Error(`Package definition not found for ${packagePath}`);\n }\n\n // Don't create an exports map for a definition that already has one.\n if (definition.exports) {\n return definition.exports;\n }\n\n const { browser, main, module, types, typings, type } = definition;\n const exports = {};\n const typesPath = types || typings;\n\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: 'index.js',\n typesPath,\n condition: type === 'module' ? 'import' : 'default',\n },\n context,\n );\n main &&\n (await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: main,\n typesPath,\n condition: type === 'module' ? 'import' : 'default',\n },\n context,\n ),\n context);\n module &&\n (await addExportsMapEntry({ exports, packagePath, filePath: module, typesPath, condition: 'import' }, context));\n\n if (browser) {\n if (typeof definition.browser === 'string') {\n await addExportsMapEntry({ exports, packagePath, filePath: definition.browser, condition: 'browser' }, context);\n } else if (typeof definition.browser === 'object') {\n for (const [key, value] of Object.entries(definition.browser)) {\n if (!value || typeof value !== 'string') {\n continue;\n }\n\n const isDefaultImport = safeRelativePath(module || main) === safeRelativePath(key);\n\n const importPaths = isDefaultImport ? ['.'] : [key];\n\n if (!isDefaultImport && key.endsWith('.js')) {\n importPaths.push(key.replace(/\\.js$/, ''));\n }\n\n for (const importPath of importPaths) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n importPath,\n filePath: value,\n condition: 'browser',\n },\n context,\n );\n }\n }\n }\n }\n\n // If we couldn't infer the exports map shape from existing metadata,\n // formulate based off inferred file structure.\n // Note: CRA defaults to src/index.js, Vite defaults to src/main.js\n if (Object.keys(exports).length === 0) {\n (await addExportsMapEntry({ exports, packagePath, filePath: './lib/index.js' }, context)) ||\n (await addExportsMapEntry({ exports, packagePath, filePath: './lib/main.js' }, context)) ||\n (await addExportsMapEntry({ exports, packagePath, filePath: './index.js' }, context));\n }\n\n return exports;\n}\n"]}
1
+ {"version":3,"file":"createExportsMap.js","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAGC,EACD,OAAuE;IAEvE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAErG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,qEAAqE;IACrE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;IACnE,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,SAAS,GAAG,KAAK,IAAI,OAAO,CAAC;IAEnC,MAAM,kBAAkB,CACtB;QACE,OAAO;QACP,WAAW;QACX,QAAQ,EAAE,UAAU;QACpB,SAAS;QACT,SAAS,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,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,KAAK,CAAC,EAAE,CAAC;oBAC5C,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;gBAC7C,CAAC;gBAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;oBACrC,MAAM,kBAAkB,CACtB;wBACE,OAAO;wBACP,WAAW;wBACX,UAAU;wBACV,QAAQ,EAAE,KAAK;wBACf,SAAS,EAAE,SAAS;qBACrB,EACD,OAAO,CACR,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,+CAA+C;IAC/C,mEAAmE;IACnE,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,CAAC,MAAM,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;YACvF,CAAC,MAAM,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;YACxF,CAAC,MAAM,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig, PackageJsonExports } from '@ms-cloudpack/config-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { addExportsMapEntry } from './addExportsMapEntry.js';\n\n/**\n * Given a package path, generates an export map for the package.\n */\nexport async function createExportsMap(\n options: {\n packagePath: string;\n disableTransforms?: boolean;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports> {\n const { packagePath } = options;\n const { packages } = context;\n const definition = await packages.get(packagePath, { disableTransforms: options.disableTransforms });\n\n if (!definition) {\n throw new Error(`Package definition not found for ${packagePath}`);\n }\n\n // Don't create an exports map for a definition that already has one.\n if (definition.exports) {\n return definition.exports;\n }\n\n const { browser, main, module, types, typings, type } = definition;\n const exports = {};\n const typesPath = types || typings;\n\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: 'index.js',\n typesPath,\n condition: type === 'module' ? 'import' : 'default',\n },\n context,\n );\n main &&\n (await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: main,\n typesPath,\n condition: type === 'module' ? 'import' : 'default',\n },\n context,\n ),\n context);\n module &&\n (await addExportsMapEntry({ exports, packagePath, filePath: module, typesPath, condition: 'import' }, context));\n\n if (browser) {\n if (typeof definition.browser === 'string') {\n await addExportsMapEntry({ exports, packagePath, filePath: definition.browser, condition: 'browser' }, context);\n } else if (typeof definition.browser === 'object') {\n for (const [key, value] of Object.entries(definition.browser)) {\n if (!value || typeof value !== 'string') {\n continue;\n }\n\n const isDefaultImport = normalizeRelativePath(module || main) === normalizeRelativePath(key);\n\n const importPaths = isDefaultImport ? ['.'] : [key];\n\n if (!isDefaultImport && key.endsWith('.js')) {\n importPaths.push(key.replace(/\\.js$/, ''));\n }\n\n for (const importPath of importPaths) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n importPath,\n filePath: value,\n condition: 'browser',\n },\n context,\n );\n }\n }\n }\n }\n\n // If we couldn't infer the exports map shape from existing metadata,\n // formulate based off inferred file structure.\n // Note: CRA defaults to src/index.js, Vite defaults to src/main.js\n if (Object.keys(exports).length === 0) {\n (await addExportsMapEntry({ exports, packagePath, filePath: './lib/index.js' }, context)) ||\n (await addExportsMapEntry({ exports, packagePath, filePath: './lib/main.js' }, context)) ||\n (await addExportsMapEntry({ exports, packagePath, filePath: './index.js' }, context));\n }\n\n return exports;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createImportMap.d.ts","sourceRoot":"","sources":["../src/createImportM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U,EAAE,MAAM,uBAAuB,CAAC;AAIxD,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,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,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"}
@@ -1,9 +1,8 @@
1
1
  import {} from '@ms-cloudpack/config-types';
2
2
  import { merge } from 'merge';
3
- import { flattenExportsMap } from './flattenExportsMap.js';
4
3
  import { getExportsMap } from './getExportsMap.js';
5
- import { getResolvedFilePath } from './getResolvedFilePath.js';
6
4
  import { isExternalPackage } from './isExternalPackage.js';
5
+ import { getRuntimeEntryPaths } from './getRuntimeEntryPaths.js';
7
6
  /**
8
7
  * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.
9
8
  */
@@ -51,12 +50,6 @@ async function getImportMapFromEntry(params) {
51
50
  name.startsWith('@types/')) {
52
51
  return importMap;
53
52
  }
54
- // Get both the unbundled entries from the exports map
55
- const unbundledExportsMap = flattenExportsMap(exportsMap, {
56
- conditions: ['browser-esm'],
57
- requiredConditions: ['browser-esm'],
58
- });
59
- const bundledExportsMap = flattenExportsMap(exportsMap);
60
53
  const packagePrefix = `${name}@${entry.version}/`;
61
54
  const baseUrl = `${bundleServerUrl}/${packagePrefix}`;
62
55
  const isExternal = isExternalPackage(entry.path);
@@ -64,20 +57,16 @@ async function getImportMapFromEntry(params) {
64
57
  const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;
65
58
  const hash = isExternal ? `h-${await getPackageHash(entry.path)}/` : 'h-pending/';
66
59
  // Add the bundled entries to the import map, but prefer unbundled if the entry exists.
67
- for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {
68
- const resolvedFilePath = getResolvedFilePath({
69
- entryPath: importPath,
70
- isExternal,
71
- unbundledExportsMap,
72
- bundledFilePath,
73
- bundledPrefix: `${hash}${cacheBuster}bundled/`,
74
- unbundledPrefix: `${hash}${cacheBuster}unbundled/`,
75
- });
76
- if (resolvedFilePath !== undefined) {
77
- const resolvedImportPath = importPath.replace('.', `${name}`);
78
- packageImportPaths?.add(entry.path, resolvedImportPath);
79
- importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;
80
- }
60
+ const entryPaths = getRuntimeEntryPaths({
61
+ isExternal,
62
+ exportsMap,
63
+ bundledPrefix: `${hash}${cacheBuster}bundled/`,
64
+ unbundledPrefix: `${hash}${cacheBuster}unbundled/`,
65
+ });
66
+ for (const [importPath, actualEntryPath] of Object.entries(entryPaths)) {
67
+ const resolvedImportPath = importPath.replace('.', `${name}`);
68
+ packageImportPaths?.add(entry.path, resolvedImportPath);
69
+ importMap[resolvedImportPath] = new URL(actualEntryPath, baseUrl).href;
81
70
  }
82
71
  // Finally add a fallback for all other unexpected bundle entries. (Note, this should point to a script
83
72
  // which logs this as an error to the user and offers a way to add the entry to exports overrides.)
@@ -1 +1 @@
1
- {"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,4BAA4B,CAAC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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"]}
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,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAcjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAKC,EACD,OAA+B;IAE/B,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACpF,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,CAAC;QACrD,KAAK,CACH,SAAS,CAAC,OAAO,EACjB,MAAM,qBAAqB,CAAC;YAC1B,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE;YACjF,OAAO;SACR,CAAC,CACH,CAAC;QAEF,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;YAChC,oBAAoB;YACpB,SAAS,CAAC,MAAM,KAAK,EAAE,CAAC;YAExB,KAA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CAAC,CAAC,IAAI,CAAC;IACzE,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 { getExportsMap } from './getExportsMap.js';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nimport { getRuntimeEntryPaths } from './getRuntimeEntryPaths.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 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 const entryPaths = getRuntimeEntryPaths({\n isExternal,\n exportsMap,\n bundledPrefix: `${hash}${cacheBuster}bundled/`,\n unbundledPrefix: `${hash}${cacheBuster}unbundled/`,\n });\n\n for (const [importPath, actualEntryPath] of Object.entries(entryPaths)) {\n const resolvedImportPath = importPath.replace('.', `${name}`);\n packageImportPaths?.add(entry.path, resolvedImportPath);\n importMap[resolvedImportPath] = new URL(actualEntryPath, 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,5 +1,5 @@
1
- import { type CloudpackConfig } from '@ms-cloudpack/config-types';
2
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
+ import { type CloudpackConfig } from '@ms-cloudpack/config-types';
3
3
  export type FindFileInPackageOptions = {
4
4
  packagePath: string;
5
5
  filePath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE,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,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,uBAAuB,CAAC,CAoFlC"}
1
+ {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAYlE,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,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE,OAAO,CAAC,uBAAuB,CAAC,CAoFlC"}
@@ -1,10 +1,10 @@
1
- import path from 'path';
2
- import { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';
3
1
  import {} from '@ms-cloudpack/config-types';
4
- import { safeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';
5
- import { getExportsMap } from './getExportsMap.js';
2
+ import { normalizeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';
3
+ import { intermediateToSourcePath, isFileSync, sourceToIntermediatePath } from '@ms-cloudpack/path-utilities';
4
+ import path from 'path';
6
5
  import { flattenExportsMap } from './flattenExportsMap.js';
7
6
  import { getCandidates } from './getCandidates.js';
7
+ import { getExportsMap } from './getExportsMap.js';
8
8
  import { isExternalPackage } from './isExternalPackage.js';
9
9
  const sourceExtensions = ['.ts', '.tsx', '.cts', '.mts', '.jsx'];
10
10
  const javascriptExtensions = ['.js', '.mjs', '.cjs'];
@@ -19,7 +19,7 @@ const javascriptExtensions = ['.js', '.mjs', '.cjs'];
19
19
  * exist, then we should not include it in the exports map.
20
20
  */
21
21
  export async function findFileInPackage(options, context) {
22
- const originalPath = safeRelativePath(options.filePath);
22
+ const originalPath = normalizeRelativePath(options.filePath);
23
23
  const packagePath = slash(options.packagePath);
24
24
  let filePath;
25
25
  let sourcePath;
@@ -40,9 +40,9 @@ export async function findFileInPackage(options, context) {
40
40
  return {
41
41
  ...(await findFileInPackage({
42
42
  packagePath,
43
- filePath: safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),
43
+ filePath: normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),
44
44
  }, context)),
45
- typesPath: typesPath && safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),
45
+ typesPath: typesPath && normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),
46
46
  };
47
47
  }
48
48
  }
@@ -73,13 +73,13 @@ export async function findFileInPackage(options, context) {
73
73
  }
74
74
  }
75
75
  if (typesPath) {
76
- result.typesPath = safeRelativePath(typesPath);
76
+ result.typesPath = normalizeRelativePath(typesPath);
77
77
  }
78
78
  if (filePath) {
79
- result.filePath = safeRelativePath(filePath);
79
+ result.filePath = normalizeRelativePath(filePath);
80
80
  }
81
81
  if (sourcePath) {
82
- result.sourcePath = safeRelativePath(sourcePath);
82
+ result.sourcePath = normalizeRelativePath(sourcePath);
83
83
  }
84
84
  return result;
85
85
  }
@@ -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,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAarD;;;;;;;;;GASG;AACH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AAS,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,CAAC;YAClE,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;IACH,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\nimport { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\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; config: CloudpackConfig },\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 }, context);\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"]}
1
+ {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAarD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAC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C,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,CAAC;YAClE,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;IACH,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,SAAS,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,UAAU,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { normalizeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, isFileSync, sourceToIntermediatePath } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport { getCandidates } from './getCandidates.js';\nimport { getExportsMap } from './getExportsMap.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; config: CloudpackConfig },\n): Promise<FindFileInPackageResult> {\n const originalPath = normalizeRelativePath(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 }, context);\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: normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n )),\n typesPath:\n typesPath && normalizeRelativePath(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 = normalizeRelativePath(typesPath);\n }\n\n if (filePath) {\n result.filePath = normalizeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = normalizeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
1
+ import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
2
  import {} from '@ms-cloudpack/config-types';
3
3
  import path from 'path';
4
4
  import { isExternalPackage } from './isExternalPackage.js';
@@ -34,7 +34,7 @@ export function getCandidates(options, context) {
34
34
  const { filePath, packagePath } = options;
35
35
  const resolveWebExtensions = Boolean(context.config.features?.resolveWebExtensions);
36
36
  const isBlankPath = !filePath || filePath === '.';
37
- const originalPath = isBlankPath ? './index' : safeRelativePath(filePath);
37
+ const originalPath = isBlankPath ? './index' : normalizeRelativePath(filePath);
38
38
  const originalExt = path.extname(originalPath);
39
39
  const isInternal = !isExternalPackage(packagePath);
40
40
  const endsWithSlash = originalPath.endsWith('/');
@@ -1 +1 @@
1
- {"version":3,"file":"getCandidates.js","sourceRoot":"","sources":["../src/getCandidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB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EAAE,CAAC;IACjD,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\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': ['.js'],\n '.tsx': ['.js'],\n '.mts': ['.mjs'],\n '.cts': ['.cjs'],\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(\n options: { filePath: string; packagePath: string },\n context: { config: CloudpackConfig },\n) {\n const { filePath, packagePath } = options;\n const resolveWebExtensions = Boolean(context.config.features?.resolveWebExtensions);\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 defaultExtensionsWithSuffixes = resolveWebExtensions\n ? [...defaultExtensions.map((ext) => `.web${ext}`), ...defaultExtensions]\n : defaultExtensions;\n const extensions =\n (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensionsWithSuffixes;\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 }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oB;IAC9D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,QAAQ,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;IACjD,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\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': ['.js'],\n '.tsx': ['.js'],\n '.mts': ['.mjs'],\n '.cts': ['.cjs'],\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(\n options: { filePath: string; packagePath: string },\n context: { config: CloudpackConfig },\n) {\n const { filePath, packagePath } = options;\n const resolveWebExtensions = Boolean(context.config.features?.resolveWebExtensions);\n const isBlankPath = !filePath || filePath === '.';\n const originalPath = isBlankPath ? './index' : normalizeRelativePath(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 defaultExtensionsWithSuffixes = resolveWebExtensions\n ? [...defaultExtensions.map((ext) => `.web${ext}`), ...defaultExtensions]\n : defaultExtensions;\n const extensions =\n (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensionsWithSuffixes;\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"]}
@@ -23,7 +23,7 @@ export function getNonSemverTransform() {
23
23
  if (!depVersion || semver.validRange(depVersion)) {
24
24
  continue;
25
25
  }
26
- console.warn(`Non-semver dependency found: ${depName}@${depVersion} ` +
26
+ console.debug(`Non-semver dependency found: ${depName}@${depVersion} ` +
27
27
  `(in ${definition.name}@${definition.version} at ${packagePath}). ` +
28
28
  "Cloudpack will attempt to handle this, but it's recommended to use semantic versions only if possible.");
29
29
  // Update the version in the returned dependencies:
@@ -1 +1 @@
1
- {"version":3,"file":"getNonSemverTransform.js","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAU,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC;;;OAGG;IACH,MAAM,aAAa,GAGf,EAAE,CAAC;IAEP,OAAO,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,EAAE;QACtD,MAAM,MAAM,GAAyB,EAAE,CAAC;QAExC,oCAAoC;QACpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEvC,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,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,CAAC;gBAED,qFAAqF;gBACrF,sFAAsF;gBACtF,qFAAqF;gBACrF,+BAA+B;gBAC/B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;gBAC3B,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACpC,MAAM,CAAC,iBAAiB,GAAG;oBACzB,YAAY,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;oBACnC,eAAe,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;iBAC1C,CAAC;gBACF,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';\nimport type { PackageJson } from '@ms-cloudpack/config-types';\nimport semver from 'semver';\nimport { generateVersionFromNonSemver } from './generateVersionFromNonSemver.js';\n\nconst depTypes = ['dependencies', 'peerDependencies'] as const;\n\n/**\n * Get a transform which handles non-semver dependencies:\n * - In a parent package, if a dependency is specified with a non-semver version, change the dep\n * to a special `0.0.0-<original-version>` prerelease version.\n * - In a child package, if the package was pulled in as a non-semver dependency by a parent\n * (per the `importerContext`), change its version to the special prerelease version as above.\n */\nexport function getNonSemverTransform(): PackageDefinitionTransform {\n /**\n * Cached info about parent packages with non-semver dependencies:\n * Map from parent name/version => dep type => non-semver dependency names\n */\n const nonSemverDeps: Record<\n `${string}@${string}`,\n Partial<Record<'dependencies' | 'peerDependencies', string[]>>\n > = {};\n\n return ({ definition, packagePath, importerContext }) => {\n const result: Partial<PackageJson> = {};\n\n // Check for non-semver dependencies\n for (const depType of depTypes) {\n const deps = definition[depType] || {};\n\n for (const [depName, depVersion] of Object.entries(deps)) {\n if (!depVersion || semver.validRange(depVersion)) {\n continue;\n }\n\n console.warn(\n `Non-semver dependency found: ${depName}@${depVersion} ` +\n `(in ${definition.name}@${definition.version} at ${packagePath}). ` +\n \"Cloudpack will attempt to handle this, but it's recommended to use semantic versions only if possible.\",\n );\n\n // Update the version in the returned dependencies:\n // \"bar\": \"npm:@custom/bar@^1\" => \"0.0.0-npm--custom-bar--1\"\n const resultDeps = (result[depType] ??= { ...deps });\n resultDeps[depName] = generateVersionFromNonSemver(depVersion);\n\n // Save that this was a non-semver dep\n const record = (nonSemverDeps[`${definition.name}@${definition.version}`] ??= {});\n (record[depType] ??= []).push(depName);\n }\n }\n\n // If this package's parent pulled it in with a non-semver dependency, make some more updates\n // (see below)\n const nonSemverParentInfo =\n importerContext && nonSemverDeps[`${importerContext.parentName}@${importerContext.parentVersion}`];\n\n // TODO: maybe this could also be used for resolutions if we have problems there:\n // adding a check for !semver.satisfies(requiredAs, definition.version) and forcing the package version?\n\n if (nonSemverParentInfo) {\n // Example: the parent depended on this package as \"bar\": \"npm:@custom/bar@^1\"\n // importedName = bar\n // versionRequirement = 0.0.0-npm--custom-bar--1 (was modified when this transform ran on the parent definition)\n const { importedName, versionRequirement } = importerContext;\n\n for (const depType of depTypes) {\n if (!nonSemverParentInfo[depType]?.includes(importedName)) {\n continue;\n }\n\n // To ensure other code handles this package properly, change its name and version to\n // the ones used by the parent (after transforms). This ensures it works properly with\n // the resolve map and isn't accidentally used by other packages which depend on this\n // package under its real name.\n result.name = importedName;\n result.version = versionRequirement;\n result.cloudpackRemapped = {\n originalName: definition.name || '',\n originalVersion: definition.version || '',\n };\n break;\n }\n }\n\n if (Object.keys(result).length) {\n return { ...definition, ...result };\n }\n return undefined;\n };\n}\n"]}
1
+ {"version":3,"file":"getNonSemverTransform.js","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,QAAQ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AAc;QACd,MAAM,mBAAmB,GACvB,eAAe,IAAI,aAAa,CAAC,GAAG,eAAe,CAAC,UAAU,IAAI,eAAe,CAAC,aAAa,EAAE,CAAC,CAAC;QAErG,iFAAiF;QACjF,wGAAwG;QAExG,IAAI,mBAAmB,EAAE,CAAC;YACxB,8EAA8E;YAC9E,uBAAuB;YACvB,kHAAkH;YAClH,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAAG,eAAe,CAAC;YAE7D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC1D,SAAS;gBACX,CAAC;gBAED,qFAAqF;gBACrF,sFAAsF;gBACtF,qFAAqF;gBACrF,+BAA+B;gBAC/B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;gBAC3B,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACpC,MAAM,CAAC,iBAAiB,GAAG;oBACzB,YAAY,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;oBACnC,eAAe,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;iBAC1C,CAAC;gBACF,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';\nimport type { PackageJson } from '@ms-cloudpack/config-types';\nimport semver from 'semver';\nimport { generateVersionFromNonSemver } from './generateVersionFromNonSemver.js';\n\nconst depTypes = ['dependencies', 'peerDependencies'] as const;\n\n/**\n * Get a transform which handles non-semver dependencies:\n * - In a parent package, if a dependency is specified with a non-semver version, change the dep\n * to a special `0.0.0-<original-version>` prerelease version.\n * - In a child package, if the package was pulled in as a non-semver dependency by a parent\n * (per the `importerContext`), change its version to the special prerelease version as above.\n */\nexport function getNonSemverTransform(): PackageDefinitionTransform {\n /**\n * Cached info about parent packages with non-semver dependencies:\n * Map from parent name/version => dep type => non-semver dependency names\n */\n const nonSemverDeps: Record<\n `${string}@${string}`,\n Partial<Record<'dependencies' | 'peerDependencies', string[]>>\n > = {};\n\n return ({ definition, packagePath, importerContext }) => {\n const result: Partial<PackageJson> = {};\n\n // Check for non-semver dependencies\n for (const depType of depTypes) {\n const deps = definition[depType] || {};\n\n for (const [depName, depVersion] of Object.entries(deps)) {\n if (!depVersion || semver.validRange(depVersion)) {\n continue;\n }\n\n console.debug(\n `Non-semver dependency found: ${depName}@${depVersion} ` +\n `(in ${definition.name}@${definition.version} at ${packagePath}). ` +\n \"Cloudpack will attempt to handle this, but it's recommended to use semantic versions only if possible.\",\n );\n\n // Update the version in the returned dependencies:\n // \"bar\": \"npm:@custom/bar@^1\" => \"0.0.0-npm--custom-bar--1\"\n const resultDeps = (result[depType] ??= { ...deps });\n resultDeps[depName] = generateVersionFromNonSemver(depVersion);\n\n // Save that this was a non-semver dep\n const record = (nonSemverDeps[`${definition.name}@${definition.version}`] ??= {});\n (record[depType] ??= []).push(depName);\n }\n }\n\n // If this package's parent pulled it in with a non-semver dependency, make some more updates\n // (see below)\n const nonSemverParentInfo =\n importerContext && nonSemverDeps[`${importerContext.parentName}@${importerContext.parentVersion}`];\n\n // TODO: maybe this could also be used for resolutions if we have problems there:\n // adding a check for !semver.satisfies(requiredAs, definition.version) and forcing the package version?\n\n if (nonSemverParentInfo) {\n // Example: the parent depended on this package as \"bar\": \"npm:@custom/bar@^1\"\n // importedName = bar\n // versionRequirement = 0.0.0-npm--custom-bar--1 (was modified when this transform ran on the parent definition)\n const { importedName, versionRequirement } = importerContext;\n\n for (const depType of depTypes) {\n if (!nonSemverParentInfo[depType]?.includes(importedName)) {\n continue;\n }\n\n // To ensure other code handles this package properly, change its name and version to\n // the ones used by the parent (after transforms). This ensures it works properly with\n // the resolve map and isn't accidentally used by other packages which depend on this\n // package under its real name.\n result.name = importedName;\n result.version = versionRequirement;\n result.cloudpackRemapped = {\n originalName: definition.name || '',\n originalVersion: definition.version || '',\n };\n break;\n }\n }\n\n if (Object.keys(result).length) {\n return { ...definition, ...result };\n }\n return undefined;\n };\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  /**
2
- * Get the resolved bundled or unbundled file path as appropriate, with the correct extension.
3
- * @returns The path, or undefined if a bundled path was requested and the entry is a .d.ts file
4
- * (which doesn't exist at runtime).
2
+ * @deprecated Use `getRuntimeEntryPaths`
5
3
  */
6
4
  export declare function getResolvedFilePath(params: {
7
5
  entryPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"getResolvedFilePath.d.ts","sourceRoot":"","sources":["../src/getResolvedFilePath.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,GAAG,SAAS,CAmCrB"}
1
+ {"version":3,"file":"getResolvedFilePath.d.ts","sourceRoot":"","sources":["../src/getResolvedFilePath.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,GAAG,SAAS,CAmCrB"}
@@ -1,8 +1,6 @@
1
1
  import path from 'path';
2
2
  /**
3
- * Get the resolved bundled or unbundled file path as appropriate, with the correct extension.
4
- * @returns The path, or undefined if a bundled path was requested and the entry is a .d.ts file
5
- * (which doesn't exist at runtime).
3
+ * @deprecated Use `getRuntimeEntryPaths`
6
4
  */
7
5
  export function getResolvedFilePath(params) {
8
6
  const { entryPath, isExternal, unbundledExportsMap, bundledFilePath, bundledPrefix = '', unbundledPrefix = '', } = params;
@@ -1 +1 @@
1
- {"version":3,"file":"getResolvedFilePath.js","sourceRoot":"","sources":["../src/getResolvedFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAOnC;IACC,MAAM,EACJ,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,aAAa,GAAG,EAAE,EAClB,eAAe,GAAG,EAAE,GACrB,GAAG,MAAM,CAAC;IAEX,MAAM,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,IAAI,gBAAgB,GAAG,iBAAiB,CAAC,CAAC,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAAC,CAAC,aAAa,GAAG,eAAe,CAAC;IAEjH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE3C,qBAAqB;IACrB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,uBAAuB;QACvB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,0EAA0E;QAC1E,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;YAClB,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;QACJ,CAAC;QAED,kDAAkD;QAClD,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Get the resolved bundled or unbundled file path as appropriate, with the correct extension.\n * @returns The path, or undefined if a bundled path was requested and the entry is a .d.ts file\n * (which doesn't exist at runtime).\n */\nexport function getResolvedFilePath(params: {\n entryPath: string;\n isExternal: boolean;\n unbundledExportsMap: Record<string, string>;\n bundledFilePath: string;\n bundledPrefix?: string;\n unbundledPrefix?: string;\n}): string | undefined {\n const {\n entryPath,\n isExternal,\n unbundledExportsMap,\n bundledFilePath,\n bundledPrefix = '',\n unbundledPrefix = '',\n } = params;\n\n const unbundledFilePath = isExternal ? unbundledExportsMap[entryPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? unbundledPrefix + unbundledFilePath : bundledPrefix + bundledFilePath;\n\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 return undefined;\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 return resolvedFilePath;\n}\n"]}
1
+ {"version":3,"file":"getResolvedFilePath.js","sourceRoot":"","sources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\n */\nexport function getResolvedFilePath(params: {\n entryPath: string;\n isExternal: boolean;\n unbundledExportsMap: Record<string, string>;\n bundledFilePath: string;\n bundledPrefix?: string;\n unbundledPrefix?: string;\n}): string | undefined {\n const {\n entryPath,\n isExternal,\n unbundledExportsMap,\n bundledFilePath,\n bundledPrefix = '',\n unbundledPrefix = '',\n } = params;\n\n const unbundledFilePath = isExternal ? unbundledExportsMap[entryPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? unbundledPrefix + unbundledFilePath : bundledPrefix + bundledFilePath;\n\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 return undefined;\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 return resolvedFilePath;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { PackageJsonExports } from '@ms-cloudpack/config-types';
2
+ /**
3
+ * For each path in the exports map, get the actual file path that will be used at runtime.
4
+ * - Prefers unbundled (browser-esm) paths for external packages if such paths exist.
5
+ * - Otherwise, uses bundled paths with the correct extension.
6
+ * - Omits any paths that won't exist at runtime, like .d.ts.
7
+ *
8
+ * @returns Mapping from import path (same as original exports map keys) to actual relative
9
+ * file path that will be used at runtime.
10
+ */
11
+ export declare function getRuntimeEntryPaths(params: {
12
+ /** Exports map for a package */
13
+ exportsMap: PackageJsonExports;
14
+ /** Whether the package is external to the repo */
15
+ isExternal: boolean;
16
+ /** Prefix for bundled file paths */
17
+ bundledPrefix?: string;
18
+ /** Prefix for unbundled file paths */
19
+ unbundledPrefix?: string;
20
+ }): Record<string, string>;
21
+ //# sourceMappingURL=getRuntimeEntryPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRuntimeEntryPaths.d.ts","sourceRoot":"","sources":["../src/getRuntimeEntryPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIrE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,gCAAgC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0CzB"}
@@ -0,0 +1,44 @@
1
+ import path from 'path';
2
+ import { flattenExportsMap } from './flattenExportsMap.js';
3
+ /**
4
+ * For each path in the exports map, get the actual file path that will be used at runtime.
5
+ * - Prefers unbundled (browser-esm) paths for external packages if such paths exist.
6
+ * - Otherwise, uses bundled paths with the correct extension.
7
+ * - Omits any paths that won't exist at runtime, like .d.ts.
8
+ *
9
+ * @returns Mapping from import path (same as original exports map keys) to actual relative
10
+ * file path that will be used at runtime.
11
+ */
12
+ export function getRuntimeEntryPaths(params) {
13
+ const { exportsMap, isExternal, bundledPrefix = '', unbundledPrefix = '' } = params;
14
+ const result = {};
15
+ // Get both the unbundled and bundled entries from the exports map
16
+ const unbundledExportsMap = flattenExportsMap(exportsMap, {
17
+ conditions: ['browser-esm'],
18
+ requiredConditions: ['browser-esm'],
19
+ });
20
+ const bundledExportsMap = flattenExportsMap(exportsMap);
21
+ for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {
22
+ const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;
23
+ let actualFilePath = unbundledFilePath ? unbundledPrefix + unbundledFilePath : bundledPrefix + bundledFilePath;
24
+ const ext = path.extname(actualFilePath);
25
+ // For bundled files:
26
+ if (!unbundledFilePath) {
27
+ // Ignore .d.ts entries
28
+ if (actualFilePath.endsWith('.d.ts')) {
29
+ continue;
30
+ }
31
+ // We always expect responses to come back as javascript (.js extensions.)
32
+ if (ext !== '.js') {
33
+ actualFilePath = path.join(path.dirname(actualFilePath), path.basename(actualFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'));
34
+ }
35
+ // Plus signs should be replaced with underscores.
36
+ actualFilePath = actualFilePath.replace(/\+/g, '_');
37
+ }
38
+ if (actualFilePath !== undefined) {
39
+ result[importPath] = actualFilePath;
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+ //# sourceMappingURL=getRuntimeEntryPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRuntimeEntryPaths.js","sourceRoot":"","sources":["../src/getRuntimeEntryPaths.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,MASpC;IACC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IACpF,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,kEAAkE;IAClE,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,UAAU,EAAE;QACxD,UAAU,EAAE,CAAC,aAAa,CAAC;QAC3B,kBAAkB,EAAE,CAAC,aAAa,CAAC;KACpC,CAAC,CAAC;IACH,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAExD,KAAK,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC9E,MAAM,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnF,IAAI,cAAc,GAAG,iBAAiB,CAAC,CAAC,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAAC,CAAC,aAAa,GAAG,eAAe,CAAC;QAE/G,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEzC,qBAAqB;QACrB,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,uBAAuB;YACvB,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrC,SAAS;YACX,CAAC;YAED,0EAA0E;YAC1E,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;gBAClB,cAAc,GAAG,IAAI,CAAC,IAAI,CACxB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAC5B,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAC5E,CAAC;YACJ,CAAC;YAED,kDAAkD;YAClD,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJsonExports } from '@ms-cloudpack/config-types';\nimport path from 'path';\nimport { flattenExportsMap } from './flattenExportsMap.js';\n\n/**\n * For each path in the exports map, get the actual file path that will be used at runtime.\n * - Prefers unbundled (browser-esm) paths for external packages if such paths exist.\n * - Otherwise, uses bundled paths with the correct extension.\n * - Omits any paths that won't exist at runtime, like .d.ts.\n *\n * @returns Mapping from import path (same as original exports map keys) to actual relative\n * file path that will be used at runtime.\n */\nexport function getRuntimeEntryPaths(params: {\n /** Exports map for a package */\n exportsMap: PackageJsonExports;\n /** Whether the package is external to the repo */\n isExternal: boolean;\n /** Prefix for bundled file paths */\n bundledPrefix?: string;\n /** Prefix for unbundled file paths */\n unbundledPrefix?: string;\n}): Record<string, string> {\n const { exportsMap, isExternal, bundledPrefix = '', unbundledPrefix = '' } = params;\n const result: Record<string, string> = {};\n\n // Get both the unbundled and bundled 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\n for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {\n const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;\n let actualFilePath = unbundledFilePath ? unbundledPrefix + unbundledFilePath : bundledPrefix + bundledFilePath;\n\n const ext = path.extname(actualFilePath);\n\n // For bundled files:\n if (!unbundledFilePath) {\n // Ignore .d.ts entries\n if (actualFilePath.endsWith('.d.ts')) {\n continue;\n }\n\n // We always expect responses to come back as javascript (.js extensions.)\n if (ext !== '.js') {\n actualFilePath = path.join(\n path.dirname(actualFilePath),\n path.basename(actualFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'),\n );\n }\n\n // Plus signs should be replaced with underscores.\n actualFilePath = actualFilePath.replace(/\\+/g, '_');\n }\n\n if (actualFilePath !== undefined) {\n result[importPath] = actualFilePath;\n }\n }\n\n return result;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -24,4 +24,5 @@ export { findProjectRoot } from './findProjectRoot.js';
24
24
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
25
25
  export { getResolvedFilePath } from './getResolvedFilePath.js';
26
26
  export { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';
27
+ export { getRuntimeEntryPaths } from './getRuntimeEntryPaths.js';
27
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[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,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;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;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
package/lib/index.js CHANGED
@@ -28,4 +28,5 @@ export { findProjectRoot } from './findProjectRoot.js';
28
28
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
29
29
  export { getResolvedFilePath } from './getResolvedFilePath.js';
30
30
  export { ensurePackageJsonDependencies } from './ensurePackageJsonDependencies.js';
31
+ export { getRuntimeEntryPaths } from './getRuntimeEntryPaths.js';
31
32
  //# 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,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"]}
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;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,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';\nexport { getRuntimeEntryPaths } from './getRuntimeEntryPaths.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "5.10.5",
3
+ "version": "5.11.1",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,12 +14,12 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-types": "^0.24.5",
17
+ "@ms-cloudpack/bundler-types": "^0.25.0",
18
18
  "@ms-cloudpack/config-types": "^0.5.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.4",
20
- "@ms-cloudpack/package-overrides": "^0.6.21",
21
- "@ms-cloudpack/path-utilities": "^2.5.0",
22
- "@ms-cloudpack/path-string-parsing": "^1.1.3",
20
+ "@ms-cloudpack/package-overrides": "^0.6.22",
21
+ "@ms-cloudpack/path-utilities": "^2.6.0",
22
+ "@ms-cloudpack/path-string-parsing": "^1.2.0",
23
23
  "acorn": "^8.11.2",
24
24
  "acorn-walk": "^8.2.1",
25
25
  "fast-glob": "^3.2.12",