From de98e0b232509d5f40c135d540a70e415272ff85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 May 2017 15:35:00 +0200 Subject: node_modules --- node_modules/webpack-merge/CHANGELOG.md | 324 ++++++++++++++++++ node_modules/webpack-merge/LICENSE | 20 ++ node_modules/webpack-merge/README.md | 363 +++++++++++++++++++++ node_modules/webpack-merge/lib/index.js | 157 +++++++++ .../webpack-merge/lib/join-arrays-smart.js | 148 +++++++++ node_modules/webpack-merge/lib/join-arrays.js | 67 ++++ node_modules/webpack-merge/lib/unique.js | 27 ++ node_modules/webpack-merge/lib/unite-rules.js | 114 +++++++ node_modules/webpack-merge/package.json | 74 +++++ 9 files changed, 1294 insertions(+) create mode 100644 node_modules/webpack-merge/CHANGELOG.md create mode 100644 node_modules/webpack-merge/LICENSE create mode 100644 node_modules/webpack-merge/README.md create mode 100644 node_modules/webpack-merge/lib/index.js create mode 100644 node_modules/webpack-merge/lib/join-arrays-smart.js create mode 100644 node_modules/webpack-merge/lib/join-arrays.js create mode 100644 node_modules/webpack-merge/lib/unique.js create mode 100644 node_modules/webpack-merge/lib/unite-rules.js create mode 100644 node_modules/webpack-merge/package.json (limited to 'node_modules/webpack-merge') diff --git a/node_modules/webpack-merge/CHANGELOG.md b/node_modules/webpack-merge/CHANGELOG.md new file mode 100644 index 000000000..2f9060f62 --- /dev/null +++ b/node_modules/webpack-merge/CHANGELOG.md @@ -0,0 +1,324 @@ +4.1.0 / 2017-03-16 +================== + + * Feature - `merge.multiple` to allow working with webpack multi-compiler mode. It accepts multiple objects and returns an array you can push to webpack. #74 + +4.0.0 / 2017-03-06 +================== + + * Breaking feature - `merge.smart` allows re-ordering loaders like below. #70 + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loaders: ['babel'] + }] +}, { + loaders: [{ + test: /\.js$/, + loaders: ['react-hot', 'babel'] + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + // order of second argument is respected + loaders: ['react-hot', 'babel'] + }] +} +``` + +3.0.0 / 2017-02-19 +================== + + * Breaking fix - `merge.smart` should not merge a child missing `include`/`exclude` to a parent that has either. This is safer and more predictable behavior than the old one. #69 + +2.6.1 / 2017-01-29 +================== + + * Bug fix - `merge.smart` should not merge rules that have differing `enforce` fields. #65 + +2.6.0 / 2017-01-27 +================== + + * Bug fix - Support `replace` mode for `merge.smartStrategy`. #63 + +2.5.0 / 2017-01-26 +================== + + * Bug fix - Make sure `merge.smartStrategy` works with higher level nesting like `'module.rules.use': 'prepend'`. #64 + +2.4.0 / 2017-01-12 +================== + + * Feature - Add `merge.unique` helper that plugs into `customizeArray`. This allows you to force only one plugin of a type to the end result. #58 + +2.3.1 / 2017-01-06 +================== + + * Bug fix - Clear up `CopyWebpackPlugin` handling. #56 + +2.3.0 / 2017-01-06 +================== + + * Refactor - Depend only on `lodash` instead of individual packages as latter has been discontinued. #52 + +2.2.0 / 2017-01-05 +================== + + * Bug fix - Drop `merge.smartStrategy(rules, plugins)` as that caused other issues (prototype copying for complex cases). That needs a better approach. #55 + +2.1.1 / 2017-01-05 +================== + + * Bug fix - Avoid recursion at `merge.smart`. #53 + +2.1.0 / 2017-01-05 +================== + + * Feature - Allow `merge.smartStrategy` to merge plugin contents. API: `merge.smartStrategy(rules, plugins)`. #44. Example: + +```javascript +const output = merge.smartStrategy( + { + entry: 'prepend', // or 'replace' + 'module.loaders': 'prepend' + }, + ['LoaderOptionsPlugin'] +)(object1, object2, object3, ...); +``` + +2.0.0 / 2016-12-22 +================== + + * Breaking - Disallow overriding configuration with empty arrays/objects (#48). If you want to override, use `merge.strategy`. Example: + +```javascript +const a = { + entry: ['foo'] +}; +const b = { + entry: [] +}; + +merge(a, b); // Yields a result, not b like before. +``` + +1.1.2 / 2016-12-18 +================== + + * Bug fix - `merge({ entry: {} })` should return the same result as input instead of a function. + +1.1.1 / 2016-12-11 +================== + + * Bug fix - Support previously undocumented, yet used, `merge([])` format. This works with all available functions. #46 + +1.1.0 / 2016-12-09 +================== + + * Feature - Allow `merge` behavior to be customized with overrides. Example: + +```javascript +var output = merge({ + customizeArray(a, b, key) { return [...a, ...b]; }, + customizeObject(a, b, key) { return mergeWith(a, b); } +})(object1, object2, object3, ...); +``` + +This allows you to guarantee array uniqueness and so on. + +1.0.2 / 2016-11-29 +================== + + * Bug fix - `merge` should not mutate inputs with mismatched keys. + +1.0.0 / 2016-11-28 +================== + + * Feature: Support merging Webpack 2 Rule.use. #38 + * Bug fix - Don't concat loaders if the first matching entry's include/exclude doesn't match. #39 + +0.20.0 / 2016-11-27 +=================== + + * Feature: Add support for merging functions. This feature has been designed `postcss` in mind. It executes the functions, picks their results, and packs them again. + +0.19.0 / 2016-11-26 +=================== + + * Feature: Add support for 'replace' option at `merge.strategy`. It literally replaces the old field value with the newer one. #40 + +0.18.0 / 2016-11-24 +=================== + + * Feature: Add support for recursive definitions at `merge.strategy`. Example: + +```javascript +var output = merge.strategy({ + entry: 'prepend', + 'module.loaders': 'prepend' +})(object1, object2, object3, ...); +``` + + * Feature: Add `merge.smartStrategy`. This combines the ideas of `merge.smart` and `merge.strategy` into one. Example: + +```javascript +var output = merge.smartStrategy({ + entry: 'prepend', + 'module.loaders': 'prepend' +})(object1, object2, object3, ...); +``` + +0.17.0 / 2016-11-16 +=================== + + * Feature: Add support for `merge.strategy`. Now you can customize merging behavior per root level configuration field. Example: `merge.strategy({ entry: 'prepend' })(object1, object2, object3, ...);`. #17 + +0.16.0 / 2016-11-14 +=================== + + * Feature: Add support for webpack 2 at `merge.smart`. It should pick up `module.rules` as you might expect now. #35 + +0.15.0 / 2016-10-18 +=================== + + * Breaking: Rework `merge.smart` so that it **appends** loaders instead of **prepending** them. This is the logical thing to do as it allows you to specify behavior better as you `merge`. #32 + +0.14.1 / 2016-07-25 +=================== + + * Docs: Improve package description. #23. + * Bug fix - Let `merge.smart` merge loaders based on their full name instead of first letter. Thanks to @choffmeister. #26. + +0.14.0 / 2016-06-05 +=================== + + * Feature: Allow `merge.smart` to merge `loaders` if `exclude` is the same. Thanks to @mshwery. #21. + +0.13.0 / 2016-05-24 +=================== + + * Bug fix: Allow `merge.smart` to merge configuration if `include` is defined. Thanks to @blackrabbit99. #20. + +0.12.0 / 2016-04-19 +=================== + + * Feature: Support `include/exclude` at `merge.smart` for `loader` definition too. Thanks to @Whoaa512. #16. + +0.11.0 / 2016-04-18 +=================== + + * Feature: Support `include/exclude` at `merge.smart` when its set only in a parent. #15. + +0.10.0 / 2016-04-10 +=================== + + * Feature: Support `include/exclude` at `merge.smart`. Thanks to @siready. #14. + +0.9.0 / 2016-04-08 +================== + + * Feature: Allow existing objects/arrays to be emptied with an empty object/array later in merge. This overriding behavior is useful for example emptying your `entry` configuration. + +0.8.4 / 2016-03-17 +================== + + * Bug fix: *webpack-merge* should not mutate inputs. #12 + +0.8.3 / 2016-03-02 +================== + + * Bug fix: Drop `files` field from *package.json* as it wasn't including the dist correctly. + +0.8.0 / 2016-03-02 +================== + + * Breaking: Change merging behavior so that only loaders get prepended. The rest follow appending logic. This makes `entry` array merging behavior logical. Prepend makes sense only for loaders after all. #10 + +0.7.3 / 2016-01-11 +================== + + * Bug fix: Do not error when there are no matching loaders. Thanks @GreenGremlin! + +0.7.2 / 2016-01-08 +================== + + * Regenerate tarball. The problem was that there were some old dependencies included. Closes #7. + +0.7.1 / 2016-01-03 +================== + + * Improve performance by defaulting to `concat` and by dropping a redundant check. Thanks @davegomez! + +0.7.0 / 2015-12-31 +================== + + * Bug fix: Arrays get merged within nested structures correctly now. Array items are prepended (reverse order compared to earlier). This is related to the change made in *0.6.0*. Incidentally this change affects normal merge as well. + * Smart merge: If a loader contains either `include` or `exclude`, it will generate separate entries instead of merging. Without this the configuration might change in an unpredictable manner. + +0.6.0 / 2015-12-30 +================== + + * Support `preLoaders` and `postLoaders`. Previously only `loaders` were supported. + * Breaking: Change smart merging behavior for `loaders` field so that it prepends loaders instead of appending them. The benefit of this is that now it's possible to specialize loader setup in a predictable manner. For example you can have a linter set up at the root and expect it to become evaluated first always. + +0.5.1 / 2015-12-26 +================== + + * Fix `merge` object/array case (missing `bind`). The behavior should be correct now. + +0.5.0 / 2015-12-26 +================== + + * Breaking: Push smart merging behind `merge.smart`. Now `merge` behaves exactly as in *0.3.0* series. + +0.4.0 / 2015-12-23 +================== + + * Dropped changelog generator. It's better to write these by hand. + * Breaking: Added smart merging (@GreenGremlin) + +0.3.2 / 2015-11-23 +================== + + * Tweaked changelog generator process. + +0.3.1 / 2015-11-23 +================== + + * Added changelog generator. + +0.3.0 / 2015-11-13 +================== + + * Improved formatting + * Allowed an arbitrary amount of objects to be merged + +0.2.0 / 2015-08-30 +================== + + * Only require lodash modules used by the package (@montogeek) + * Removed lodash.isarray dependency, use Array.isArray standard object + +0.1.3 / 2015-08-10 +================== + + * Improved README example + +0.1.2 / 2015-07-01 +================== + + * Simplified example + +0.1.1 / 2015-06-26 +================== + + * Fixed travis link + +0.1.0 / 2015-06-26 +================== + + * Initial implementation diff --git a/node_modules/webpack-merge/LICENSE b/node_modules/webpack-merge/LICENSE new file mode 100644 index 000000000..5eaceffb3 --- /dev/null +++ b/node_modules/webpack-merge/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2015 Juho Vepsalainen + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/webpack-merge/README.md b/node_modules/webpack-merge/README.md new file mode 100644 index 000000000..4aaa7da1f --- /dev/null +++ b/node_modules/webpack-merge/README.md @@ -0,0 +1,363 @@ +[![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) + +# webpack-merge - Merge designed for Webpack + +**webpack-merge** provides a `merge` function that concatenates arrays and merges objects creating a new object. If functions are encountered, it will execute them, run the results through the algorithm, and then wrap the returned values within a function again. + +This behavior is particularly useful in configuring webpack although it has uses beyond it. Whenever you need to merge configuration objects, **webpack-merge** can come in handy. + +There's also a webpack specific merge variant known as `merge.smart` that's able to take webpack specifics into account (i.e., it can flatten loader definitions). + +## Standard Merging + +### **`merge(...configuration | [...configuration])`** + +`merge` is the core, and the most important idea, of the API. Often this is all you need unless you want further customization. + +```javascript +// Default API +var output = merge(object1, object2, object3, ...); + +// You can pass an array of objects directly. +// This works with all available functions. +var output = merge([object1, object2, object3]); +``` + +### **`merge({ customizeArray, customizeObject })(...configuration | [...configuration])`** + +`merge` behavior can be customized per field through a curried customization API. + +```javascript +// Customizing array/object behavior +var output = merge( + { + customizeArray(a, b, key) { + if (key === 'extensions') { + return _.uniq([...a, ...b]); + } + + // Fall back to default merging + return undefined; + }, + customizeObject(a, b, key) { + if (key === 'module') { + // Custom merging + return _.merge({}, a, b); + } + + // Fall back to default merging + return undefined; + } + } +)(object1, object2, object3, ...); +``` + +### **`merge.unique(, , field => field)`** + +```javascript +const output = merge({ + customizeArray: merge.unique( + 'plugins', + ['HotModuleReplacementPlugin'], + plugin => plugin.constructor && plugin.constructor.name + ) +})({ + plugins: [ + new webpack.HotModuleReplacementPlugin() + ] +}, { + plugins: [ + new webpack.HotModuleReplacementPlugin() + ] +}); + +// Output contains only single HotModuleReplacementPlugin now. +``` + +## Merging with Strategies + +### **`merge.strategy({ : '''})(...configuration | [...configuration])`** + +Given you may want to configure merging behavior per field, there's a strategy variant: + +```javascript +// Merging with a specific merge strategy +var output = merge.strategy( + { + entry: 'prepend', // or 'replace', defaults to 'append' + 'module.loaders': 'prepend' + } +)(object1, object2, object3, ...); +``` + +### **`merge.smartStrategy({ : '''})(...configuration | [...configuration])`** + +The same idea works with smart merging too (described below in greater detail). + +```javascript +var output = merge.smartStrategy( + { + entry: 'prepend', // or 'replace' + 'module.loaders': 'prepend' + } +)(object1, object2, object3, ...); +``` + +## Smart Merging + +### **`merge.smart(...configuration | [...configuration])`** + +*webpack-merge* tries to be smart about merging loaders when `merge.smart` is used. Loaders with matching tests will be merged into a single loader value. + +Note that the logic picks up webpack 2 `rules` kind of syntax as well. The examples below have been written in webpack 1 syntax. + +**package.json** + +```json5 +{ + "scripts": { + "start": "webpack-dev-server", + "build": "webpack" + }, + // ... +} +``` + +**webpack.config.js** + +```javascript +var path = require('path'); +var merge = require('webpack-merge'); + +var TARGET = process.env.npm_lifecycle_event; + +var common = { + entry: path.join(__dirname, 'app'), + ... + module: { + loaders: [ + { + test: /\.css$/, + loaders: ['style', 'css'], + }, + ], + }, +}; + +if(TARGET === 'start') { + module.exports = merge(common, { + module: { + // loaders will get concatenated! + loaders: [ + { + test: /\.jsx?$/, + loader: 'babel?stage=1', + include: path.join(ROOT_PATH, 'app'), + }, + ], + }, + ... + }); +} + +if(TARGET === 'build') { + module.exports = merge(common, { + ... + }); +} + +... +``` + +**Loader string values `loader: 'babel'` override each other.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loader: 'babel' + }] +}, { + loaders: [{ + test: /\.js$/, + loader: 'coffee' + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + loader: 'coffee' + }] +} +``` + +**Loader array values `loaders: ['babel']` will be merged, without duplication.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loaders: ['babel'] + }] +}, { + loaders: [{ + test: /\.js$/, + loaders: ['coffee'] + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + // appended because Webpack evaluated these from right to left + // this way you can specialize behavior and build the loader chain + loaders: ['babel', 'coffee'] + }] +} +``` + +**Loader array values `loaders: ['babel']` can be reordered by including +original loaders.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loaders: ['babel'] + }] +}, { + loaders: [{ + test: /\.js$/, + loaders: ['react-hot', 'babel'] + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + // order of second argument is respected + loaders: ['react-hot', 'babel'] + }] +} +``` + +**Loader query strings `loaders: ['babel?plugins[]=object-assign']` will be overridden.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loaders: ['babel?plugins[]=object-assign'] + }] +}, { + loaders: [{ + test: /\.js$/, + loaders: ['babel', 'coffee'] + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + loaders: ['babel', 'coffee'] + }] +} +``` + +**Loader arrays in source values will have loader strings merged into them.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loader: 'babel' + }] +}, { + loaders: [{ + test: /\.js$/, + loaders: ['coffee'] + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + // appended because Webpack evaluated these from right to left! + loaders: ['babel', 'coffee'] + }] +} +``` + +**Loader strings in source values will always override.** + +```javascript +merge.smart({ + loaders: [{ + test: /\.js$/, + loaders: ['babel'] + }] +}, { + loaders: [{ + test: /\.js$/, + loader: 'coffee' + }] +}); +// will become +{ + loaders: [{ + test: /\.js$/, + loader: 'coffee' + }] +} +``` + +## Multiple Merging + +### **`merge.multiple(...configuration | [...configuration])`** + +Sometimes you may need to support multiple targets, *webpack-merge* will accept an object where each key represents the target configuration. The output becomes an *array* of configurations where matching keys are merged and non-matching keys are added. + +```javascript +var path = require('path'); +var baseConfig = { + server: { + target: 'node', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'lib.node.js' + } + }, + client: { + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'lib.js' + } + } + }; + +// specialized configuration +var production = { + client: { + output: { + path: path.resolve(__dirname, 'dist'), + filename: '[name].[hash].js' + } + } + } + +module.exports = merge.multiple(baseConfig, production) +``` + +> Check out [SurviveJS - Webpack and React](http://survivejs.com/) to dig deeper into the topic. + +## Development + +1. `npm i` +2. `npm run watch` + +Before contributing, please open an issue where to discuss. + +## License + +*webpack-merge* is available under MIT. See LICENSE for more details. diff --git a/node_modules/webpack-merge/lib/index.js b/node_modules/webpack-merge/lib/index.js new file mode 100644 index 000000000..bd7298897 --- /dev/null +++ b/node_modules/webpack-merge/lib/index.js @@ -0,0 +1,157 @@ +'use strict'; + +var _values2 = require('lodash/values'); + +var _values3 = _interopRequireDefault(_values2); + +var _unionWith2 = require('lodash/unionWith'); + +var _unionWith3 = _interopRequireDefault(_unionWith2); + +var _mergeWith2 = require('lodash/mergeWith'); + +var _mergeWith3 = _interopRequireDefault(_mergeWith2); + +var _differenceWith2 = require('lodash/differenceWith'); + +var _differenceWith3 = _interopRequireDefault(_differenceWith2); + +var _joinArrays = require('./join-arrays'); + +var _joinArrays2 = _interopRequireDefault(_joinArrays); + +var _joinArraysSmart = require('./join-arrays-smart'); + +var _unique = require('./unique'); + +var _unique2 = _interopRequireDefault(_unique); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function merge() { + for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) { + sources[_key] = arguments[_key]; + } + + // This supports + // merge([] | ...) + // merge({ customizeArray: , customizeObject: })([] | ...) + // where fn = (a, b, key) + if (sources.length === 1) { + if (Array.isArray(sources[0])) { + return _mergeWith3.default.apply(undefined, [{}].concat(_toConsumableArray(sources[0]), [(0, _joinArrays2.default)(sources[0])])); + } + + if (sources[0].customizeArray || sources[0].customizeObject) { + return function () { + for (var _len2 = arguments.length, structures = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + structures[_key2] = arguments[_key2]; + } + + if (Array.isArray(structures[0])) { + return _mergeWith3.default.apply(undefined, [{}].concat(_toConsumableArray(structures[0]), [(0, _joinArrays2.default)(sources[0])])); + } + + return _mergeWith3.default.apply(undefined, [{}].concat(structures, [(0, _joinArrays2.default)(sources[0])])); + }; + } + + return sources[0]; + } + + return _mergeWith3.default.apply(undefined, [{}].concat(sources, [(0, _joinArrays2.default)()])); +} + +var mergeSmart = merge({ + customizeArray: function customizeArray(a, b, key) { + if (isRule(key.split('.').slice(-1)[0])) { + return (0, _unionWith3.default)(a, b, _joinArraysSmart.uniteRules.bind(null, {}, key)); + } + + return null; + } +}); + +var mergeMultiple = function mergeMultiple() { + for (var _len3 = arguments.length, sources = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + sources[_key3] = arguments[_key3]; + } + + return (0, _values3.default)(merge(sources)); +}; + +// rules: { : <'append'|'prepend'|'replace'> } +// All default to append but you can override here +var mergeStrategy = function mergeStrategy() { + var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return merge({ + customizeArray: _customizeArray(rules), + customizeObject: customizeObject(rules) + }); +}; +var mergeSmartStrategy = function mergeSmartStrategy() { + var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return merge({ + customizeArray: function customizeArray(a, b, key) { + var topKey = key.split('.').slice(-1)[0]; + + if (isRule(topKey)) { + switch (rules[key]) { + case 'prepend': + return [].concat(_toConsumableArray((0, _differenceWith3.default)(b, a, function (newRule, seenRule) { + return (0, _joinArraysSmart.uniteRules)(rules, key, newRule, seenRule, 'prepend'); + })), _toConsumableArray(a)); + case 'replace': + return b; + default: + // append + return (0, _unionWith3.default)(a, b, _joinArraysSmart.uniteRules.bind(null, rules, key)); + } + } + + return _customizeArray(rules)(a, b, key); + }, + customizeObject: customizeObject(rules) + }); +}; + +function _customizeArray(rules) { + return function (a, b, key) { + switch (rules[key]) { + case 'prepend': + return [].concat(_toConsumableArray(b), _toConsumableArray(a)); + case 'replace': + return b; + default: + // append + return false; + } + }; +} + +function customizeObject(rules) { + return function (a, b, key) { + switch (rules[key]) { + case 'prepend': + return (0, _mergeWith3.default)({}, b, a, (0, _joinArrays2.default)()); + case 'replace': + return b; + default: + // append + return false; + } + }; +} + +function isRule(key) { + return ['preLoaders', 'loaders', 'postLoaders', 'rules'].indexOf(key) >= 0; +} + +module.exports = merge; +module.exports.multiple = mergeMultiple; +module.exports.smart = mergeSmart; +module.exports.strategy = mergeStrategy; +module.exports.smartStrategy = mergeSmartStrategy; +module.exports.unique = _unique2.default; \ No newline at end of file diff --git a/node_modules/webpack-merge/lib/join-arrays-smart.js b/node_modules/webpack-merge/lib/join-arrays-smart.js new file mode 100644 index 000000000..74dda9047 --- /dev/null +++ b/node_modules/webpack-merge/lib/join-arrays-smart.js @@ -0,0 +1,148 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.uniteEntries = exports.uniteRules = undefined; + +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); + +var _isEqual2 = require('lodash/isEqual'); + +var _isEqual3 = _interopRequireDefault(_isEqual2); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var isArray = Array.isArray; + +function uniteRules(rules, key, newRule, rule) { + if (String(rule.test) !== String(newRule.test) || (newRule.enforce || rule.enforce) && rule.enforce !== newRule.enforce || newRule.include && !isSameValue(rule.include, newRule.include) || newRule.exclude && !isSameValue(rule.exclude, newRule.exclude)) { + return false; + } else if (!rule.test && !rule.include && !rule.exclude && (rule.loader && rule.loader.split('?')[0]) !== (newRule.loader && newRule.loader.split('?')[0])) { + // Don't merge the rule if there isn't any identifying fields and the loaders don't match + return false; + } else if ((rule.include || rule.exclude) && !newRule.include && !newRule.exclude) { + // Don't merge child without include/exclude to parent that has either + return false; + } + + // newRule.loader should always override + if (newRule.loader) { + var optionsKey = newRule.options ? 'options' : newRule.query && 'query'; + + delete rule.use; + delete rule.loaders; + rule.loader = newRule.loader; + + if (optionsKey) { + rule[optionsKey] = newRule[optionsKey]; + } + } else if ((rule.use || rule.loaders || rule.loader) && (newRule.use || newRule.loaders)) { + var expandEntry = function expandEntry(loader) { + return typeof loader === 'string' ? { loader: loader } : loader; + }; + // this is only here to avoid breaking existing tests + var unwrapEntry = function unwrapEntry(entry) { + return !entry.options && !entry.query ? entry.loader : entry; + }; + + var entries = void 0; + if (rule.loader) { + var _optionsKey = rule.options ? 'options' : rule.query && 'query'; + entries = [{ loader: rule.loader }]; + + if (_optionsKey) { + entries[0][_optionsKey] = rule[_optionsKey]; + } + + delete rule.loader; + + if (_optionsKey) { + delete rule[_optionsKey]; + } + } else { + entries = [].concat(rule.use || rule.loaders).map(expandEntry); + } + var newEntries = [].concat(newRule.use || newRule.loaders).map(expandEntry); + + var loadersKey = rule.use || newRule.use ? 'use' : 'loaders'; + var resolvedKey = key + '.' + loadersKey; + + switch (rules[resolvedKey]) { + case 'prepend': + rule[loadersKey] = [].concat(_toConsumableArray((0, _differenceWith3.default)(newEntries, entries, uniteEntries)), _toConsumableArray(entries)).map(unwrapEntry); + break; + case 'replace': + 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); + } + } + + if (newRule.include) { + rule.include = newRule.include; + } + + if (newRule.exclude) { + rule.exclude = newRule.exclude; + } + + return true; +} + +/** + * Check equality of two values using lodash's isEqual + * Arrays need to be sorted for equality checking + * but clone them first so as not to disrupt the sort order in tests + */ +function isSameValue(a, b) { + var _map = [a, b].map(function (value) { + return isArray(value) ? [].concat(_toConsumableArray(value)).sort() : value; + }), + _map2 = _slicedToArray(_map, 2), + propA = _map2[0], + propB = _map2[1]; + + return (0, _isEqual3.default)(propA, propB); +} + +function uniteEntries(newEntry, entry) { + var loaderNameRe = /^([^?]+)/ig; + + var _entry$loader$match = entry.loader.match(loaderNameRe), + _entry$loader$match2 = _slicedToArray(_entry$loader$match, 1), + loaderName = _entry$loader$match2[0]; + + var _newEntry$loader$matc = newEntry.loader.match(loaderNameRe), + _newEntry$loader$matc2 = _slicedToArray(_newEntry$loader$matc, 1), + newLoaderName = _newEntry$loader$matc2[0]; + + if (loaderName !== newLoaderName) { + return false; + } + + // Replace query values with newer ones + (0, _mergeWith3.default)(entry, newEntry); + return true; +} + +exports.uniteRules = uniteRules; +exports.uniteEntries = uniteEntries; \ No newline at end of file diff --git a/node_modules/webpack-merge/lib/join-arrays.js b/node_modules/webpack-merge/lib/join-arrays.js new file mode 100644 index 000000000..3f2b378b7 --- /dev/null +++ b/node_modules/webpack-merge/lib/join-arrays.js @@ -0,0 +1,67 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _mergeWith2 = require('lodash/mergeWith'); + +var _mergeWith3 = _interopRequireDefault(_mergeWith2); + +var _isPlainObject2 = require('lodash/isPlainObject'); + +var _isPlainObject3 = _interopRequireDefault(_isPlainObject2); + +var _isFunction2 = require('lodash/isFunction'); + +var _isFunction3 = _interopRequireDefault(_isFunction2); + +var _cloneDeep2 = require('lodash/cloneDeep'); + +var _cloneDeep3 = _interopRequireDefault(_cloneDeep2); + +exports.default = joinArrays; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var isArray = Array.isArray; + +function joinArrays() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + customizeArray = _ref.customizeArray, + customizeObject = _ref.customizeObject, + key = _ref.key; + + return function _joinArrays(a, b, k) { + var newKey = key ? key + '.' + k : k; + + if ((0, _isFunction3.default)(a) && (0, _isFunction3.default)(b)) { + return function () { + return _joinArrays(a.apply(undefined, arguments), b.apply(undefined, arguments), k); + }; + } + if (isArray(a) && isArray(b)) { + var customResult = customizeArray && customizeArray(a, b, newKey); + + return customResult || [].concat(_toConsumableArray(a), _toConsumableArray(b)); + } + + if ((0, _isPlainObject3.default)(a) && (0, _isPlainObject3.default)(b)) { + var _customResult = customizeObject && customizeObject(a, b, newKey); + + return _customResult || (0, _mergeWith3.default)({}, a, b, joinArrays({ + customizeArray: customizeArray, + customizeObject: customizeObject, + key: newKey + })); + } + + if ((0, _isPlainObject3.default)(b)) { + return (0, _cloneDeep3.default)(b); + } + + return b; + }; +} \ No newline at end of file diff --git a/node_modules/webpack-merge/lib/unique.js b/node_modules/webpack-merge/lib/unique.js new file mode 100644 index 000000000..4d9992908 --- /dev/null +++ b/node_modules/webpack-merge/lib/unique.js @@ -0,0 +1,27 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _differenceWith2 = require('lodash/differenceWith'); + +var _differenceWith3 = _interopRequireDefault(_differenceWith2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function mergeUnique(key, uniques) { + var getter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (a) { + return a; + }; + + return function (a, b, k) { + return k === key && [].concat(_toConsumableArray(a), _toConsumableArray((0, _differenceWith3.default)(b, a, function (item) { + return uniques.indexOf(getter(item)) >= 0; + }))); + }; +} + +exports.default = mergeUnique; \ No newline at end of file diff --git a/node_modules/webpack-merge/lib/unite-rules.js b/node_modules/webpack-merge/lib/unite-rules.js new file mode 100644 index 000000000..a89b5f6d4 --- /dev/null +++ b/node_modules/webpack-merge/lib/unite-rules.js @@ -0,0 +1,114 @@ +'use strict'; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var isEqual = require('lodash.isequal'); +var mergeWith = require('lodash.mergewith'); +var unionWith = require('lodash.unionwith'); +var differenceWith = require('lodash.differencewith'); + +var isArray = Array.isArray; + +module.exports = function uniteRules(newRule, rule, prepend) { + if (String(rule.test) !== String(newRule.test) || newRule.enforce && rule.enforce !== newRule.enforce || newRule.include && !isSameValue(rule.include, newRule.include) || newRule.exclude && !isSameValue(rule.exclude, newRule.exclude)) { + return false; + } + + // webpack 2 nested rules support + if (rule.rules) { + rule.rules = prepend ? [].concat(_toConsumableArray(differenceWith(newRule.rules, rule.rules, function (b, a) { + return uniteRules(b, a, true); + })), _toConsumableArray(rule.rules)) : unionWith(rule.rules, newRule.rules, uniteRules); + } + + // newRule.loader should always override + if (newRule.loader) { + var optionsKey = newRule.options ? 'options' : newRule.query && 'query'; + + delete rule.use; + delete rule.loaders; + rule.loader = newRule.loader; + + if (optionsKey) { + rule[optionsKey] = newRule[optionsKey]; + } + } else if ((rule.use || rule.loaders || rule.loader) && (newRule.use || newRule.loaders)) { + var expandEntry = function expandEntry(loader) { + return typeof loader === 'string' ? { loader: loader } : loader; + }; + // this is only here to avoid breaking existing tests + var unwrapEntry = function unwrapEntry(entry) { + return !entry.options && !entry.query ? entry.loader : entry; + }; + + var entries = void 0; + if (rule.loader) { + var _optionsKey = rule.options ? 'options' : rule.query && 'query'; + entries = [{ loader: rule.loader }]; + + if (_optionsKey) { + entries[0][_optionsKey] = rule[_optionsKey]; + } + + delete rule.loader; + + if (_optionsKey) { + delete rule[_optionsKey]; + } + } else { + entries = [].concat(rule.use || rule.loaders).map(expandEntry); + } + var newEntries = [].concat(newRule.use || newRule.loaders).map(expandEntry); + + var loadersKey = rule.use || newRule.use ? 'use' : 'loaders'; + rule[loadersKey] = prepend ? [].concat(_toConsumableArray(differenceWith(newEntries, entries, uniteEntries)), _toConsumableArray(entries)).map(unwrapEntry) : unionWith(entries, newEntries, uniteEntries).map(unwrapEntry); + } + + if (newRule.include) { + rule.include = newRule.include; + } + + if (newRule.exclude) { + rule.exclude = newRule.exclude; + } + + return true; +}; + +/** + * Check equality of two values using lodash's isEqual + * Arrays need to be sorted for equality checking + * but clone them first so as not to disrupt the sort order in tests + */ +function isSameValue(a, b) { + var _map = [a, b].map(function (value) { + return isArray(value) ? [].concat(_toConsumableArray(value)).sort() : value; + }), + _map2 = _slicedToArray(_map, 2), + propA = _map2[0], + propB = _map2[1]; + + return isEqual(propA, propB); +} + +function uniteEntries(newEntry, entry) { + var loaderNameRe = /^([^?]+)/ig; + + var _entry$loader$match = entry.loader.match(loaderNameRe), + _entry$loader$match2 = _slicedToArray(_entry$loader$match, 1), + loaderName = _entry$loader$match2[0]; + + var _newEntry$loader$matc = newEntry.loader.match(loaderNameRe), + _newEntry$loader$matc2 = _slicedToArray(_newEntry$loader$matc, 1), + newLoaderName = _newEntry$loader$matc2[0]; + + if (loaderName !== newLoaderName) { + return false; + } + + // Replace query values with newer ones + mergeWith(entry, newEntry); + return true; +} \ No newline at end of file diff --git a/node_modules/webpack-merge/package.json b/node_modules/webpack-merge/package.json new file mode 100644 index 000000000..7916a8c5f --- /dev/null +++ b/node_modules/webpack-merge/package.json @@ -0,0 +1,74 @@ +{ + "name": "webpack-merge", + "description": "Variant of merge that's useful for webpack configuration", + "author": "Juho Vepsalainen ", + "version": "4.1.0", + "scripts": { + "build": "babel src -d lib", + "watch": "npm-watch", + "test": "mocha tests/test-*", + "test:coverage": "istanbul cover node_modules/.bin/_mocha tests/test-*", + "test:lint": "eslint src/ tests/ --cache", + "preversion": "npm run test:lint && npm run build && npm test && git commit --allow-empty -am \"Update lib\"" + }, + "main": "lib/index.js", + "files": [ + "lib" + ], + "dependencies": { + "lodash": "^4.17.4" + }, + "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", + "eslint-plugin-jsx-a11y": "^3.0.2", + "eslint-plugin-react": "^6.9.0", + "git-prepush-hook": "^1.0.1", + "istanbul": "^0.4.5", + "mocha": "^3.2.0", + "npm-watch": "^0.1.7", + "webpack": "^1.14.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/survivejs/webpack-merge.git" + }, + "homepage": "https://github.com/survivejs/webpack-merge", + "bugs": { + "url": "https://github.com/survivejs/webpack-merge/issues" + }, + "keywords": [ + "webpack", + "merge" + ], + "license": "MIT", + "pre-push": [ + "test:lint", + "build", + "test" + ], + "watch": { + "build": { + "patterns": [ + "src/**/*.js" + ] + }, + "test": { + "patterns": [ + "src/**/*.js", + "tests/**/*.js" + ] + }, + "test:lint": { + "patterns": [ + "src/**/*.js", + "tests/**/*.js" + ] + } + } +} -- cgit v1.2.3