@untool/core
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -6,2 +6,14 @@ # Change Log | ||
## [2.0.1](https://github.com/untool/untool/compare/v2.0.0...v2.0.1) (2020-01-20) | ||
### Bug Fixes | ||
* **core:** align mixin load order with config overrides ([be90427](https://github.com/untool/untool/commit/be9042754c51f5a708a01dfbd59940757fa5ae0c)) | ||
* **core:** set mixin deduplication order based on preset config ([2191ac1](https://github.com/untool/untool/commit/2191ac19f77f593e25e0198cc8d0d123daa8dd7d)), closes [#542](https://github.com/untool/untool/issues/542) | ||
# [2.0.0](https://github.com/untool/untool/compare/v2.0.0-beta.1...v2.0.0) (2020-01-06) | ||
@@ -8,0 +20,0 @@ |
@@ -13,3 +13,8 @@ 'use strict'; | ||
const { validate } = require('./validator'); | ||
const { environmentalize, placeholdify, merge } = require('./utils'); | ||
const { | ||
environmentalize, | ||
placeholdify, | ||
merge: mergeFactory, | ||
getMixinSortOrder, | ||
} = require('./utils'); | ||
@@ -43,2 +48,3 @@ exports.getConfig = ({ untoolNamespace = 'untool', ...overrides } = {}) => { | ||
const merge = mergeFactory(getMixinSortOrder(settings, overrides)); | ||
const raw = merge(defaults, settings, overrides); | ||
@@ -45,0 +51,0 @@ const { mixins, mixinTypes, configSchema, ...clean } = raw; |
@@ -8,3 +8,3 @@ 'use strict'; | ||
const { merge } = require('./utils'); | ||
const { merge: mergeFactory, getMixinSortOrder } = require('./utils'); | ||
const { resolve, resolvePreset, isResolveError } = require('./resolver'); | ||
@@ -38,3 +38,3 @@ | ||
} | ||
loadPresets(context, presets = []) { | ||
loadPresets(context, merge, presets = []) { | ||
return presets.reduce((result, preset) => { | ||
@@ -48,3 +48,7 @@ const { config, filepath } = this.loadPreset(context, preset); | ||
} | ||
return merge(result, this.loadPresets(directory, config.presets), config); | ||
return merge( | ||
result, | ||
this.loadPresets(directory, merge, config.presets), | ||
config | ||
); | ||
}, {}); | ||
@@ -81,3 +85,4 @@ } | ||
const settings = loader.loadSettings(rootDir); | ||
const presets = loader.loadPresets(rootDir, settings.presets); | ||
const merge = mergeFactory(getMixinSortOrder(settings)); | ||
const presets = loader.loadPresets(rootDir, merge, settings.presets); | ||
@@ -84,0 +89,0 @@ // eslint-disable-next-line no-unused-vars |
@@ -36,9 +36,26 @@ 'use strict'; | ||
exports.merge = (...args) => | ||
mergeWith({}, ...args, (objValue, srcValue, key) => { | ||
exports.getMixinSortOrder = (...args) => | ||
args.reduce((enableLegacyMixinSortOrder, config) => { | ||
if ('enableLegacyMixinSortOrder' in config) { | ||
return config.enableLegacyMixinSortOrder; | ||
} | ||
return enableLegacyMixinSortOrder; | ||
}, false); | ||
exports.merge = (enableLegacyMixinSortOrder = false) => (...args) => { | ||
return mergeWith({}, ...args, (objValue, srcValue, key) => { | ||
if (Array.isArray(objValue)) { | ||
if ('mixins' === key) { | ||
return [...objValue, ...srcValue].filter( | ||
(curr, index, self) => self.indexOf(curr) === index | ||
); | ||
// #542: remove this in untool v3 if no potential side-effects have been | ||
// discovered | ||
if (enableLegacyMixinSortOrder) { | ||
return [...objValue, ...srcValue].filter( | ||
(curr, index, self) => self.indexOf(curr) === index | ||
); | ||
} | ||
return [ | ||
...objValue.filter((curr) => !srcValue.includes(curr)), | ||
...srcValue, | ||
]; | ||
} | ||
@@ -48,2 +65,3 @@ return srcValue; | ||
}); | ||
}; | ||
@@ -50,0 +68,0 @@ exports.placeholdify = (config) => { |
{ | ||
"name": "@untool/core", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "untool core", | ||
@@ -36,3 +36,3 @@ "repository": { | ||
}, | ||
"gitHead": "15be35ce680c060ecb4397b83260430ff56b176d" | ||
"gitHead": "1ed715ff3e102e39dd6869502389d4d0f48b0a1e" | ||
} |
@@ -71,2 +71,30 @@ # `@untool/core` | ||
**Note:** Have in mind that you must explicitly whitelist config properties, that hold an environment variable placeholder, otherwise the interpolation fails. | ||
```json | ||
{ | ||
"foo": { | ||
"bar": "[FOOBAR]" | ||
}, | ||
"browserWhitelist": { | ||
"foo.bar": true | ||
} | ||
} | ||
``` | ||
If you instead whitelist the whole nested object, that holds this property, `@untool/core` is currently not able to detect the placeholder. | ||
```json | ||
{ | ||
"foo": { | ||
"bar": "[FOOBAR]" | ||
}, | ||
"browserWhitelist": { | ||
"foo": true | ||
} | ||
} | ||
``` | ||
Besides that, whitelisting of nested objects as a whole is fine. Also this is considered a bug and will be fixed in one of the next minor releases. | ||
`@untool/core` looks for configuration data in a couple of places. It only uses the first config it finds, so make sure you do not have multiple configs lying around: | ||
@@ -73,0 +101,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
49052
614
224
1