Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-merge

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-merge - npm Package Compare versions

Comparing version 5.0.0 to 5.0.3

118

CHANGELOG.md

@@ -1,3 +0,5 @@

# 5.0.0 / 2020-07-03
# Changelog
## 5.0.2 / 2020-07-06
- Feature - Support TypeScript out of the box. #84 #86 #95 #110 #112

@@ -15,4 +17,6 @@ - Deprecation - `merge.smart` has been dropped as it's tricky to support all the corner cases. Instead, it's better to use the provided utilities to put together a `merge` that fits your case.

# 4.2.2 / 2019-08-27
Special thanks to Google and Addy Osmani for supporting the work financially as it allowed me to complete the work required by the new major release.
## 4.2.2 / 2019-08-27
- Fix - Update minimum version of lodash to 4.17.15 in order to avoid `npm audit warning`. #116

@@ -22,3 +26,3 @@ - Docs - Improve `merge.unique` documentation. #103

# 4.2.1 / 2019-01-04
## 4.2.1 / 2019-01-04

@@ -28,23 +32,23 @@ - Feature - Support `oneOf` at `merge.smart`. #111

# 4.1.4 / 2018-08-01
## 4.1.4 / 2018-08-01
- Maintenance - Remove bitHound from the README as it closed down. #102
# 4.1.3 / 2018-06-14
## 4.1.3 / 2018-06-14
- Fix - Smart merge respects the existing loader order #79, #101
# 4.1.2 / 2017-02-22
## 4.1.2 / 2017-02-22
- Maintenance - Update lodash, #97, #98
# 4.1.1 / 2017-11-01
## 4.1.1 / 2017-11-01
- Docs - Add `customizeArray` and `customizeObject` examples. #93
# 4.1.0 / 2017-03-16
## 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
## 4.0.0 / 2017-03-06

@@ -84,39 +88,39 @@ - Breaking feature - `merge.smart` allows re-ordering loaders like below. #70

# 3.0.0 / 2017-02-19
## 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
## 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
## 2.6.0 / 2017-01-27
- Bug fix - Support `replace` mode for `merge.smartStrategy`. #63
# 2.5.0 / 2017-01-26
## 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
## 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
## 2.3.1 / 2017-01-06
- Bug fix - Clear up `CopyWebpackPlugin` handling. #56
# 2.3.0 / 2017-01-06
## 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
## 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
## 2.1.1 / 2017-01-05
- Bug fix - Avoid recursion at `merge.smart`. #53
# 2.1.0 / 2017-01-05
## 2.1.0 / 2017-01-05

@@ -135,3 +139,3 @@ - Feature - Allow `merge.smartStrategy` to merge plugin contents. API: `merge.smartStrategy(rules, plugins)`. #44. Example:

# 2.0.0 / 2016-12-22
## 2.0.0 / 2016-12-22

@@ -151,11 +155,11 @@ - Breaking - Disallow overriding configuration with empty arrays/objects (#48). If you want to override, use `merge.strategy`. Example:

# 1.1.2 / 2016-12-18
## 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
## 1.1.1 / 2016-12-11
- Bug fix - Support previously undocumented, yet used, `merge([<object>])` format. This works with all available functions. #46
# 1.1.0 / 2016-12-09
## 1.1.0 / 2016-12-09

@@ -173,7 +177,7 @@ - Feature - Allow `merge` behavior to be customized with overrides. Example:

# 1.0.2 / 2016-11-29
## 1.0.2 / 2016-11-29
- Bug fix - `merge` should not mutate inputs with mismatched keys.
# 1.0.0 / 2016-11-28
## 1.0.0 / 2016-11-28

@@ -183,11 +187,11 @@ - Feature: Support merging Webpack 2 Rule.use. #38

# 0.20.0 / 2016-11-27
## 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
## 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
## 0.18.0 / 2016-11-24

@@ -212,15 +216,15 @@ - Feature: Add support for recursive definitions at `merge.strategy`. Example:

# 0.17.0 / 2016-11-16
## 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
## 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
## 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
## 0.14.1 / 2016-07-25

@@ -230,51 +234,51 @@ - Docs: Improve package description. #23.

# 0.14.0 / 2016-06-05
## 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
## 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
## 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
## 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
## 0.10.0 / 2016-04-10
- Feature: Support `include/exclude` at `merge.smart`. Thanks to @siready. #14.
# 0.9.0 / 2016-04-08
## 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
## 0.8.4 / 2016-03-17
- Bug fix: _webpack-merge_ should not mutate inputs. #12
# 0.8.3 / 2016-03-02
## 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
## 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
## 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
## 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
## 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
## 0.7.0 / 2015-12-31

@@ -284,3 +288,3 @@ - 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.

# 0.6.0 / 2015-12-30
## 0.6.0 / 2015-12-30

@@ -290,11 +294,11 @@ - Support `preLoaders` and `postLoaders`. Previously only `loaders` were supported.

# 0.5.1 / 2015-12-26
## 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
## 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
## 0.4.0 / 2015-12-23

@@ -304,11 +308,11 @@ - Dropped changelog generator. It's better to write these by hand.

# 0.3.2 / 2015-11-23
## 0.3.2 / 2015-11-23
- Tweaked changelog generator process.
# 0.3.1 / 2015-11-23
## 0.3.1 / 2015-11-23
- Added changelog generator.
# 0.3.0 / 2015-11-13
## 0.3.0 / 2015-11-13

@@ -318,3 +322,3 @@ - Improved formatting

# 0.2.0 / 2015-08-30
## 0.2.0 / 2015-08-30

@@ -324,16 +328,16 @@ - Only require lodash modules used by the package (@montogeek)

# 0.1.3 / 2015-08-10
## 0.1.3 / 2015-08-10
- Improved README example
# 0.1.2 / 2015-07-01
## 0.1.2 / 2015-07-01
- Simplified example
# 0.1.1 / 2015-06-26
## 0.1.1 / 2015-06-26
- Fixed travis link
# 0.1.0 / 2015-06-26
## 0.1.0 / 2015-06-26
- Initial implementation

@@ -5,3 +5,3 @@ {

"author": "Juho Vepsalainen <bebraw@gmail.com>",
"version": "5.0.0",
"version": "5.0.3",
"scripts": {

@@ -15,2 +15,3 @@ "build": "tsdx build",

"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [

@@ -24,7 +25,7 @@ "dist"

"devDependencies": {
"@types/webpack": "^4.41.18",
"@types/webpack": "^4.41.19",
"husky": "^4.2.5",
"tsdx": "^0.13.2",
"tslib": "^2.0.0",
"typescript": "^3.9.5",
"typescript": "^3.9.6",
"webpack": "^4.43.0"

@@ -47,2 +48,5 @@ },

},
"jest": {
"collectCoverage": true
},
"license": "MIT",

@@ -49,0 +53,0 @@ "husky": {

@@ -5,10 +5,8 @@ [![Financial Contributors on Open Collective](https://opencollective.com/webpack-merge/all/badge.svg?label=financial+contributors)](https://opencollective.com/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** 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.
_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.
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.
## Standard Merging
## **`merge(...configuration | [...configuration])`**
### **`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.

@@ -35,9 +33,36 @@

> Note that `Promise`s are not supported! If you want to return a configuration wrapped within a `Promise`, `merge` inside one. Example: `Promise.resolve(merge({ ... }, { ... }))`.
### Limitations
### **`mergeWithCustomize({ customizeArray, customizeObject })(...configuration | [...configuration])`**
Note that `Promise`s are not supported! If you want to return a configuration wrapped within a `Promise`, `merge` inside one. Example: `Promise.resolve(merge({ ... }, { ... }))`.
`merge` behavior can be customized per field as below:
The same goes for configuration level functions as in the example below:
**webpack.config.js**
```javascript
const commonConfig = { ... };
const productionConfig = { ... };
const developmentConfig = { ... };
module.exports = env => {
switch(env) {
case 'development':
return merge(commonConfig, developmentConfig);
case 'production':
return merge(commonConfig, productionConfig);
default:
throw new Error('No matching configuration was found!');
}
}
```
You can choose the configuration you want by using `webpack --env development` assuming you are using _webpack-cli_.
## **`mergeWithCustomize({ customizeArray, customizeObject })(...configuration | [...configuration])`**
In case you need more flexibility, `merge` behavior can be customized per field as below:
```javascript
import { mergeWithCustomize } from 'webpack-merge';

@@ -105,4 +130,23 @@

### **`unique(<field>, <fields>, field => field)`**
## **`customizeArray`** and **`customizeObject`**
`customizeArray` and `customizeObject` provide small strategies to for `mergeWithCustomize`. They support `append`, `prepend`, `replace`, and wildcards for field names.
```javascript
import { mergeWithCustomize, customizeArray, customizeObject } from 'webpack-merge';
const output = mergeWithCustomize({
customizeArray: customizeArray({
'entry.*': 'prepend'
}),
customizeObject: customizeObject({
entry: 'prepend'
})
})(object1, object2, object3, ...);
```
## **`unique(<field>, <fields>, field => field)`**
`unique` is a strategy used for forcing uniqueness within configuration. It's most useful with plugins when you want to make sure there's only one in place.
The first `<field>` is the config property to look through for duplicates.

@@ -130,31 +174,19 @@

// Output contains only single HotModuleReplacementPlugin now.
// Output contains only single HotModuleReplacementPlugin now and it's
// going to be the last plugin instance.
```
### **`customizeArray`** and **`customizeObject`**
## Development
`customizeArray` and `customizeObject` provide small strategies to for `mergeWithCustomize`. They support `append`, `prepend`, `replace`, and wildcards for field names.
1. `npm i`
1. `npm t -- --watch`
```javascript
import { mergeWithCustomize, customizeArray, customizeObject } from 'webpack-merge';
Before contributing, please [open an issue](https://github.com/survivejs/webpack-merge/issues/new) where to discuss.
const output = mergeWithCustomize({
customizeArray: customizeArray({
'entry.*': 'prepend'
}),
customizeObject: customizeObject({
entry: 'prepend'
})
})(object1, object2, object3, ...);
```
## Further Information and Support
> Check out [SurviveJS - Webpack](http://survivejs.com/) to dig deeper into the topic.
Check out [SurviveJS - Webpack](http://survivejs.com/) to dig deeper into webpack. The free book uses _webpack-merge_ extensively and shows you how to compose your configuration to keep it maintainable.
## Development
I am also available as a consultant in case you require specific assistance. I can contribute particularly in terms of improving maintainability of the setup while speeding it up and pointing out better practices. In addition to improving developer productivity, the work has impact on the end users of the product in terms of reduced application size and loading times.
1. `npm i`
1. `npm t -- --watch`
Before contributing, please open an issue where to discuss.
## Contributors

@@ -161,0 +193,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc