@ms-cloudpack/config
Advanced tools
Comparing version 0.22.0 to 0.22.1
@@ -25,3 +25,5 @@ import { getPackageSettings } from './getPackageSettings.js'; | ||
if (definition.peerDependencies && !userPackageSettings?.excludedDependencies?.includes('$peerDependencies')) { | ||
newDefinition.peerDependencies = definition.peerDependencies; | ||
newDefinition.peerDependencies = !excludedDependencies?.length | ||
? definition.peerDependencies | ||
: Object.fromEntries(Object.entries(definition.peerDependencies).filter(([dep]) => !excludedDependencies.includes(dep))); | ||
} | ||
@@ -28,0 +30,0 @@ if (config.mode || Object.keys(settings).length > 0) { |
@@ -0,1 +1,2 @@ | ||
import { mergeObjects, mergeArrayDefaults } from '@ms-cloudpack/package-utilities'; | ||
const defaultInputPaths = ['src/**', '*.json', '!**/node_modules/**']; | ||
@@ -11,64 +12,27 @@ /** | ||
export function mergePackageSettings(settings) { | ||
const result = settings.reduce((acc, setting) => { | ||
const { exports } = setting; | ||
if (exports) { | ||
// If we don't have any exports yet, just set it. | ||
if (!acc.exports) { | ||
acc.exports = exports; | ||
} | ||
else { | ||
// If we have an exports but it's not an array, make it an array. | ||
if (!Array.isArray(acc.exports)) { | ||
acc.exports = [acc.exports]; | ||
const result = mergeObjects(settings, { | ||
overwriteKeys: ['ignoreMissingExports', 'bundlerOptions'], | ||
customMerge: { | ||
exports: (acc, curr) => { | ||
// Use the current setting if it's explicitly null or was previously not set. | ||
if (!acc || curr === null) { | ||
// Make a copy if it's an array, so later additions don't affect the original. | ||
return Array.isArray(curr) ? [...curr] : curr; | ||
} | ||
// If the accumulated exports is an array, expand the array to `push`; else push the single item. | ||
if (Array.isArray(exports)) { | ||
acc.exports.push(...exports); | ||
if (curr) { | ||
// If we have previous exports but it's not an array, make it an array. | ||
acc = acc ? (Array.isArray(acc) ? acc : [acc]) : []; | ||
// Add the new exports. | ||
acc.push(...(Array.isArray(curr) ? curr : [curr])); | ||
} | ||
else { | ||
acc.exports.push(exports); | ||
} | ||
} | ||
} | ||
if (setting.includedDependencies) { | ||
acc.includedDependencies = [...(acc.includedDependencies || []), ...setting.includedDependencies]; | ||
} | ||
if (setting.excludedDependencies) { | ||
acc.excludedDependencies = [...(acc.excludedDependencies || []), ...setting.excludedDependencies]; | ||
} | ||
if (setting.inlinedDependencies) { | ||
acc.inlinedDependencies = [...(acc.inlinedDependencies || []), ...setting.inlinedDependencies]; | ||
} | ||
if (setting.bundlerType) { | ||
acc.bundlerType = setting.bundlerType; | ||
} | ||
if (setting.bundlerOptions) { | ||
acc.bundlerOptions = setting.bundlerOptions; | ||
} | ||
if (setting.inputPaths) { | ||
const defaultInputPathsIndex = setting.inputPaths.indexOf('...'); | ||
if (defaultInputPathsIndex > -1) { | ||
setting.inputPaths.splice(defaultInputPathsIndex, 1, ...defaultInputPaths); | ||
} | ||
acc.inputPaths = [...(acc.inputPaths || []), ...setting.inputPaths]; | ||
} | ||
if (setting.ignoreMissingExports !== undefined) { | ||
acc.ignoreMissingExports = setting.ignoreMissingExports; | ||
} | ||
if (setting.dynamicImports) { | ||
acc.dynamicImports = [...(acc.dynamicImports || []), ...setting.dynamicImports]; | ||
} | ||
if (setting.ignoredBundlerWarnings) { | ||
acc.ignoredBundlerWarnings = [...(acc.ignoredBundlerWarnings || []), ...setting.ignoredBundlerWarnings]; | ||
} | ||
if (setting.link !== undefined) { | ||
acc.link ??= {}; | ||
if (setting.link.duplicatedDependencyBehavior !== undefined) { | ||
acc.link.duplicatedDependencyBehavior = setting.link.duplicatedDependencyBehavior; | ||
} | ||
} | ||
return acc; | ||
}, {}); | ||
return acc; | ||
}, | ||
inputPaths: (acc = [], curr = []) => { | ||
return [...acc, ...mergeArrayDefaults(curr, defaultInputPaths)]; | ||
}, | ||
}, | ||
}); | ||
delete result.match; | ||
return result; | ||
} | ||
//# sourceMappingURL=mergePackageSettings.js.map |
@@ -1,2 +0,2 @@ | ||
import { recursive as recursiveMerge } from 'merge'; | ||
import { mergeObjects } from '@ms-cloudpack/package-utilities'; | ||
/** | ||
@@ -7,9 +7,10 @@ * Merge the configs. Later parent configs override earlier ones. | ||
const configs = [...params.parentConfigs, params.AppConfig]; | ||
// NOTE: This must merge into an empty object to avoid modifying the originals | ||
const result = recursiveMerge({}, ...configs); | ||
const result = mergeObjects(configs, { arrayMerge: 'overwrite' }); | ||
// Remove the extends property from the result | ||
delete result.extends; | ||
// Remove the default-merged package settings (fixed below) | ||
delete result.packageSettings; | ||
// Concatenate the package settings. User config comes first here since order can matter | ||
// in some cases (and the user config should override the parent). | ||
const packageSettings = [...configs].reverse().flatMap((config) => config.packageSettings ?? []); | ||
const packageSettings = configs.reverse().flatMap((config) => config.packageSettings ?? []); | ||
if (packageSettings.length) { | ||
@@ -16,0 +17,0 @@ result.packageSettings = packageSettings; |
{ | ||
"name": "@ms-cloudpack/config", | ||
"version": "0.22.0", | ||
"version": "0.22.1", | ||
"description": "Configuration handling for cloudpack.", | ||
@@ -19,5 +19,4 @@ "license": "MIT", | ||
"@ms-cloudpack/json-utilities": "^0.1.4", | ||
"@ms-cloudpack/package-utilities": "^7.7.1", | ||
"@ms-cloudpack/package-utilities": "^7.8.0", | ||
"import-meta-resolve": "^4.0.0", | ||
"merge": "^2.1.1", | ||
"semver": "^7.6.0" | ||
@@ -24,0 +23,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
87256
708
- Removedmerge@^2.1.1
- Removedmerge@2.1.1(transitive)