@ms-cloudpack/package-utilities 10.1.3 → 10.2.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.
@@ -22,11 +22,6 @@ export interface AddExportsMapEntryOptions {
22
22
  * assuming `index.js`.
23
23
  */
24
24
  filePath?: string;
25
- /**
26
- * Optional types path. If not provided, types will be discovered for internal packages that have source files.
27
- * This is useful mainly when converting the default import from a package.json that has explicit typings listed.
28
- */
29
- typesPath?: string;
30
25
  /**
31
26
  * The condition to add the entry for. (Example: "import", "require") Defaults to "default".
32
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"addExportsMapEntry.d.ts","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAI/G;;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,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAEpD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,OAAO,CAAC,CA6ClB"}
1
+ {"version":3,"file":"addExportsMapEntry.d.ts","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAI/G;;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;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAEpD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,OAAO,CAAC,CAqClB"}
@@ -6,7 +6,7 @@ import { findFileInPackage } from './findFileInPackage.js';
6
6
  export async function addExportsMapEntry(options, context) {
7
7
  const { exports, packagePath, environmentCondition, requestCondition } = options;
8
8
  const importPath = normalizeRelativePath(options.importPath);
9
- const { filePath, sourcePath, typesPath = options.typesPath ? normalizeRelativePath(options.typesPath) : undefined, } = await findFileInPackage({
9
+ const { filePath, sourcePath } = await findFileInPackage({
10
10
  packagePath,
11
11
  filePath: options.filePath || options.importPath || '',
12
12
  }, context);
@@ -18,14 +18,11 @@ export async function addExportsMapEntry(options, context) {
18
18
  const localExports = exports;
19
19
  let exportValue;
20
20
  // If this is the only entry we're adding, set it to a string to minimize the exports map.
21
- if (!typesPath && !sourcePath && !requestCondition) {
21
+ if (!sourcePath && !requestCondition) {
22
22
  exportValue = filePath;
23
23
  }
24
24
  else {
25
25
  exportValue = {};
26
- if (typesPath) {
27
- exportValue['types'] = typesPath;
28
- }
29
26
  if (sourcePath) {
30
27
  exportValue['source'] = sourcePath;
31
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"addExportsMapEntry.js","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA+C3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAkC,EAClC,OAAyF;IAEzF,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IACjF,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,EACJ,QAAQ,EACR,UAAU,EACV,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,GACrF,GAAG,MAAM,iBAAiB,CACzB;QACE,WAAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE;KACvD,EACD,OAAO,CACR,CAAC;IAEF,yCAAyC;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8BAA8B;IAC9B,MAAM,YAAY,GAAG,OAAmF,CAAC;IACzG,IAAI,WAA4C,CAAC;IAEjD,0FAA0F;IAC1F,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACnD,WAAW,GAAG,QAAQ,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,EAAE,CAAC;QAEjB,IAAI,SAAS,EAAE,CAAC;YACd,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;QACnC,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,WAAW,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QACrC,CAAC;QAED,mCAAmC;QACnC,WAAW,CAAC,gBAAgB,IAAI,SAAS,CAAC,GAAG,QAAQ,CAAC;IACxD,CAAC;IAED,YAAY,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAExG,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache, PackageJsonExports } from '@ms-cloudpack/common-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\") Defaults to \"default\".\n */\n requestCondition?: 'import' | 'require' | 'browser';\n\n /**\n * The condition that describes the environment the entry is for. (Example: \"browser\", \"node\".)\n * Unspecified implies environmentally agnostic.\n */\n environmentCondition?: 'browser' | 'node';\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: Pick<CloudpackConfig, 'features'> },\n): Promise<boolean> {\n const { exports, packagePath, environmentCondition, requestCondition } = options;\n const importPath = normalizeRelativePath(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 | Record<string, string>>>;\n let exportValue: 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 (!typesPath && !sourcePath && !requestCondition) {\n exportValue = filePath;\n } else {\n exportValue = {};\n\n if (typesPath) {\n exportValue['types'] = typesPath;\n }\n\n if (sourcePath) {\n exportValue['source'] = sourcePath;\n }\n\n // Add the entry for the condition.\n exportValue[requestCondition || 'default'] = filePath;\n }\n\n localExports[importPath] = environmentCondition ? { [environmentCondition]: exportValue } : exportValue;\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"addExportsMapEntry.js","sourceRoot":"","sources":["../src/addExportsMapEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAyC3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAkC,EAClC,OAAyF;IAEzF,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IACjF,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,MAAM,iBAAiB,CACtD;QACE,WAAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE;KACvD,EACD,OAAO,CACR,CAAC;IAEF,yCAAyC;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8BAA8B;IAC9B,MAAM,YAAY,GAAG,OAAmF,CAAC;IACzG,IAAI,WAA4C,CAAC;IAEjD,0FAA0F;IAC1F,IAAI,CAAC,UAAU,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACrC,WAAW,GAAG,QAAQ,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,EAAE,CAAC;QAEjB,IAAI,UAAU,EAAE,CAAC;YACf,WAAW,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QACrC,CAAC;QAED,mCAAmC;QACnC,WAAW,CAAC,gBAAgB,IAAI,SAAS,CAAC,GAAG,QAAQ,CAAC;IACxD,CAAC;IAED,YAAY,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAExG,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache, PackageJsonExports } from '@ms-cloudpack/common-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 * The condition to add the entry for. (Example: \"import\", \"require\") Defaults to \"default\".\n */\n requestCondition?: 'import' | 'require' | 'browser';\n\n /**\n * The condition that describes the environment the entry is for. (Example: \"browser\", \"node\".)\n * Unspecified implies environmentally agnostic.\n */\n environmentCondition?: 'browser' | 'node';\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: Pick<CloudpackConfig, 'features'> },\n): Promise<boolean> {\n const { exports, packagePath, environmentCondition, requestCondition } = options;\n const importPath = normalizeRelativePath(options.importPath);\n const { filePath, sourcePath } = 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 | Record<string, string>>>;\n let exportValue: 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 (!sourcePath && !requestCondition) {\n exportValue = filePath;\n } else {\n exportValue = {};\n\n if (sourcePath) {\n exportValue['source'] = sourcePath;\n }\n\n // Add the entry for the condition.\n exportValue[requestCondition || 'default'] = filePath;\n }\n\n localExports[importPath] = environmentCondition ? { [environmentCondition]: exportValue } : exportValue;\n\n return true;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAI/G;;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,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,kBAAkB,CAAC,CAoG7B"}
1
+ {"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAI/G;;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,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,kBAAkB,CAAC,CAgG7B"}
@@ -11,16 +11,14 @@ export async function createExportsMap(options, context) {
11
11
  if (definition.exports) {
12
12
  return definition.exports;
13
13
  }
14
- const { browser, main, module, types, typings, type } = definition;
14
+ const { browser, main, module, type } = definition;
15
15
  const exports = {};
16
- const typesPath = types || typings;
17
16
  // Only try to add `index.js` as an entry if main/module/browser isn't available.
18
17
  if (!(main || module || browser)) {
19
18
  await addExportsMapEntry({
20
19
  exports,
21
20
  packagePath,
22
21
  filePath: 'index.js',
23
- typesPath,
24
22
  requestCondition: type === 'module' ? 'import' : undefined,
25
23
  }, context);
26
24
  }
@@ -29,7 +27,6 @@ export async function createExportsMap(options, context) {
29
27
  exports,
30
28
  packagePath,
31
29
  filePath: main,
32
- typesPath,
33
30
  requestCondition: type === 'module' ? 'import' : undefined,
34
31
  }, context);
35
32
  }
@@ -38,7 +35,6 @@ export async function createExportsMap(options, context) {
38
35
  exports,
39
36
  packagePath,
40
37
  filePath: module,
41
- typesPath,
42
38
  requestCondition: 'import',
43
39
  }, context);
44
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createExportsMap.js","sourceRoot":"","sources":["../src/createExportsMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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BACf,gBAAgB,EAAE,SAAS;qBAC5B,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 { CloudpackConfig, PackageDefinitionsCache, PackageJsonExports } from '@ms-cloudpack/common-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: Pick<CloudpackConfig, 'features'> },\n): Promise<PackageJsonExports> {\n const { packagePath } = options;\n const { packages } = context;\n const definition = await packages.get(packagePath, { disableTransforms: options.disableTransforms });\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 // Only try to add `index.js` as an entry if main/module/browser isn't available.\n if (!(main || module || browser)) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: 'index.js',\n typesPath,\n requestCondition: type === 'module' ? 'import' : undefined,\n },\n context,\n );\n }\n\n if (main) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: main,\n typesPath,\n requestCondition: type === 'module' ? 'import' : undefined,\n },\n context,\n );\n }\n\n if (module) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: module,\n typesPath,\n requestCondition: 'import',\n },\n context,\n );\n }\n\n if (browser) {\n if (typeof definition.browser === 'string') {\n await addExportsMapEntry(\n { exports, packagePath, filePath: definition.browser, requestCondition: 'browser' },\n context,\n );\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 requestCondition: '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":"AACA,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,OAAyF;IAEzF,MAAM,EAAE,WAAW,EAAE,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AE,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 { CloudpackConfig, PackageDefinitionsCache, PackageJsonExports } from '@ms-cloudpack/common-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: Pick<CloudpackConfig, 'features'> },\n): Promise<PackageJsonExports> {\n const { packagePath } = options;\n const { packages } = context;\n const definition = await packages.get(packagePath, { disableTransforms: options.disableTransforms });\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, type } = definition;\n const exports = {};\n\n // Only try to add `index.js` as an entry if main/module/browser isn't available.\n if (!(main || module || browser)) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: 'index.js',\n requestCondition: type === 'module' ? 'import' : undefined,\n },\n context,\n );\n }\n\n if (main) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: main,\n requestCondition: type === 'module' ? 'import' : undefined,\n },\n context,\n );\n }\n\n if (module) {\n await addExportsMapEntry(\n {\n exports,\n packagePath,\n filePath: module,\n requestCondition: 'import',\n },\n context,\n );\n }\n\n if (browser) {\n if (typeof definition.browser === 'string') {\n await addExportsMapEntry(\n { exports, packagePath, filePath: definition.browser, requestCondition: 'browser' },\n context,\n );\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 requestCondition: '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"]}
@@ -5,7 +5,6 @@ export type FindFileInPackageOptions = {
5
5
  };
6
6
  export type FindFileInPackageResult = {
7
7
  filePath?: string;
8
- typesPath?: string;
9
8
  sourcePath?: string;
10
9
  };
11
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAY3F,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,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,uBAAuB,CAAC,CAyGlC"}
1
+ {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAY3F,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,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,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,GACxF,OAAO,CAAC,uBAAuB,CAAC,CAqFlC"}
@@ -22,7 +22,6 @@ export async function findFileInPackage(options, context) {
22
22
  const packagePath = slash(options.packagePath);
23
23
  let filePath;
24
24
  let sourcePath;
25
- let typesPath;
26
25
  const isInternal = !isExternalPackage(packagePath);
27
26
  const pathsToConsider = [originalPath];
28
27
  const definition = await context.packages.tryGet(packagePath, { disableTransforms: true });
@@ -51,14 +50,10 @@ export async function findFileInPackage(options, context) {
51
50
  const exportsMap = await getExportsMap({ packagePath: nestedDefinitionPath }, context);
52
51
  const entryPath = flattenExportsMap(exportsMap)['.'];
53
52
  if (entryPath) {
54
- typesPath = flattenExportsMap(exportsMap, { conditions: ['types'] })['.'];
55
- return {
56
- ...(await findFileInPackage({
57
- packagePath,
58
- filePath: normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),
59
- }, context)),
60
- typesPath: typesPath && normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),
61
- };
53
+ return findFileInPackage({
54
+ packagePath,
55
+ filePath: normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),
56
+ }, context);
62
57
  }
63
58
  else {
64
59
  // If we can't find an entry, we should not include this in the exports map.
@@ -84,16 +79,6 @@ export async function findFileInPackage(options, context) {
84
79
  }
85
80
  }
86
81
  }
87
- // Try to resolve the typesPath
88
- if (sourcePath && filePath) {
89
- typesPath = filePath.replace(/\.js$/, '.d.ts');
90
- if (!isInternal && !isFileSync(path.join(packagePath, typesPath))) {
91
- typesPath = undefined;
92
- }
93
- }
94
- if (typesPath) {
95
- result.typesPath = normalizeRelativePath(typesPath);
96
- }
97
82
  if (filePath) {
98
83
  result.filePath = normalizeRelativePath(filePath);
99
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AACA,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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CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-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: Pick<CloudpackConfig, 'features'> },\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 pathsToConsider = [originalPath];\n\n const definition = await context.packages.tryGet(packagePath, { disableTransforms: true });\n // If the original package.json has an exports map, we should not use main and module as hints.\n if (originalPath === '.' && definition && !definition.exports) {\n const { main, module } = definition;\n if (main) {\n pathsToConsider.unshift(main);\n }\n if (module) {\n pathsToConsider.unshift(module);\n }\n }\n\n for (const currentPath of pathsToConsider) {\n const candidates = await getCandidates({ filePath: currentPath, packagePath }, context);\n\n // Try and resolve a physical file given the candidates.\n filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));\n if (filePath) {\n break;\n }\n }\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 } else {\n // If we can't find an entry, we should not include this in the exports map.\n // This avoids adding a \"./package.json\" value to a \".\" entry.\n return result;\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 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
+ {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AACA,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;AAYrD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAiC,EACjC,OAAyF;IAEzF,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,QAA4B,CAAC;IACjC,IAAI,UAA8B,CAAC;IACnC,MAAM,UAAU,GAAG,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,eAAe,GAAG,CAAC,YAAY,CAAC,CAA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,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 { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-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 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: Pick<CloudpackConfig, 'features'> },\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 const isInternal = !isExternalPackage(packagePath);\n const pathsToConsider = [originalPath];\n\n const definition = await context.packages.tryGet(packagePath, { disableTransforms: true });\n // If the original package.json has an exports map, we should not use main and module as hints.\n if (originalPath === '.' && definition && !definition.exports) {\n const { main, module } = definition;\n if (main) {\n pathsToConsider.unshift(main);\n }\n if (module) {\n pathsToConsider.unshift(module);\n }\n }\n\n for (const currentPath of pathsToConsider) {\n const candidates = await getCandidates({ filePath: currentPath, packagePath }, context);\n\n // Try and resolve a physical file given the candidates.\n filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));\n if (filePath) {\n break;\n }\n }\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 return findFileInPackage(\n {\n packagePath,\n filePath: normalizeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n );\n } else {\n // If we can't find an entry, we should not include this in the exports map.\n // This avoids adding a \"./package.json\" value to a \".\" entry.\n return result;\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 if (filePath) {\n result.filePath = normalizeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = normalizeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
@@ -9,6 +9,7 @@ export declare function mergeObjects<T extends object>(objects: T[], options?: {
9
9
  /**
10
10
  * Whether to concatenate all arrays (default) or overwrite with new values.
11
11
  * Applies to top-level and nested objects.
12
+ * @default 'concat'
12
13
  */
13
14
  arrayMerge?: 'concat' | 'overwrite';
14
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mergeObjects.d.ts","sourceRoot":"","sources":["../src/mergeObjects.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,OAAO,EAAE,CAAC,EAAE,EACZ,OAAO,GAAE;IACP;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE;SACX,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC9D,CAAC;CACE,GACL,CAAC,CAkCH"}
1
+ {"version":3,"file":"mergeObjects.d.ts","sourceRoot":"","sources":["../src/mergeObjects.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,OAAO,EAAE,CAAC,EAAE,EACZ,OAAO,GAAE;IACP;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE;SACX,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,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K,QAAQ,CAAC,CAAC,CAAE,CAAC,GAAG,CAAE,GAAG,CAAC,GAAG,CAAe,IAAI,EAAE,CAAC,EAAE,GAAG,GAAG,CAAgB,CAAC,CAAC,CAAC,GAAG,CAAC;YAC1G,CAAC;iBAAM,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC1C,0FAA0F;gBAC1F,sEAAsE;gBACtE,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAe,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Recursively merge objects.\n * Array values are concatenated by default, but this is configurable.\n * Assumes that the types of any defined keys stay consistent across all objects;\n * if this isn't true, provide a `customMerge` function for that key.\n * (`customMerge` must also be used to customize merging for nested objects.)\n */\nexport function mergeObjects<T extends object>(\n objects: T[],\n options: {\n /**\n * Whether to concatenate all arrays (default) or overwrite with new values.\n * Applies to top-level and nested objects.\n */\n arrayMerge?: 'concat' | 'overwrite';\n /**\n * Overwrite the values of these object or array keys instead of merging.\n * Applies to the top-level object only.\n */\n overwriteKeys?: (keyof T)[];\n /**\n * Custom merging for key values. The function should return the merged value.\n * Applies to the top-level object only.\n */\n customMerge?: {\n [K in keyof T]?: (prev: T[K] | undefined, curr: T[K]) => T[K];\n };\n } = {},\n): T {\n // NOTE: If other options are added, consider whether they should apply recursively,\n // and if so, update the mergeObjects() recursive call.\n const { customMerge, arrayMerge = 'concat', overwriteKeys } = options;\n\n const acc = {} as T;\n\n for (const obj of objects) {\n if (!obj || typeof obj !== 'object') {\n throw new Error('mergeObjects: all arguments must be objects');\n }\n\n for (const pair of Object.entries(obj)) {\n const key = pair[0] as keyof T;\n const val = pair[1] as T[typeof key];\n const customMergeKey = customMerge?.[key];\n\n if (customMergeKey) {\n acc[key] = customMergeKey(acc[key], val);\n } else if (overwriteKeys?.includes(key)) {\n acc[key] = val;\n } else if (Array.isArray(val)) {\n acc[key] = arrayMerge === 'concat' ? ([...((acc[key] as unknown[]) || []), ...val] as typeof val) : val;\n } else if (val && typeof val === 'object') {\n // Recursively merge objects. arrayMerge makes sense to apply recursively, but customMerge\n // and overwriteKeys are specific to the keys of the top-level object.\n acc[key] = mergeObjects([(acc[key] || {}) as typeof val, val], { arrayMerge });\n } else {\n acc[key] = val;\n }\n }\n }\n\n return acc;\n}\n"]}
1
+ {"version":3,"file":"mergeObjects.js","sourceRoot":"","sources":["../src/mergeObjects.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAY,EACZ,UAmBI,EAAE;IAEN,oFAAoF;IACpF,uDAAuD;IACvD,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAEtE,MAAM,GAAG,GAAG,EAAO,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAY,CAAC;YAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAkB,CAAC;YACrC,MAAM,cAAc,GAAG,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;YAE1C,IAAI,cAAc,EAAE,CAAC;gBACnB,GAAG,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;iBAAM,IAAI,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YACjB,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAC,GAAG,CAAE,GAAG,CAAC,GAAG,CAAe,IAAI,EAAE,CAAC,EAAE,GAAG,GAAG,CAAgB,CAAC,CAAC,CAAC,GAAG,CAAC;YAC1G,CAAC;iBAAM,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC1C,0FAA0F;gBAC1F,sEAAsE;gBACtE,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAe,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Recursively merge objects.\n * Array values are concatenated by default, but this is configurable.\n * Assumes that the types of any defined keys stay consistent across all objects;\n * if this isn't true, provide a `customMerge` function for that key.\n * (`customMerge` must also be used to customize merging for nested objects.)\n */\nexport function mergeObjects<T extends object>(\n objects: T[],\n options: {\n /**\n * Whether to concatenate all arrays (default) or overwrite with new values.\n * Applies to top-level and nested objects.\n * @default 'concat'\n */\n arrayMerge?: 'concat' | 'overwrite';\n /**\n * Overwrite the values of these object or array keys instead of merging.\n * Applies to the top-level object only.\n */\n overwriteKeys?: (keyof T)[];\n /**\n * Custom merging for key values. The function should return the merged value.\n * Applies to the top-level object only.\n */\n customMerge?: {\n [K in keyof T]?: (prev: T[K] | undefined, curr: T[K]) => T[K];\n };\n } = {},\n): T {\n // NOTE: If other options are added, consider whether they should apply recursively,\n // and if so, update the mergeObjects() recursive call.\n const { customMerge, arrayMerge = 'concat', overwriteKeys } = options;\n\n const acc = {} as T;\n\n for (const obj of objects) {\n if (!obj || typeof obj !== 'object') {\n throw new Error('mergeObjects: all arguments must be objects');\n }\n\n for (const pair of Object.entries(obj)) {\n const key = pair[0] as keyof T;\n const val = pair[1] as T[typeof key];\n const customMergeKey = customMerge?.[key];\n\n if (customMergeKey) {\n acc[key] = customMergeKey(acc[key], val);\n } else if (overwriteKeys?.includes(key)) {\n acc[key] = val;\n } else if (Array.isArray(val)) {\n acc[key] = arrayMerge === 'concat' ? ([...((acc[key] as unknown[]) || []), ...val] as typeof val) : val;\n } else if (val && typeof val === 'object') {\n // Recursively merge objects. arrayMerge makes sense to apply recursively, but customMerge\n // and overwriteKeys are specific to the keys of the top-level object.\n acc[key] = mergeObjects([(acc[key] || {}) as typeof val, val], { arrayMerge });\n } else {\n acc[key] = val;\n }\n }\n }\n\n return acc;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Determines if a package should be externalized from the bundle.
3
- * Don't externalize inlined packages, node builtins, absolute paths, or relative paths.
2
+ * @deprecated Use the one from `@ms-cloudpack/bundler-utilities` instead.
3
+ * (can be deleted in version 11 or later)
4
4
  */
5
5
  export declare function shouldExternalizePackage(params: {
6
6
  id: string;
@@ -2,8 +2,8 @@ import path from 'path';
2
2
  import { isBuiltin } from 'module';
3
3
  import { parseImportString } from '@ms-cloudpack/path-string-parsing';
4
4
  /**
5
- * Determines if a package should be externalized from the bundle.
6
- * Don't externalize inlined packages, node builtins, absolute paths, or relative paths.
5
+ * @deprecated Use the one from `@ms-cloudpack/bundler-utilities` instead.
6
+ * (can be deleted in version 11 or later)
7
7
  */
8
8
  export function shouldExternalizePackage(params) {
9
9
  const { id, inlined, external, polyfills, shouldInlineNodeBuiltins } = params;
@@ -1 +1 @@
1
- {"version":3,"file":"shouldExternalizePackage.js","sourceRoot":"","sources":["../src/shouldExternalizePackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAMxC;IACC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,wBAAwB,EAAE,GAAG,MAAM,CAAC;IAE9E,OAAO,CAAC,CACN,CAAC,wBAAwB,IAAI,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC3E,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,CAAC;QACd,6FAA6F;QAC7F,CAAC,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,kDAAkD;AAClD,SAAS,oBAAoB,CAAC,EAAU,EAAE,QAA8B,EAAE,SAAkC;IAC1G,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AACxG,CAAC","sourcesContent":["import path from 'path';\nimport { isBuiltin } from 'module';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Determines if a package should be externalized from the bundle.\n * Don't externalize inlined packages, node builtins, absolute paths, or relative paths.\n */\nexport function shouldExternalizePackage(params: {\n id: string;\n inlined?: string[];\n external?: string[];\n polyfills?: Set<string>;\n shouldInlineNodeBuiltins: boolean;\n}): boolean {\n const { id, inlined, external, polyfills, shouldInlineNodeBuiltins } = params;\n\n return !(\n (shouldInlineNodeBuiltins && isInlinedNodeBuiltin(id, external, polyfills)) ||\n path.isAbsolute(id) ||\n isRelative(id) ||\n // The length check ensures that parseImportString is only called when there are inlined deps\n (inlined?.length && inlined.includes(parseImportString(id).packageName))\n );\n}\n\n// We should inline node builtins that are handled by the nodePolyfills plugin.\n// Except if the dependency is listed as external.\nfunction isInlinedNodeBuiltin(id: string, external: string[] | undefined, polyfills: Set<string> | undefined) {\n return (isBuiltin(id) || polyfills?.has(id)) && !external?.find((ex) => id.startsWith(ex));\n}\n\nfunction isRelative(id: string) {\n return id.startsWith('/') || id.startsWith('./') || id.startsWith('../') || id === '.' || id === '..';\n}\n"]}
1
+ {"version":3,"file":"shouldExternalizePackage.js","sourceRoot":"","sources":["../src/shouldExternalizePackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAMxC;IACC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,wBAAwB,EAAE,GAAG,MAAM,CAAC;IAE9E,OAAO,CAAC,CACN,CAAC,wBAAwB,IAAI,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC3E,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,CAAC;QACd,6FAA6F;QAC7F,CAAC,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,kDAAkD;AAClD,SAAS,oBAAoB,CAAC,EAAU,EAAE,QAA8B,EAAE,SAAkC;IAC1G,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AACxG,CAAC","sourcesContent":["import path from 'path';\nimport { isBuiltin } from 'module';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * @deprecated Use the one from `@ms-cloudpack/bundler-utilities` instead.\n * (can be deleted in version 11 or later)\n */\nexport function shouldExternalizePackage(params: {\n id: string;\n inlined?: string[];\n external?: string[];\n polyfills?: Set<string>;\n shouldInlineNodeBuiltins: boolean;\n}): boolean {\n const { id, inlined, external, polyfills, shouldInlineNodeBuiltins } = params;\n\n return !(\n (shouldInlineNodeBuiltins && isInlinedNodeBuiltin(id, external, polyfills)) ||\n path.isAbsolute(id) ||\n isRelative(id) ||\n // The length check ensures that parseImportString is only called when there are inlined deps\n (inlined?.length && inlined.includes(parseImportString(id).packageName))\n );\n}\n\n// We should inline node builtins that are handled by the nodePolyfills plugin.\n// Except if the dependency is listed as external.\nfunction isInlinedNodeBuiltin(id: string, external: string[] | undefined, polyfills: Set<string> | undefined) {\n return (isBuiltin(id) || polyfills?.has(id)) && !external?.find((ex) => id.startsWith(ex));\n}\n\nfunction isRelative(id: string) {\n return id.startsWith('/') || id.startsWith('./') || id.startsWith('../') || id === '.' || id === '..';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "10.1.3",
3
+ "version": "10.2.1",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",