@ms-cloudpack/package-utilities 11.1.2 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exportsMap/createExportsMap.d.ts +3 -1
- package/lib/exportsMap/createExportsMap.d.ts.map +1 -1
- package/lib/exportsMap/createExportsMap.js +3 -1
- package/lib/exportsMap/createExportsMap.js.map +1 -1
- package/lib/findFileInPackage/findFileInPackage.js +3 -3
- package/lib/findFileInPackage/findFileInPackage.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/packageJson/getDependencies.d.ts +5 -2
- package/lib/packageJson/getDependencies.d.ts.map +1 -1
- package/lib/packageJson/getDependencies.js +5 -4
- package/lib/packageJson/getDependencies.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CloudpackConfig, PackageDefinitionsCache, PackageJsonExports } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
|
-
* Given a package path,
|
|
3
|
+
* Given a package path, return its exports if already set (this could be from either the original
|
|
4
|
+
* package.json or as generated by `createPackageSettingsTransform`), or otherwise generate an
|
|
5
|
+
* exports map based on other fields in the package definition.
|
|
4
6
|
*/
|
|
5
7
|
export declare function createExportsMap(options: {
|
|
6
8
|
packagePath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../../src/exportsMap/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AAIpC
|
|
1
|
+
{"version":3,"file":"createExportsMap.d.ts","sourceRoot":"","sources":["../../src/exportsMap/createExportsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AAIpC;;;;GAIG;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,CAqG7B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
2
2
|
import { addExportsMapEntry } from './addExportsMapEntry.js';
|
|
3
3
|
/**
|
|
4
|
-
* Given a package path,
|
|
4
|
+
* Given a package path, return its exports if already set (this could be from either the original
|
|
5
|
+
* package.json or as generated by `createPackageSettingsTransform`), or otherwise generate an
|
|
6
|
+
* exports map based on other fields in the package definition.
|
|
5
7
|
*/
|
|
6
8
|
export async function createExportsMap(options, context) {
|
|
7
9
|
const { packagePath } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExportsMap.js","sourceRoot":"","sources":["../../src/exportsMap/createExportsMap.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"createExportsMap.js","sourceRoot":"","sources":["../../src/exportsMap/createExportsMap.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAGC,EACD,OAAyF;IAEzF,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM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E;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 {\n CloudpackConfig,\n PackageDefinitionsCache,\n PackageJsonExports,\n GeneratedExports,\n} 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, return its exports if already set (this could be from either the original\n * package.json or as generated by `createPackageSettingsTransform`), or otherwise generate an\n * exports map based on other fields in the package definition.\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 // Use the GeneratedExports type internally because it matches up with the more constrained\n // format of the exports map we're creating here (and addExportsMapEntry requires this type).\n const exports: GeneratedExports = {};\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, environmentCondition: '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 isDefaultModule = normalizeRelativePath(module) === normalizeRelativePath(key);\n const isDefaultMain = normalizeRelativePath(main) === normalizeRelativePath(key);\n\n let importPaths: string[];\n if (isDefaultMain || isDefaultModule) {\n importPaths = ['.'];\n } else {\n importPaths = [key, 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 environmentCondition: 'browser',\n requestCondition: isDefaultModule || (isDefaultMain && type === 'module') ? 'import' : undefined,\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"]}
|
|
@@ -23,10 +23,10 @@ export async function findFileInPackage(options, context) {
|
|
|
23
23
|
let sourcePath;
|
|
24
24
|
const isInternal = !isExternalPackage(packagePath);
|
|
25
25
|
const pathsToConsider = [originalPath];
|
|
26
|
-
const
|
|
26
|
+
const originalDefinition = await context.packages.tryGet(packagePath, { disableTransforms: true });
|
|
27
27
|
// If the original package.json has an exports map, we should not use main and module as hints.
|
|
28
|
-
if (originalPath === '.' &&
|
|
29
|
-
const { main, module } =
|
|
28
|
+
if (originalPath === '.' && originalDefinition && !originalDefinition.exports) {
|
|
29
|
+
const { main, module } = originalDefinition;
|
|
30
30
|
if (main) {
|
|
31
31
|
pathsToConsider.unshift(main);
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../../src/findFileInPackage/findFileInPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,UAAU,EACV,wBAAwB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,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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sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { normalizeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport {\n intermediateToSourcePath,\n isExternalPackage,\n isFileSync,\n sourceToIntermediatePath,\n} from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { flattenExportsMap } from '../exportsMap/flattenExportsMap.js';\nimport { getCandidates } from './getCandidates.js';\nimport { getExportsMap } from '../exportsMap/getExportsMap.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 originalDefinition = 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 === '.' && originalDefinition && !originalDefinition.exports) {\n const { main, module } = originalDefinition;\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"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type { DiffResolveMapsChanges, DiffResolveMapsStats } from './resolveMap/
|
|
|
6
6
|
export { diffResolveMaps } from './resolveMap/diffResolveMaps.js';
|
|
7
7
|
export { ensureResolveMapEntry } from './resolveMap/ensureResolveMapEntry.js';
|
|
8
8
|
export { flattenExportsMap } from './exportsMap/flattenExportsMap.js';
|
|
9
|
-
export { createExportsMap } from './exportsMap/createExportsMap.js';
|
|
10
9
|
export { addExportsMapEntry, type AddExportsMapEntryOptions } from './exportsMap/addExportsMapEntry.js';
|
|
11
10
|
export { getExportsMap } from './exportsMap/getExportsMap.js';
|
|
12
11
|
export { getSourceEntry } from './exportsMap/getSourceEntry.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAGxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAGxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export { diffResolveMaps } from './resolveMap/diffResolveMaps.js';
|
|
|
8
8
|
export { ensureResolveMapEntry } from './resolveMap/ensureResolveMapEntry.js';
|
|
9
9
|
// ExportsMap parsing and creation
|
|
10
10
|
export { flattenExportsMap } from './exportsMap/flattenExportsMap.js';
|
|
11
|
-
export { createExportsMap } from './exportsMap/createExportsMap.js';
|
|
12
11
|
export { addExportsMapEntry } from './exportsMap/addExportsMapEntry.js';
|
|
13
12
|
export { getExportsMap } from './exportsMap/getExportsMap.js';
|
|
14
13
|
export { getSourceEntry } from './exportsMap/getSourceEntry.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src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AU,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,qFAAqF;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './packageDefinitions/PackageDefinitions.js';\nexport { MockPackageDefinitions } from './packageDefinitions/MockPackageDefinitions.js';\n\n// ResolveMaps\nexport { createResolveMap } from './resolveMap/createResolveMap.js';\nexport { findResolveMapEntry } from './resolveMap/findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './resolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './resolveMap/diffResolveMaps.js';\nexport { ensureResolveMapEntry } from './resolveMap/ensureResolveMapEntry.js';\n\n// ExportsMap parsing and creation\nexport { flattenExportsMap } from './exportsMap/flattenExportsMap.js';\nexport { addExportsMapEntry, type AddExportsMapEntryOptions } from './exportsMap/addExportsMapEntry.js';\nexport { getExportsMap } from './exportsMap/getExportsMap.js';\nexport { getSourceEntry } from './exportsMap/getSourceEntry.js';\n\n// Other package utilities\nexport { detectModuleType } from './detectModuleType.js';\nexport {\n findFileInPackage,\n type FindFileInPackageOptions,\n type FindFileInPackageResult,\n} from './findFileInPackage/findFileInPackage.js';\nexport { getVersion, getDisplayVersion } from './packageJson/getVersion.js';\nexport { getDependencies } from './packageJson/getDependencies.js';\nexport { getUnusedDependencies } from './packageJson/getUnusedDependencies.js';\n\n// Object utilities which could be moved to a separate package if we add more of them\nexport { mergeArrayDefaults } from './object/mergeArrayDefaults.js';\nexport { mergeObjects } from './object/mergeObjects.js';\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
3
|
* Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack
|
|
4
|
-
* (currently prod and peer).
|
|
4
|
+
* (currently prod and peer). Or if `options.includeAll` is true, also include dev and optional.
|
|
5
5
|
*/
|
|
6
|
-
export declare function getDependencies(definition: PackageJson
|
|
6
|
+
export declare function getDependencies(definition: PackageJson, options?: {
|
|
7
|
+
/** If true, also include dev and optional dependencies. */
|
|
8
|
+
includeAll?: boolean;
|
|
9
|
+
}): PackageJsonDependencies;
|
|
7
10
|
//# sourceMappingURL=getDependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDependencies.d.ts","sourceRoot":"","sources":["../../src/packageJson/getDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEvF;;;GAGG;AACH,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"getDependencies.d.ts","sourceRoot":"","sources":["../../src/packageJson/getDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEvF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,WAAW,EACvB,OAAO,CAAC,EAAE;IACR,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA,uBAAuB,CASzB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack
|
|
3
|
-
* (currently prod and peer).
|
|
3
|
+
* (currently prod and peer). Or if `options.includeAll` is true, also include dev and optional.
|
|
4
4
|
*/
|
|
5
|
-
export function getDependencies(definition) {
|
|
6
|
-
|
|
7
|
-
// especially in case it needs to be changed somehow later.
|
|
5
|
+
export function getDependencies(definition, options) {
|
|
6
|
+
const { includeAll } = options || {};
|
|
8
7
|
return {
|
|
8
|
+
...(includeAll ? definition.devDependencies : {}),
|
|
9
|
+
...(includeAll ? definition.optionalDependencies : {}),
|
|
9
10
|
...definition.dependencies,
|
|
10
11
|
...definition.peerDependencies,
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDependencies.js","sourceRoot":"","sources":["../../src/packageJson/getDependencies.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"getDependencies.js","sourceRoot":"","sources":["../../src/packageJson/getDependencies.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAuB,EACvB,OAGC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAErC,OAAO;QACL,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,UAAU,CAAC,YAAY;QAC1B,GAAG,UAAU,CAAC,gBAAgB;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson, PackageJsonDependencies } from '@ms-cloudpack/common-types';\n\n/**\n * Get the dependencies that are potentially used at runtime and considered for bundling by cloudpack\n * (currently prod and peer). Or if `options.includeAll` is true, also include dev and optional.\n */\nexport function getDependencies(\n definition: PackageJson,\n options?: {\n /** If true, also include dev and optional dependencies. */\n includeAll?: boolean;\n },\n): PackageJsonDependencies {\n const { includeAll } = options || {};\n\n return {\n ...(includeAll ? definition.devDependencies : {}),\n ...(includeAll ? definition.optionalDependencies : {}),\n ...definition.dependencies,\n ...definition.peerDependencies,\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.24.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.24.3",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
19
19
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
20
|
-
"@ms-cloudpack/path-utilities": "^2.8.
|
|
20
|
+
"@ms-cloudpack/path-utilities": "^2.8.4",
|
|
21
21
|
"@ms-cloudpack/task-reporter": "^0.14.8",
|
|
22
22
|
"acorn": "^8.11.2",
|
|
23
23
|
"acorn-walk": "^8.2.1",
|