aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack-merge
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/webpack-merge
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/webpack-merge')
-rw-r--r--node_modules/webpack-merge/CHANGELOG.md15
-rw-r--r--node_modules/webpack-merge/README.md65
-rw-r--r--node_modules/webpack-merge/lib/join-arrays-smart.js98
-rw-r--r--node_modules/webpack-merge/package.json28
4 files changed, 177 insertions, 29 deletions
diff --git a/node_modules/webpack-merge/CHANGELOG.md b/node_modules/webpack-merge/CHANGELOG.md
index 3050cc3bb..b204cac9c 100644
--- a/node_modules/webpack-merge/CHANGELOG.md
+++ b/node_modules/webpack-merge/CHANGELOG.md
@@ -1,3 +1,18 @@
+4.1.4 / 2018-08-01
+==================
+
+ * Maintenance - Remove bitHound from the README as it closed down. #102
+
+4.1.3 / 2018-06-14
+==================
+
+ * Fix - Smart merge respects the existing loader order #79, #101
+
+4.1.2 / 2017-02-22
+==================
+
+ * Maintenance - Update lodash, #97, #98
+
4.1.1 / 2017-11-01
==================
diff --git a/node_modules/webpack-merge/README.md b/node_modules/webpack-merge/README.md
index af4fbb180..eca7703fc 100644
--- a/node_modules/webpack-merge/README.md
+++ b/node_modules/webpack-merge/README.md
@@ -1,4 +1,4 @@
-[![build status](https://secure.travis-ci.org/survivejs/webpack-merge.svg)](http://travis-ci.org/survivejs/webpack-merge) [![bitHound Score](https://www.bithound.io/github/survivejs/webpack-merge/badges/score.svg)](https://www.bithound.io/github/survivejs/webpack-merge) [![codecov](https://codecov.io/gh/survivejs/webpack-merge/branch/master/graph/badge.svg)](https://codecov.io/gh/survivejs/webpack-merge)
+[![build status](https://secure.travis-ci.org/survivejs/webpack-merge.svg)](http://travis-ci.org/survivejs/webpack-merge) [![codecov](https://codecov.io/gh/survivejs/webpack-merge/branch/master/graph/badge.svg)](https://codecov.io/gh/survivejs/webpack-merge)
# webpack-merge - Merge designed for Webpack
@@ -271,6 +271,69 @@ merge.smart({
}
```
+This also works in reverse - the existing order will be maintained if possible:
+
+```javascript
+merge.smart({
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'css-loader', options: { myOptions: true } },
+ { loader: 'style-loader' }
+ ]
+ }]
+}, {
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'style-loader', options: { someSetting: true } }
+ ]
+ }]
+});
+// will become
+{
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'css-loader', options: { myOptions: true } },
+ { loader: 'style-loader', options: { someSetting: true } }
+ ]
+ }]
+}
+```
+
+In the case of an order conflict, the second order wins:
+```javascript
+merge.smart({
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'css-loader' },
+ { loader: 'style-loader' }
+ ]
+ }]
+}, {
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'style-loader' },
+ { loader: 'css-loader' }
+ ]
+ }]
+});
+// will become
+{
+ loaders: [{
+ test: /\.css$/,
+ use: [
+ { loader: 'style-loader' }
+ { loader: 'css-loader' },
+ ]
+ }]
+}
+```
+
+
**Loader query strings `loaders: ['babel?plugins[]=object-assign']` will be overridden.**
```javascript
diff --git a/node_modules/webpack-merge/lib/join-arrays-smart.js b/node_modules/webpack-merge/lib/join-arrays-smart.js
index 74dda9047..468fb6fad 100644
--- a/node_modules/webpack-merge/lib/join-arrays-smart.js
+++ b/node_modules/webpack-merge/lib/join-arrays-smart.js
@@ -9,10 +9,6 @@ var _differenceWith2 = require('lodash/differenceWith');
var _differenceWith3 = _interopRequireDefault(_differenceWith2);
-var _unionWith2 = require('lodash/unionWith');
-
-var _unionWith3 = _interopRequireDefault(_unionWith2);
-
var _mergeWith2 = require('lodash/mergeWith');
var _mergeWith3 = _interopRequireDefault(_mergeWith2);
@@ -90,10 +86,7 @@ function uniteRules(rules, key, newRule, rule) {
rule[loadersKey] = newRule.use || newRule.loaders;
break;
default:
- rule[loadersKey] = (0, _unionWith3.default)(
- // Remove existing entries so that we can respect the order of the new
- // entries
- (0, _differenceWith3.default)(entries, newEntries, _isEqual3.default), newEntries, uniteEntries).map(unwrapEntry);
+ rule[loadersKey] = combineEntries(newEntries, entries).map(unwrapEntry);
}
}
@@ -124,7 +117,7 @@ function isSameValue(a, b) {
return (0, _isEqual3.default)(propA, propB);
}
-function uniteEntries(newEntry, entry) {
+function areEqualEntries(newEntry, entry) {
var loaderNameRe = /^([^?]+)/ig;
var _entry$loader$match = entry.loader.match(loaderNameRe),
@@ -135,13 +128,90 @@ function uniteEntries(newEntry, entry) {
_newEntry$loader$matc2 = _slicedToArray(_newEntry$loader$matc, 1),
newLoaderName = _newEntry$loader$matc2[0];
- if (loaderName !== newLoaderName) {
- return false;
+ return loaderName === newLoaderName;
+}
+
+function uniteEntries(newEntry, entry) {
+ if (areEqualEntries(newEntry, entry)) {
+ // Replace query values with newer ones
+ (0, _mergeWith3.default)(entry, newEntry);
+ return true;
}
+ return false;
+}
- // Replace query values with newer ones
- (0, _mergeWith3.default)(entry, newEntry);
- return true;
+/* Combines entries and newEntries, while respecting the order of loaders in each.
+
+Iterates through new entries. If the new entry also exists in existing entries,
+we'll put in all of the loaders from existing entries that come before it (in case
+those are pre-requisites). Any remaining existing entries are added at the end.
+
+Since webpack processes right-to-left, we're working backwards through the arrays
+*/
+function combineEntries(newEntries, existingEntries) {
+ var resultSet = [];
+
+ // We're iterating through newEntries, this keeps track of where we are in the existingEntries
+ var existingEntriesIteratorIndex = existingEntries.length - 1;
+
+ for (var i = newEntries.length - 1; i >= 0; i -= 1) {
+ var currentEntry = newEntries[i];
+ var indexInExistingEntries = findLastIndexUsingComparinator(existingEntries, currentEntry, areEqualEntries, existingEntriesIteratorIndex);
+ var hasEquivalentEntryInExistingEntries = indexInExistingEntries !== -1;
+
+ if (hasEquivalentEntryInExistingEntries) {
+ // If the same entry exists in existing entries, we should add all of the entries that
+ // come before to maintain order
+ for (var j = existingEntriesIteratorIndex; j > indexInExistingEntries; j -= 1) {
+ var existingEntry = existingEntries[j];
+
+ // If this entry also exists in new entries, we'll add as part of iterating through
+ // new entries so that if there's a conflict between existing entries and new entries,
+ // new entries order wins
+ var hasMatchingEntryInNewEntries = findLastIndexUsingComparinator(newEntries, existingEntry, areEqualEntries, i) !== -1;
+
+ if (!hasMatchingEntryInNewEntries) {
+ resultSet.unshift(existingEntry);
+ }
+ existingEntriesIteratorIndex -= 1;
+ }
+
+ uniteEntries(currentEntry, existingEntries[existingEntriesIteratorIndex]);
+ // uniteEntries mutates the second parameter to be a merged version, so that's what's pushed
+ resultSet.unshift(existingEntries[existingEntriesIteratorIndex]);
+
+ existingEntriesIteratorIndex -= 1;
+ } else {
+ var alreadyHasMatchingEntryInResultSet = findLastIndexUsingComparinator(resultSet, currentEntry, areEqualEntries) !== -1;
+
+ if (!alreadyHasMatchingEntryInResultSet) {
+ resultSet.unshift(currentEntry);
+ }
+ }
+ }
+
+ // Add remaining existing entries
+ for (existingEntriesIteratorIndex; existingEntriesIteratorIndex >= 0; existingEntriesIteratorIndex -= 1) {
+
+ var _existingEntry = existingEntries[existingEntriesIteratorIndex];
+ var _alreadyHasMatchingEntryInResultSet = findLastIndexUsingComparinator(resultSet, _existingEntry, areEqualEntries) !== -1;
+
+ if (!_alreadyHasMatchingEntryInResultSet) {
+ resultSet.unshift(_existingEntry);
+ }
+ }
+
+ return resultSet;
+}
+
+function findLastIndexUsingComparinator(entries, entryToFind, comparinator, startingIndex) {
+ startingIndex = startingIndex || entries.length - 1;
+ for (var i = startingIndex; i >= 0; i -= 1) {
+ if (areEqualEntries(entryToFind, entries[i])) {
+ return i;
+ }
+ }
+ return -1;
}
exports.uniteRules = uniteRules;
diff --git a/node_modules/webpack-merge/package.json b/node_modules/webpack-merge/package.json
index 2a6545e18..f57a1400e 100644
--- a/node_modules/webpack-merge/package.json
+++ b/node_modules/webpack-merge/package.json
@@ -2,7 +2,7 @@
"name": "webpack-merge",
"description": "Variant of merge that's useful for webpack configuration",
"author": "Juho Vepsalainen <bebraw@gmail.com>",
- "version": "4.1.1",
+ "version": "4.1.4",
"scripts": {
"build": "babel src -d lib",
"watch": "npm-watch",
@@ -16,23 +16,23 @@
"lib"
],
"dependencies": {
- "lodash": "^4.17.4"
+ "lodash": "^4.17.5"
},
"devDependencies": {
- "babel-cli": "^6.18.0",
- "babel-plugin-lodash": "^3.2.11",
- "babel-preset-es2015": "^6.18.0",
- "copy-webpack-plugin": "^4.0.1",
- "eslint": "^3.13.1",
- "eslint-config-airbnb": "^14.0.0",
- "eslint-plugin-import": "^2.2.0",
+ "babel-cli": "^6.26.0",
+ "babel-plugin-lodash": "^3.3.2",
+ "babel-preset-es2015": "^6.24.1",
+ "copy-webpack-plugin": "^4.4.1",
+ "eslint": "^3.19.0",
+ "eslint-config-airbnb": "^14.1.0",
+ "eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
- "eslint-plugin-react": "^6.9.0",
- "git-prepush-hook": "^1.0.1",
+ "eslint-plugin-react": "^6.10.3",
+ "git-prepush-hook": "^1.0.2",
"istanbul": "^0.4.5",
- "mocha": "^3.2.0",
- "npm-watch": "^0.1.7",
- "webpack": "^1.14.0"
+ "mocha": "^3.5.3",
+ "npm-watch": "^0.1.9",
+ "webpack": "^1.15.0"
},
"repository": {
"type": "git",