diff options
Diffstat (limited to 'node_modules/webpack-chain')
19 files changed, 2891 insertions, 0 deletions
diff --git a/node_modules/webpack-chain/CHANGELOG.md b/node_modules/webpack-chain/CHANGELOG.md new file mode 100644 index 00000000..fae701b1 --- /dev/null +++ b/node_modules/webpack-chain/CHANGELOG.md @@ -0,0 +1,253 @@ +### Changelog + +All notable changes to this project will be documented in this file. Dates are displayed in UTC. + +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). + +#### [v4.12.1](https://github.com/neutrinojs/webpack-chain/compare/v4.12.0...v4.12.1) + +> 3 October 2018 + +- Switch from changelog to auto-changelog [`#109`](https://github.com/neutrinojs/webpack-chain/pull/109) +- Allow passing entry as a string to config.merge() [`#107`](https://github.com/neutrinojs/webpack-chain/pull/107) +- Lock file maintenance [`#101`](https://github.com/neutrinojs/webpack-chain/pull/101) +- Update dependency eslint-plugin-prettier to v3 [`e42d8bd`](https://github.com/neutrinojs/webpack-chain/commit/e42d8bd2f6f70841c4d1ab7a2926c26d3ec828ed) + +#### [v4.12.0](https://github.com/neutrinojs/webpack-chain/compare/v4.11.0...v4.12.0) + +> 28 September 2018 + +- Revert changes to gitignore [`c1250a0`](https://github.com/neutrinojs/webpack-chain/commit/c1250a0fe7ffafa82f529ac8e7262e2c3cdd4729) + +#### [v4.11.0](https://github.com/neutrinojs/webpack-chain/compare/v4.10.0...v4.11.0) + +> 13 September 2018 + +- Support specifying plugins by path [`#102`](https://github.com/neutrinojs/webpack-chain/pull/102) +- Lock file maintenance [`#100`](https://github.com/neutrinojs/webpack-chain/pull/100) +- Lock file maintenance [`#96`](https://github.com/neutrinojs/webpack-chain/pull/96) + +#### [v4.10.0](https://github.com/neutrinojs/webpack-chain/compare/v4.9.0...v4.10.0) + +> 6 September 2018 + +- Use the Resolve API to define ResolveLoader according to webpack [`#99`](https://github.com/neutrinojs/webpack-chain/pull/99) +- Migrate to new org [`#92`](https://github.com/neutrinojs/webpack-chain/pull/92) +- test: 'clean' in 'ChainedMap' [`#93`](https://github.com/neutrinojs/webpack-chain/pull/93) +- Lock file maintenance [`3a4b3e1`](https://github.com/neutrinojs/webpack-chain/commit/3a4b3e10032856ab7f01afa67a23dd9e4e68161a) +- Lock file maintenance [`815bfd1`](https://github.com/neutrinojs/webpack-chain/commit/815bfd173a2dc6f802b66a48cdb2c4d2ff47df9f) + +#### [v4.9.0](https://github.com/neutrinojs/webpack-chain/compare/v4.8.0...v4.9.0) + +> 15 August 2018 + +- Update to ESLint 5 [`#89`](https://github.com/neutrinojs/webpack-chain/pull/89) +- Lock file maintenance [`#85`](https://github.com/neutrinojs/webpack-chain/pull/85) +- Implement ChainedMap.getOrCompute [`#63`](https://github.com/neutrinojs/webpack-chain/pull/63) +- Support Object literal plugin usage [`#86`](https://github.com/neutrinojs/webpack-chain/pull/86) +- Lock file maintenance [`#61`](https://github.com/neutrinojs/webpack-chain/pull/61) +- Lock file maintenance [`#60`](https://github.com/neutrinojs/webpack-chain/pull/60) +- Update dependency eslint-config-airbnb-base to v13 [`7370962`](https://github.com/neutrinojs/webpack-chain/commit/73709628a6ff6661e478c652d0ff03b99b6c2abb) +- merge resolve plugins just like config [`c47ee2d`](https://github.com/neutrinojs/webpack-chain/commit/c47ee2d52c1be4fcdbe10adef865e45d6fd729ef) +- Fix linting :/ [`30cc11d`](https://github.com/neutrinojs/webpack-chain/commit/30cc11d0d35a5676069a623b180c8e7b00e099e4) +- Fix README bug, test in Node.js v6 [`4a37c74`](https://github.com/neutrinojs/webpack-chain/commit/4a37c74e1f790e118034154da9c32d0e36164f74) +- linted [`dff82f8`](https://github.com/neutrinojs/webpack-chain/commit/dff82f8494394dcf8c97bff324f877513f44fa56) +- Run yarn lint --fix [`9384537`](https://github.com/neutrinojs/webpack-chain/commit/9384537269d60bb80b3330cf44ddbdd9d528c454) + +#### [v4.8.0](https://github.com/neutrinojs/webpack-chain/compare/v4.7.0...v4.8.0) + +> 16 May 2018 + +- Expose toString as a static method on Config [`#57`](https://github.com/neutrinojs/webpack-chain/pull/57) +- Add test for Config.toString, add README note [`0107aef`](https://github.com/neutrinojs/webpack-chain/commit/0107aef203202aef069190723b04ec4f6ac80b9f) + +#### [v4.7.0](https://github.com/neutrinojs/webpack-chain/compare/v4.6.0...v4.7.0) + +> 15 May 2018 + +- Lint with eslint, prettier, airbnb [`#52`](https://github.com/neutrinojs/webpack-chain/pull/52) +- Support Config.toString() with name hints [`#53`](https://github.com/neutrinojs/webpack-chain/pull/53) +- Configure Renovate [`#54`](https://github.com/neutrinojs/webpack-chain/pull/54) +- Lock file maintenance [`50d4db8`](https://github.com/neutrinojs/webpack-chain/commit/50d4db81ab5fe62a55435720f5c78ddc40309a88) + +#### [v4.6.0](https://github.com/neutrinojs/webpack-chain/compare/v4.5.0...v4.6.0) + +> 16 April 2018 + +- Support Webpack 4.x [`#51`](https://github.com/neutrinojs/webpack-chain/pull/51) +- Update devDependencies [`#50`](https://github.com/neutrinojs/webpack-chain/pull/50) + +#### [v4.5.0](https://github.com/neutrinojs/webpack-chain/compare/v4.4.2...v4.5.0) + +> 22 November 2017 + +- Introduce method for performing a batch of operations against a context [`#43`](https://github.com/neutrinojs/webpack-chain/pull/43) + +#### [v4.4.2](https://github.com/neutrinojs/webpack-chain/compare/v4.4.1...v4.4.2) + +> 10 October 2017 + +- Update changelog [`1bb3da1`](https://github.com/neutrinojs/webpack-chain/commit/1bb3da1fec04a158f68762e57aff33a0172a298f) +- Hotfix - guard against non-defined entries when ordering chainedmap [`76be81f`](https://github.com/neutrinojs/webpack-chain/commit/76be81f4509b9652bef25cc55747df87850b858e) +- Updating changelog [`a71fc4b`](https://github.com/neutrinojs/webpack-chain/commit/a71fc4b70ccce358aacc29ed7dc5d8cdacdd4cc1) + +#### [v4.4.1](https://github.com/neutrinojs/webpack-chain/compare/v4.4.0...v4.4.1) + +> 6 October 2017 + +- Updating changelog [`97a2fab`](https://github.com/neutrinojs/webpack-chain/commit/97a2fabf6e51f1b03cacb0991ba02e236be983fa) +- Missing schema before/after [`8d8f26d`](https://github.com/neutrinojs/webpack-chain/commit/8d8f26dd0e6db375dbabb8e8dfe784e6c50408d5) + +#### [v4.4.0](https://github.com/neutrinojs/webpack-chain/compare/v4.3.0...v4.4.0) + +> 6 October 2017 + +- Feature: allow specifying to use before or after other use [`#42`](https://github.com/neutrinojs/webpack-chain/pull/42) +- Docs: Upstream fixes made to Neutrino's webpack-chain docs [`#41`](https://github.com/neutrinojs/webpack-chain/pull/41) +- Improve documentation for plugin configuration [`#40`](https://github.com/neutrinojs/webpack-chain/pull/40) +- Allow omitting keys from source merge object [`fb6ea2f`](https://github.com/neutrinojs/webpack-chain/commit/fb6ea2fad931c13e7516a3e9354215a78cb5c4ff) +- Feature: allow specifying .before or .after to order plugins and uses [`b0040bf`](https://github.com/neutrinojs/webpack-chain/commit/b0040bff73b3b9e55d53192ac4a447a2ac8c02d1) +- Rename when arguments to be clearer [`d15e895`](https://github.com/neutrinojs/webpack-chain/commit/d15e895669ce0a44c704755af39290700e73e85f) +- Bumping deps [`c15be4a`](https://github.com/neutrinojs/webpack-chain/commit/c15be4ab99d232126bbf18666f4f20f80df21f90) +- Update changelog [`5aec63a`](https://github.com/neutrinojs/webpack-chain/commit/5aec63a424c71a9a603540b33e576999c839f074) + +#### [v4.3.0](https://github.com/neutrinojs/webpack-chain/compare/v4.2.0...v4.3.0) + +> 13 September 2017 + +- Update API for base config, dev server, and output [`#38`](https://github.com/neutrinojs/webpack-chain/pull/38) +- Update changelog [`6260f49`](https://github.com/neutrinojs/webpack-chain/commit/6260f49edbcab301988b7b2c6c8a77e07707c010) + +#### [v4.2.0](https://github.com/neutrinojs/webpack-chain/compare/v4.1.0...v4.2.0) + +> 13 September 2017 + +- Add new shorthands from resolve and output [`#37`](https://github.com/neutrinojs/webpack-chain/pull/37) +- changelog [`0374e51`](https://github.com/neutrinojs/webpack-chain/commit/0374e518a4b465c73b5097eff6e4c77768319e4f) +- Updating README with shorthands [`ae5e75a`](https://github.com/neutrinojs/webpack-chain/commit/ae5e75ae619d0399bcbf8e588a48759b0e590b6e) + +#### [v4.1.0](https://github.com/neutrinojs/webpack-chain/compare/v4.0.0...v4.1.0) + +> 12 September 2017 + +- Updating rule definition shortcuts, adding oneOf [`#36`](https://github.com/neutrinojs/webpack-chain/pull/36) + +### [v4.0.0](https://github.com/neutrinojs/webpack-chain/compare/v3.3.0...v4.0.0) + +> 3 August 2017 + +- Switch noParse to getter/setter to allow webpack v3 function argument [`#32`](https://github.com/neutrinojs/webpack-chain/pull/32) +- Serialize performance into config output [`#31`](https://github.com/neutrinojs/webpack-chain/pull/31) +- Release v4.0.0 [`e84b002`](https://github.com/neutrinojs/webpack-chain/commit/e84b00207f6d4f4dc37c43ffffc65d8a34f63a75) + +#### [v3.3.0](https://github.com/neutrinojs/webpack-chain/compare/v3.2.0...v3.3.0) + +> 18 May 2017 + +- Adding noParse on module [`#27`](https://github.com/neutrinojs/webpack-chain/pull/27) +- Releasing v3.3.0 [`4a59bef`](https://github.com/neutrinojs/webpack-chain/commit/4a59bef687f273503945e638fefe1f6ab29857d1) + +#### [v3.2.0](https://github.com/neutrinojs/webpack-chain/compare/v3.1.0...v3.2.0) + +> 12 April 2017 + +- Adding updated shorthand methods for devServer [`#23`](https://github.com/neutrinojs/webpack-chain/pull/23) + +#### [v3.1.0](https://github.com/neutrinojs/webpack-chain/compare/v3.0.0...v3.1.0) + +> 29 March 2017 + +- Allow conditional configuration via when [`#22`](https://github.com/neutrinojs/webpack-chain/pull/22) +- Update README with links to previous docs versions [`0dc3984`](https://github.com/neutrinojs/webpack-chain/commit/0dc39841b76c5e4d9493fa86d7f65e66145a6964) +- Update README with links to previous docs versions [`bcc2362`](https://github.com/neutrinojs/webpack-chain/commit/bcc2362d396cee736feaa5e4537150b4a1fa2d4a) + +### [v3.0.0](https://github.com/neutrinojs/webpack-chain/compare/v2.0.1...v3.0.0) + +> 8 March 2017 + +- Make rule.include, rule.exclude, loaders and plugins more extensible [`#16`](https://github.com/neutrinojs/webpack-chain/pull/16) + +#### [v2.0.1](https://github.com/neutrinojs/webpack-chain/compare/v2.0.0...v2.0.1) + +> 8 March 2017 + +- undefined plugin [`#17`](https://github.com/neutrinojs/webpack-chain/pull/17) + +### [v2.0.0](https://github.com/neutrinojs/webpack-chain/compare/v1.4.3...v2.0.0) + +> 6 March 2017 + +- Adding testing, which informed v2 API, updated docs to reflect [`#14`](https://github.com/neutrinojs/webpack-chain/pull/14) +- Make Plugin API consistent with Loader API [`#13`](https://github.com/neutrinojs/webpack-chain/pull/13) +- MPL license, moving to mozilla-neutrino [`f122edd`](https://github.com/neutrinojs/webpack-chain/commit/f122eddccb9f7af9742f5c447c651172700b4c50) + +#### [v1.4.3](https://github.com/neutrinojs/webpack-chain/compare/v1.4.2...v1.4.3) + +> 4 March 2017 + +- Adding ChainedMap and ChainedSet documentation [`b071f82`](https://github.com/neutrinojs/webpack-chain/commit/b071f82042c7806f6d2df412a0154c1b985c4763) +- Removing empty entities from cluttering configuration object [`b428e55`](https://github.com/neutrinojs/webpack-chain/commit/b428e55a671a033c133ba2e225796845307dee12) +- Docs: getConfig -> toConfig [`2468eaa`](https://github.com/neutrinojs/webpack-chain/commit/2468eaac7e4c2f74cae244a4af6d2a517483db7b) + +#### [v1.4.2](https://github.com/neutrinojs/webpack-chain/compare/v1.4.1...v1.4.2) + +> 2 March 2017 + +- Fix bug where `exclude` doesn't return `this` [`#7`](https://github.com/neutrinojs/webpack-chain/pull/7) +- Bumping to v1.4.2 [`38d1412`](https://github.com/neutrinojs/webpack-chain/commit/38d1412037780b815c537de2abd5f02443b80502) + +#### [v1.4.1](https://github.com/neutrinojs/webpack-chain/compare/v1.4.0...v1.4.1) + +> 26 February 2017 + +- Allowing config merge to append to existing rule loaders [`#3`](https://github.com/neutrinojs/webpack-chain/pull/3) +- docs(readme): fix typo in devtool option [`#1`](https://github.com/neutrinojs/webpack-chain/pull/1) + +#### [v1.4.0](https://github.com/neutrinojs/webpack-chain/compare/v1.3.0...v1.4.0) + +> 15 February 2017 + +- Adds rule test merge via string to regex, fixes externals not chainable [`a15b49e`](https://github.com/neutrinojs/webpack-chain/commit/a15b49ec28903708c04665d0c6cac3a956558a99) + +#### [v1.3.0](https://github.com/neutrinojs/webpack-chain/compare/v1.2.0...v1.3.0) + +> 14 February 2017 + +- Adding functionality for merging and object into a Config instance [`5f0b0c6`](https://github.com/neutrinojs/webpack-chain/commit/5f0b0c670e6ad946e0232a208abb667f749aeba4) + +#### [v1.2.0](https://github.com/neutrinojs/webpack-chain/compare/v1.1.0...v1.2.0) + +> 13 February 2017 + +- Adds hot flag for Config.DevServer [`c64a155`](https://github.com/neutrinojs/webpack-chain/commit/c64a1558188ab2a4982a7b3f2aba95ced50c9756) + +#### [v1.1.0](https://github.com/neutrinojs/webpack-chain/compare/v1.0.3...v1.1.0) + +> 13 February 2017 + +- Adding ChainedSet#prepend functionality [`cc86e7b`](https://github.com/neutrinojs/webpack-chain/commit/cc86e7bdbdcaca7610255039dcb31adfacb4952b) + +#### [v1.0.3](https://github.com/neutrinojs/webpack-chain/compare/v1.0.2...v1.0.3) + +> 10 February 2017 + +- Fixes exception with empty rule entries with loader only [`7964b34`](https://github.com/neutrinojs/webpack-chain/commit/7964b347ed613c7dc18e54f912467abad2956b8b) + +#### [v1.0.2](https://github.com/neutrinojs/webpack-chain/compare/v1.0.1...v1.0.2) + +> 9 February 2017 + +- Fixes plugin methods not chaining [`7cc56ed`](https://github.com/neutrinojs/webpack-chain/commit/7cc56ed5e331c7cc0ccd58f25feb3b1b0398829a) + +#### [v1.0.1](https://github.com/neutrinojs/webpack-chain/compare/v1.0.0...v1.0.1) + +> 9 February 2017 + +- Shared configuration documentation [`5c6a65b`](https://github.com/neutrinojs/webpack-chain/commit/5c6a65b344113ff3522d5f7d66dfacbc0ad7fa69) +- Avoid exceptions in empty config [`ab46ee0`](https://github.com/neutrinojs/webpack-chain/commit/ab46ee0234a04eb2b89190df32ea4287c499dd39) + +#### v1.0.0 + +> 6 February 2017 + +- initial commit [`9e2a87c`](https://github.com/neutrinojs/webpack-chain/commit/9e2a87c5f6a1f1aac3eedbd4102e40dc47a8f7f4) diff --git a/node_modules/webpack-chain/LICENSE b/node_modules/webpack-chain/LICENSE new file mode 100644 index 00000000..fa0086a9 --- /dev/null +++ b/node_modules/webpack-chain/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0.
\ No newline at end of file diff --git a/node_modules/webpack-chain/README.md b/node_modules/webpack-chain/README.md new file mode 100644 index 00000000..0dd025ad --- /dev/null +++ b/node_modules/webpack-chain/README.md @@ -0,0 +1,1288 @@ +# webpack-chain + +Use a chaining API to generate and simplify the modification of +webpack version 2-4 configurations. + +This documentation corresponds to v4 of webpack-chain. + +* [v3 docs](https://github.com/neutrinojs/webpack-chain/tree/v3) +* [v2 docs](https://github.com/neutrinojs/webpack-chain/tree/v2) +* [v1 docs](https://github.com/neutrinojs/webpack-chain/tree/v1.4.3) + +_Note: while webpack-chain is utilized extensively in Neutrino, this package is +completely standalone and can be used by any project._ + +## Introduction + +webpack's core configuration is based on creating and modifying a +potentially unwieldy JavaScript object. While this is OK for configurations +on individual projects, trying to share these objects across projects and +make subsequent modifications gets messy, as you need to have a deep +understanding of the underlying object structure to make those changes. + +`webpack-chain` attempts to improve this process by providing a chainable or +fluent API for creating and modifying webpack configurations. Key portions +of the API can be referenced by user-specified names, which helps to +standardize how to modify a configuration across projects. + +This is easier explained through the examples following. + +## Installation + +`webpack-chain` requires Node.js v6.9 and higher. `webpack-chain` also +only creates configuration objects designed for use in webpack versions 2, 3, +and 4. + +You may install this package using either Yarn or npm (choose one): + +**Yarn** + +```bash +yarn add --dev webpack-chain +``` + +**npm** + +```bash +npm install --save-dev webpack-chain +``` + +## Getting Started + +Once you have `webpack-chain` installed, you can start creating a +webpack configuration. For this guide, our example base configuration will +be `webpack.config.js` in the root of our project directory. + +```js +// Require the webpack-chain module. This module exports a single +// constructor function for creating a configuration API. +const Config = require('webpack-chain'); + +// Instantiate the configuration with a new API +const config = new Config(); + +// Make configuration changes using the chain API. +// Every API call tracks a change to the stored configuration. + +config + // Interact with entry points + .entry('index') + .add('src/index.js') + .end() + // Modify output settings + .output + .path('dist') + .filename('[name].bundle.js'); + +// Create named rules which can be modified later +config.module + .rule('lint') + .test(/\.js$/) + .pre() + .include + .add('src') + .end() + // Even create named uses (loaders) + .use('eslint') + .loader('eslint-loader') + .options({ + rules: { + semi: 'off' + } + }); + +config.module + .rule('compile') + .test(/\.js$/) + .include + .add('src') + .add('test') + .end() + .use('babel') + .loader('babel-loader') + .options({ + presets: [ + ['@babel/preset-env', { modules: false }] + ] + }); + +// Create named plugins too! +config + .plugin('clean') + .use(CleanPlugin, [['dist'], { root: '/dir' }]); + +// Export the completed configuration object to be consumed by webpack +module.exports = config.toConfig(); +``` + +Having shared configurations is also simple. Just export the configuration +and call `.toConfig()` prior to passing to webpack. + +```js +// webpack.core.js +const Config = require('webpack-chain'); +const config = new Config(); + +// Make configuration shared across targets +// ... + +module.exports = config; + +// webpack.dev.js +const config = require('./webpack.core'); + +// Dev-specific configuration +// ... +module.exports = config.toConfig(); + +// webpack.prod.js +const config = require('./webpack.core'); + +// Production-specific configuration +// ... +module.exports = config.toConfig(); +``` + +## ChainedMap + +One of the core API interfaces in webpack-chain is a `ChainedMap`. A +`ChainedMap` operates similar to a JavaScript Map, with some conveniences for +chaining and generating configuration. If a property is marked as being a +`ChainedMap`, it will have an API and methods as described below: + +**Unless stated otherwise, these methods will return the `ChainedMap`, allowing +you to chain these methods.** + +```js +// Remove all entries from a Map. +clear() +``` + +```js +// Remove a single entry from a Map given its key. +// key: * +delete(key) +``` + +```js +// Fetch the value from a Map located at the corresponding key. +// key: * +// returns: value +get(key) +``` + +```js +// Fetch the value from a Map located at the corresponding key. +// If the key is missing, the key is set to the result of function fn. +// key: * +// fn: Function () -> value +// returns: value +getOrCompute(key, fn) +``` + +```js +// Set a value on the Map stored at the `key` location. +// key: * +// value: * +set(key, value) +``` + +```js +// Returns `true` or `false` based on whether a Map as has a value set at a +// particular key. +// key: * +// returns: Boolean +has(key) +``` + +```js +// Returns an array of all the values stored in the Map. +// returns: Array +values() +``` + +```js +// Returns an object of all the entries in the backing Map +// where the key is the object property, and the value +// corresponding to the key. Will return `undefined` if the backing +// Map is empty. +// This will order properties by their name if the value is +// a ChainedMap that used .before() or .after(). +// returns: Object, undefined if empty +entries() +```` + +```js +// Provide an object which maps its properties and values +// into the backing Map as keys and values. +// You can also provide an array as the second argument +// for property names to omit from being merged. +// obj: Object +// omit: Optional Array +merge(obj, omit) +``` + +```js +// Execute a function against the current configuration context +// handler: Function -> ChainedMap + // A function which is given a single argument of the ChainedMap instance +batch(handler) +``` + +```js +// Conditionally execute a function to continue configuration +// condition: Boolean +// whenTruthy: Function -> ChainedMap + // invoked when condition is truthy, given a single argument of the ChainedMap instance +// whenFalsy: Optional Function -> ChainedMap + // invoked when condition is falsy, given a single argument of the ChainedMap instance +when(condition, whenTruthy, whenFalsy) +``` + +## ChainedSet + +Another of the core API interfaces in webpack-chain is a `ChainedSet`. A +`ChainedSet` operates similar to a JavaScript Set, with some conveniences for +chaining and generating configuration. If a property is marked as being a +`ChainedSet`, it will have an API and methods as described below: + +**Unless stated otherwise, these methods will return the `ChainedSet`, allowing +you to chain these methods.** + +```js +// Add/append a value to the end of a Set. +// value: * +add(value) +``` + +```js +// Add a value to the beginning of a Set. +// value: * +prepend(value) +``` + +```js +// Remove all values from a Set. +clear() +``` + +```js +// Remove a specific value from a Set. +// value: * +delete(value) +``` + +```js +// Returns `true` or `false` based on whether or not the +// backing Set contains the specified value. +// value: * +// returns: Boolean +has(value) +``` + +```js +// Returns an array of values contained in the backing Set. +// returns: Array +values() +``` + +```js +// Concatenates the given array to the end of the backing Set. +// arr: Array +merge(arr) +``` + +```js +// Execute a function against the current configuration context +// handler: Function -> ChainedSet + // A function which is given a single argument of the ChainedSet instance +batch(handler) +``` + +```js +// Conditionally execute a function to continue configuration +// condition: Boolean +// whenTruthy: Function -> ChainedSet + // invoked when condition is truthy, given a single argument of the ChainedSet instance +// whenFalsy: Optional Function -> ChainedSet + // invoked when condition is falsy, given a single argument of the ChainedSet instance +when(condition, whenTruthy, whenFalsy) +``` + +## Shorthand methods + +A number of shorthand methods exist for setting a value on a `ChainedMap` +with the same key as the shorthand method name. +For example, `devServer.hot` is a shorthand method, so it can be used as: + +```js +// A shorthand method for setting a value on a ChainedMap +devServer.hot(true); + +// This would be equivalent to: +devServer.set('hot', true); +``` + +A shorthand method is chainable, so calling it will return the original +instance, allowing you to continue to chain. + +### Config + +Create a new configuration object. + +```js +const Config = require('webpack-chain'); + +const config = new Config(); +``` + +Moving to deeper points in the API will change the context of what you +are modifying. You can move back to the higher context by either referencing +the top-level `config` again, or by calling `.end()` to move up one level. +If you are familiar with jQuery, `.end()` works similarly. All API calls +will return the API instance at the current context unless otherwise +specified. This is so you may chain API calls continuously if desired. + +For details on the specific values that are valid for all shorthand and +low-level methods, please refer to their corresponding name in the +[webpack docs hierarchy](https://webpack.js.org/configuration/). + +```js +Config : ChainedMap +``` + +#### Config shorthand methods + +```js +config + .amd(amd) + .bail(bail) + .cache(cache) + .devtool(devtool) + .context(context) + .externals(externals) + .loader(loader) + .mode(mode) + .parallelism(parallelism) + .profile(profile) + .recordsPath(recordsPath) + .recordsInputPath(recordsInputPath) + .recordsOutputPath(recordsOutputPath) + .stats(stats) + .target(target) + .watch(watch) + .watchOptions(watchOptions) +``` + +#### Config entryPoints + +```js +// Backed at config.entryPoints : ChainedMap +config.entry(name) : ChainedSet + +config + .entry(name) + .add(value) + .add(value) + +config + .entry(name) + .clear() + +// Using low-level config.entryPoints: + +config.entryPoints + .get(name) + .add(value) + .add(value) + +config.entryPoints + .get(name) + .clear() +``` + +#### Config output: shorthand methods + +```js +config.output : ChainedMap + +config.output + .auxiliaryComment(auxiliaryComment) + .chunkFilename(chunkFilename) + .chunkLoadTimeout(chunkLoadTimeout) + .crossOriginLoading(crossOriginLoading) + .devtoolFallbackModuleFilenameTemplate(devtoolFallbackModuleFilenameTemplate) + .devtoolLineToLine(devtoolLineToLine) + .devtoolModuleFilenameTemplate(devtoolModuleFilenameTemplate) + .filename(filename) + .hashFunction(hashFunction) + .hashDigest(hashDigest) + .hashDigestLength(hashDigestLength) + .hashSalt(hashSalt) + .hotUpdateChunkFilename(hotUpdateChunkFilename) + .hotUpdateFunction(hotUpdateFunction) + .hotUpdateMainFilename(hotUpdateMainFilename) + .jsonpFunction(jsonpFunction) + .library(library) + .libraryExport(libraryExport) + .libraryTarget(libraryTarget) + .path(path) + .pathinfo(pathinfo) + .publicPath(publicPath) + .sourceMapFilename(sourceMapFilename) + .sourcePrefix(sourcePrefix) + .strictModuleExceptionHandling(strictModuleExceptionHandling) + .umdNamedDefine(umdNamedDefine) +``` + +#### Config resolve: shorthand methods + +```js +config.resolve : ChainedMap + +config.resolve + .cachePredicate(cachePredicate) + .cacheWithContext(cacheWithContext) + .enforceExtension(enforceExtension) + .enforceModuleExtension(enforceModuleExtension) + .unsafeCache(unsafeCache) + .symlinks(symlinks) +``` + +#### Config resolve alias + +```js +config.resolve.alias : ChainedMap + +config.resolve.alias + .set(key, value) + .set(key, value) + .delete(key) + .clear() +``` + +#### Config resolve modules + +```js +config.resolve.modules : ChainedSet + +config.resolve.modules + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolve aliasFields + +```js +config.resolve.aliasFields : ChainedSet + +config.resolve.aliasFields + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolve descriptionFields + +```js +config.resolve.descriptionFields : ChainedSet + +config.resolve.descriptionFields + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolve extensions + +```js +config.resolve.extensions : ChainedSet + +config.resolve.extensions + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolve mainFields + +```js +config.resolve.mainFields : ChainedSet + +config.resolve.mainFields + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolve mainFiles + +```js +config.resolve.mainFiles : ChainedSet + +config.resolve.mainFiles + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolveLoader + +The API for `config.resolveLoader` is identical to `config.resolve` with +the following additions: + +#### Config resolveLoader moduleExtensions + +```js +config.resolveLoader.moduleExtensions : ChainedSet + +config.resolveLoader.moduleExtensions + .add(value) + .prepend(value) + .clear() +``` + +#### Config resolveLoader packageMains + +```js +config.resolveLoader.packageMains : ChainedSet + +config.resolveLoader.packageMains + .add(value) + .prepend(value) + .clear() +``` + +#### Config performance: shorthand methods + +```js +config.performance : ChainedMap + +config.performance + .hints(hints) + .maxEntrypointSize(maxEntrypointSize) + .maxAssetSize(maxAssetSize) + .assetFilter(assetFilter) +``` + +#### Configuring optimizations: shorthand methods + +```js +config.optimization : ChainedMap + +config.optimization + .concatenateModules(concatenateModules) + .flagIncludedChunks(flagIncludedChunks) + .mergeDuplicateChunks(mergeDuplicateChunks) + .minimize(minimize) + .minimizer(minimizer) + .namedChunks(namedChunks) + .namedModules(namedModules) + .nodeEnv(nodeEnv) + .noEmitOnErrors(noEmitOnErrors) + .occurrenceOrder(occurrenceOrder) + .portableRecords(portableRecords) + .providedExports(providedExports) + .removeAvailableModules(removeAvailableModules) + .removeEmptyChunks(removeEmptyChunks) + .runtimeChunk(runtimeChunk) + .sideEffects(sideEffects) + .splitChunks(splitChunks) + .usedExports(usedExports) +``` + +#### Config plugins + +```js +// Backed at config.plugins +config.plugin(name) : ChainedMap +``` + +#### Config plugins: adding + +_NOTE: Do not use `new` to create the plugin, as this will be done for you._ + +```js +config + .plugin(name) + .use(WebpackPlugin, args) + +// Examples + +config + .plugin('hot') + .use(webpack.HotModuleReplacementPlugin); + +// Plugins can also be specified by their path, allowing the expensive require()s to be +// skipped in cases where the plugin or webpack configuration won't end up being used. +config + .plugin('env') + .use(require.resolve('webpack/lib/EnvironmentPlugin'), [{ 'VAR': false }]); +``` + +#### Config plugins: modify arguments + +```js +config + .plugin(name) + .tap(args => newArgs) + +// Example +config + .plugin('env') + .tap(args => [...args, 'SECRET_KEY']); +``` + +#### Config plugins: modify instantiation + +```js +config + .plugin(name) + .init((Plugin, args) => new Plugin(...args)); +``` + +#### Config plugins: removing + +```js +config.plugins.delete(name) +``` + +#### Config plugins: ordering before + +Specify that the current `plugin` context should operate before another named +`plugin`. You cannot use both `.before()` and `.after()` on the same plugin. + +```js +config + .plugin(name) + .before(otherName) + +// Example + +config + .plugin('html-template') + .use(HtmlWebpackTemplate) + .end() + .plugin('script-ext') + .use(ScriptExtWebpackPlugin) + .before('html-template'); +``` + +#### Config plugins: ordering after + +Specify that the current `plugin` context should operate after another named +`plugin`. You cannot use both `.before()` and `.after()` on the same plugin. + +```js +config + .plugin(name) + .after(otherName) + +// Example + +config + .plugin('html-template') + .after('script-ext') + .use(HtmlWebpackTemplate) + .end() + .plugin('script-ext') + .use(ScriptExtWebpackPlugin); +``` + +#### Config resolve plugins + +```js +// Backed at config.resolve.plugins +config.resolve.plugin(name) : ChainedMap +``` + +#### Config resolve plugins: adding + +_NOTE: Do not use `new` to create the plugin, as this will be done for you._ + +```js +config.resolve + .plugin(name) + .use(WebpackPlugin, args) +``` + +#### Config resolve plugins: modify arguments + +```js +config.resolve + .plugin(name) + .tap(args => newArgs) +``` + +#### Config resolve plugins: modify instantiation + +```js +config.resolve + .plugin(name) + .init((Plugin, args) => new Plugin(...args)) +``` + +#### Config resolve plugins: removing + +```js +config.resolve.plugins.delete(name) +``` + +#### Config resolve plugins: ordering before + +Specify that the current `plugin` context should operate before another named +`plugin`. You cannot use both `.before()` and `.after()` on the same resolve +plugin. + +```js +config.resolve + .plugin(name) + .before(otherName) + +// Example + +config.resolve + .plugin('beta') + .use(BetaWebpackPlugin) + .end() + .plugin('alpha') + .use(AlphaWebpackPlugin) + .before('beta'); +``` + +#### Config resolve plugins: ordering after + +Specify that the current `plugin` context should operate after another named +`plugin`. You cannot use both `.before()` and `.after()` on the same resolve +plugin. + +```js +config.resolve + .plugin(name) + .after(otherName) + +// Example + +config.resolve + .plugin('beta') + .after('alpha') + .use(BetaWebpackTemplate) + .end() + .plugin('alpha') + .use(AlphaWebpackPlugin); +``` + +#### Config node + +```js +config.node : ChainedMap + +config.node + .set('__dirname', 'mock') + .set('__filename', 'mock'); +``` + +#### Config devServer + +```js +config.devServer : ChainedMap +``` + +#### Config devServer allowedHosts + +```js +config.devServer.allowedHosts : ChainedSet + +config.devServer.allowedHosts + .add(value) + .prepend(value) + .clear() +``` + +#### Config devServer: shorthand methods + +```js +config.devServer + .bonjour(bonjour) + .clientLogLevel(clientLogLevel) + .color(color) + .compress(compress) + .contentBase(contentBase) + .disableHostCheck(disableHostCheck) + .filename(filename) + .headers(headers) + .historyApiFallback(historyApiFallback) + .host(host) + .hot(hot) + .hotOnly(hotOnly) + .https(https) + .inline(inline) + .info(info) + .lazy(lazy) + .noInfo(noInfo) + .open(open) + .openPage(openPage) + .overlay(overlay) + .pfx(pfx) + .pfxPassphrase(pfsPassphrase) + .port(port) + .progress(progress) + .proxy(proxy) + .public(public) + .publicPath(publicPath) + .quiet(quiet) + .setup(setup) + .socket(socket) + .staticOptions(staticOptions) + .stats(stats) + .stdin(stdin) + .useLocalIp(useLocalIp) + .watchContentBase(watchContentBase) + .watchOptions(watchOptions) +``` + +#### Config module + +```js +config.module : ChainedMap +``` + +#### Config module: shorthand methods + +```js +config.module : ChainedMap + +config.module + .noParse(noParse) +``` + +#### Config module rules: shorthand methods + +```js +config.module.rules : ChainedMap + +config.module + .rule(name) + .test(test) + .pre() + .post() + .enforce(preOrPost) +``` + +#### Config module rules uses (loaders): creating + +```js +config.module.rules{}.uses : ChainedMap + +config.module + .rule(name) + .use(name) + .loader(loader) + .options(options) + +// Example + +config.module + .rule('compile') + .use('babel') + .loader('babel-loader') + .options({ presets: ['@babel/preset-env'] }); +``` + +#### Config module rules uses (loaders): modifying options + +```js +config.module + .rule(name) + .use(name) + .tap(options => newOptions) + +// Example + +config.module + .rule('compile') + .use('babel') + .tap(options => merge(options, { + plugins: ['@babel/plugin-proposal-class-properties'] + })); +``` + +#### Config module rules oneOfs (conditional rules): + +```js +config.module.rules{}.oneOfs : ChainedMap<Rule> + +config.module + .rule(name) + .oneOf(name) + +// Example + +config.module + .rule('css') + .oneOf('inline') + .resourceQuery(/inline/) + .use('url') + .loader('url-loader') + .end() + .end() + .oneOf('external') + .resourceQuery(/external/) + .use('file') + .loader('file-loader') +``` + +--- + +### Merging Config + +webpack-chain supports merging in an object to the configuration instance which +matches a layout similar to how the webpack-chain schema is laid out. Note that +this is not a webpack configuration object, but you may transform a webpack +configuration object before providing it to webpack-chain to match its layout. + +```js +config.merge({ devtool: 'source-map' }); + +config.get('devtool') // "source-map" +``` + +```js +config.merge({ + [key]: value, + + amd, + bail, + cache, + context, + devtool, + externals, + loader, + mode, + parallelism, + profile, + recordsPath, + recordsInputPath, + recordsOutputPath, + stats, + target, + watch, + watchOptions, + + entry: { + [name]: [...values] + }, + + plugin: { + [name]: { + plugin: WebpackPlugin, + args: [...args], + before, + after + } + }, + + devServer: { + [key]: value, + + clientLogLevel, + compress, + contentBase, + filename, + headers, + historyApiFallback, + host, + hot, + hotOnly, + https, + inline, + lazy, + noInfo, + overlay, + port, + proxy, + quiet, + setup, + stats, + watchContentBase + }, + + node: { + [key]: value + }, + + optimizations: { + concatenateModules, + flagIncludedChunks, + mergeDuplicateChunks, + minimize, + minimizer, + namedChunks, + namedModules, + nodeEnv, + noEmitOnErrors, + occurrenceOrder, + portableRecords, + providedExports, + removeAvailableModules, + removeEmptyChunks, + runtimeChunk, + sideEffects, + splitChunks, + usedExports, + }, + + performance: { + [key]: value, + + hints, + maxEntrypointSize, + maxAssetSize, + assetFilter + }, + + resolve: { + [key]: value, + + alias: { + [key]: value + }, + aliasFields: [...values], + descriptionFields: [...values], + extensions: [...values], + mainFields: [...values], + mainFiles: [...values], + modules: [...values], + + plugin: { + [name]: { + plugin: WebpackPlugin, + args: [...args], + before, + after + } + } + }, + + resolveLoader: { + [key]: value, + + alias: { + [key]: value + }, + aliasFields: [...values], + descriptionFields: [...values], + extensions: [...values], + mainFields: [...values], + mainFiles: [...values], + modules: [...values], + moduleExtensions: [...values], + packageMains: [...values], + + plugin: { + [name]: { + plugin: WebpackPlugin, + args: [...args], + before, + after + } + } + }, + + module: { + [key]: value, + + rule: { + [name]: { + [key]: value, + + enforce, + issuer, + parser, + resource, + resourceQuery, + test, + + include: [...paths], + exclude: [...paths], + + oneOf: { + [name]: Rule + }, + + use: { + [name]: { + loader: LoaderString, + options: LoaderOptions, + before, + after + } + } + } + } + } +}) +``` + +### Conditional configuration + +When working with instances of `ChainedMap` and `ChainedSet`, you can perform +conditional configuration using `when`. You must specify an expression to +`when()` which will be evaluated for truthiness or falsiness. If the expression +is truthy, the first function argument will be invoked with an instance of the +current chained instance. You can optionally provide a second function to be +invoked when the condition is falsy, which is also given the current chained +instance. + +```js +// Example: Only add minify plugin during production +config + .when(process.env.NODE_ENV === 'production', config => { + config + .plugin('minify') + .use(BabiliWebpackPlugin); + }); +``` + +```js +// Example: Only add minify plugin during production, +// otherwise set devtool to source-map +config + .when(process.env.NODE_ENV === 'production', + config => config.plugin('minify').use(BabiliWebpackPlugin), + config => config.devtool('source-map') + ); +``` + +### Inspecting generated configuration + +You can inspect the generated webpack config using `config.toString()`. This +will generate a stringified version of the config with comment hints for named +rules, uses and plugins: + +``` js +config + .module + .rule('compile') + .test(/\.js$/) + .use('babel') + .loader('babel-loader'); + +config.toString(); + +/* +{ + module: { + rules: [ + /* config.module.rule('compile') */ + { + test: /\.js$/, + use: [ + /* config.module.rule('compile').use('babel') */ + { + loader: 'babel-loader' + } + ] + } + ] + } +} +*/ +``` + +By default the generated string cannot be used directly as real webpack config +if it contains functions and plugins that need to be required. In order to +generate usable config, you can customize how functions and plugins are +stringified by setting a special `__expression` property on them: + +``` js +class MyPlugin {} +MyPlugin.__expression = `require('my-plugin')`; + +function myFunction () {} +myFunction.__expression = `require('my-function')`; + +config + .plugin('example') + .use(MyPlugin, [{ fn: myFunction }]); + +config.toString(); + +/* +{ + plugins: [ + new (require('my-plugin'))({ + fn: require('my-function') + }) + ] +} +*/ +``` + +Plugins specified via their path will have their `require()` statement generated +automatically: + +``` js +config + .plugin('env') + .use(require.resolve('webpack/lib/ProvidePlugin'), [{ jQuery: 'jquery' }]) + +config.toString(); + +/* +{ + plugins: [ + new (require('/foo/bar/src/node_modules/webpack/lib/EnvironmentPlugin.js'))( + { + jQuery: 'jquery' + } + ) + ] +} +*/ +``` + +You can also call `toString` as a static method on `Config` in order to +modify the configuration object prior to stringifying. + +```js +Config.toString({ + ...config.toConfig(), + module: { + defaultRules: [ + { + use: [ + { + loader: 'banner-loader', + options: { prefix: 'banner-prefix.txt' }, + }, + ], + }, + ], + }, +}) + +/* +{ + plugins: [ + /* config.plugin('foo') */ + new TestPlugin() + ], + module: { + defaultRules: [ + { + use: [ + { + loader: 'banner-loader', + options: { + prefix: 'banner-prefix.txt' + } + } + ] + } + ] + } +} +*/ +``` diff --git a/node_modules/webpack-chain/package.json b/node_modules/webpack-chain/package.json new file mode 100644 index 00000000..f2f10dd9 --- /dev/null +++ b/node_modules/webpack-chain/package.json @@ -0,0 +1,40 @@ +{ + "name": "webpack-chain", + "version": "4.12.1", + "main": "src/Config.js", + "repository": "neutrinojs/webpack-chain", + "keywords": [ + "webpack", + "config", + "chain", + "fluent", + "api" + ], + "files": [ + "src" + ], + "author": "Eli Perelman <eli@eliperelman.com>", + "license": "MPL-2.0", + "scripts": { + "test": "ava test", + "lint": "eslint --cache --report-unused-disable-directives --format codeframe \".*.js\" src test", + "changelog": "auto-changelog --remote upstream --commit-limit false", + "version": "yarn changelog --package && git add CHANGELOG.md" + }, + "dependencies": { + "deepmerge": "^1.5.2", + "javascript-stringify": "^1.6.0" + }, + "devDependencies": { + "auto-changelog": "^1.8.0", + "ava": "^0.25.0", + "eslint": "^5.6.1", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-config-prettier": "^3.1.0", + "eslint-plugin-ava": "^5.1.1", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-prettier": "^3.0.0", + "prettier": "^1.14.3", + "webpack": "^4.20.2" + } +} diff --git a/node_modules/webpack-chain/src/Chainable.js b/node_modules/webpack-chain/src/Chainable.js new file mode 100644 index 00000000..f5704ae4 --- /dev/null +++ b/node_modules/webpack-chain/src/Chainable.js @@ -0,0 +1,14 @@ +module.exports = class { + constructor(parent) { + this.parent = parent; + } + + batch(handler) { + handler(this); + return this; + } + + end() { + return this.parent; + } +}; diff --git a/node_modules/webpack-chain/src/ChainedMap.js b/node_modules/webpack-chain/src/ChainedMap.js new file mode 100644 index 00000000..d7dff756 --- /dev/null +++ b/node_modules/webpack-chain/src/ChainedMap.js @@ -0,0 +1,151 @@ +const merge = require('deepmerge'); +const Chainable = require('./Chainable'); + +module.exports = class extends Chainable { + constructor(parent) { + super(parent); + this.store = new Map(); + } + + extend(methods) { + this.shorthands = methods; + methods.forEach(method => { + this[method] = value => this.set(method, value); + }); + return this; + } + + clear() { + this.store.clear(); + return this; + } + + delete(key) { + this.store.delete(key); + return this; + } + + order() { + const entries = [...this.store].reduce((acc, [key, value]) => { + acc[key] = value; + return acc; + }, {}); + const names = Object.keys(entries); + const order = [...names]; + + names.forEach(name => { + if (!entries[name]) { + return; + } + + const { __before, __after } = entries[name]; + + if (__before && order.includes(__before)) { + order.splice(order.indexOf(name), 1); + order.splice(order.indexOf(__before), 0, name); + } else if (__after && order.includes(__after)) { + order.splice(order.indexOf(name), 1); + order.splice(order.indexOf(__after) + 1, 0, name); + } + }); + + return { entries, order }; + } + + entries() { + const { entries, order } = this.order(); + + if (order.length) { + return entries; + } + + return undefined; + } + + values() { + const { entries, order } = this.order(); + + return order.map(name => entries[name]); + } + + get(key) { + return this.store.get(key); + } + + getOrCompute(key, fn) { + if (!this.has(key)) { + this.set(key, fn()); + } + return this.get(key); + } + + has(key) { + return this.store.has(key); + } + + set(key, value) { + this.store.set(key, value); + return this; + } + + merge(obj, omit = []) { + Object.keys(obj).forEach(key => { + if (omit.includes(key)) { + return; + } + + const value = obj[key]; + + if ( + (!Array.isArray(value) && typeof value !== 'object') || + value === null || + !this.has(key) + ) { + this.set(key, value); + } else { + this.set(key, merge(this.get(key), value)); + } + }); + + return this; + } + + clean(obj) { + return Object.keys(obj).reduce((acc, key) => { + const value = obj[key]; + + if (value === undefined) { + return acc; + } + + if (Array.isArray(value) && !value.length) { + return acc; + } + + if ( + Object.prototype.toString.call(value) === '[object Object]' && + !Object.keys(value).length + ) { + return acc; + } + + acc[key] = value; + + return acc; + }, {}); + } + + when( + condition, + whenTruthy = Function.prototype, + whenFalsy = Function.prototype + ) { + if (condition) { + whenTruthy(this); + } else { + whenFalsy(this); + } + + return this; + } +}; diff --git a/node_modules/webpack-chain/src/ChainedSet.js b/node_modules/webpack-chain/src/ChainedSet.js new file mode 100644 index 00000000..ea469daa --- /dev/null +++ b/node_modules/webpack-chain/src/ChainedSet.js @@ -0,0 +1,55 @@ +const Chainable = require('./Chainable'); + +module.exports = class extends Chainable { + constructor(parent) { + super(parent); + this.store = new Set(); + } + + add(value) { + this.store.add(value); + return this; + } + + prepend(value) { + this.store = new Set([value, ...this.store]); + return this; + } + + clear() { + this.store.clear(); + return this; + } + + delete(value) { + this.store.delete(value); + return this; + } + + values() { + return [...this.store]; + } + + has(value) { + return this.store.has(value); + } + + merge(arr) { + this.store = new Set([...this.store, ...arr]); + return this; + } + + when( + condition, + whenTruthy = Function.prototype, + whenFalsy = Function.prototype + ) { + if (condition) { + whenTruthy(this); + } else { + whenFalsy(this); + } + + return this; + } +}; diff --git a/node_modules/webpack-chain/src/Config.js b/node_modules/webpack-chain/src/Config.js new file mode 100644 index 00000000..39ea6df0 --- /dev/null +++ b/node_modules/webpack-chain/src/Config.js @@ -0,0 +1,176 @@ +const ChainedMap = require('./ChainedMap'); +const ChainedSet = require('./ChainedSet'); +const Resolve = require('./Resolve'); +const ResolveLoader = require('./ResolveLoader'); +const Output = require('./Output'); +const DevServer = require('./DevServer'); +const Plugin = require('./Plugin'); +const Module = require('./Module'); +const Optimization = require('./Optimization'); +const Performance = require('./Performance'); + +module.exports = class extends ChainedMap { + constructor() { + super(); + this.devServer = new DevServer(this); + this.entryPoints = new ChainedMap(this); + this.module = new Module(this); + this.node = new ChainedMap(this); + this.optimization = new Optimization(this); + this.output = new Output(this); + this.performance = new Performance(this); + this.plugins = new ChainedMap(this); + this.resolve = new Resolve(this); + this.resolveLoader = new ResolveLoader(this); + this.extend([ + 'amd', + 'bail', + 'cache', + 'context', + 'devtool', + 'externals', + 'loader', + 'mode', + 'parallelism', + 'profile', + 'recordsInputPath', + 'recordsPath', + 'recordsOutputPath', + 'stats', + 'target', + 'watch', + 'watchOptions', + ]); + } + + static toString(config, { verbose = false, configPrefix = 'config' } = {}) { + // eslint-disable-next-line global-require + const stringify = require('javascript-stringify'); + + return stringify( + config, + (value, indent, stringify) => { + // improve plugin output + if (value && value.__pluginName) { + const prefix = `/* ${configPrefix}.plugin('${ + value.__pluginName + }') */\n`; + const constructorExpression = value.__pluginPath + ? // The path is stringified to ensure special characters are escaped + // (such as the backslashes in Windows-style paths). + `(require(${stringify(value.__pluginPath)}))` + : value.__pluginConstructorName; + + if (constructorExpression) { + // get correct indentation for args by stringifying the args array and + // discarding the square brackets. + const args = stringify(value.__pluginArgs).slice(1, -1); + return `${prefix}new ${constructorExpression}(${args})`; + } + return ( + prefix + + stringify( + value.__pluginArgs && value.__pluginArgs.length + ? { args: value.__pluginArgs } + : {} + ) + ); + } + + // improve rule/use output + if (value && value.__ruleNames) { + const prefix = `/* ${configPrefix}.module.rule('${ + value.__ruleNames[0] + }')${value.__ruleNames + .slice(1) + .map(r => `.oneOf('${r}')`) + .join('')}${ + value.__useName ? `.use('${value.__useName}')` : `` + } */\n`; + return prefix + stringify(value); + } + + // shorten long functions + if (typeof value === 'function') { + if (value.__expression) { + return value.__expression; + } + if (!verbose && value.toString().length > 100) { + return `function () { /* omitted long function */ }`; + } + } + + return stringify(value); + }, + 2 + ); + } + + entry(name) { + return this.entryPoints.getOrCompute(name, () => new ChainedSet(this)); + } + + plugin(name) { + return this.plugins.getOrCompute(name, () => new Plugin(this, name)); + } + + toConfig() { + const entryPoints = this.entryPoints.entries() || {}; + + return this.clean( + Object.assign(this.entries() || {}, { + node: this.node.entries(), + output: this.output.entries(), + resolve: this.resolve.toConfig(), + resolveLoader: this.resolveLoader.toConfig(), + devServer: this.devServer.toConfig(), + module: this.module.toConfig(), + optimization: this.optimization.entries(), + plugins: this.plugins.values().map(plugin => plugin.toConfig()), + performance: this.performance.entries(), + entry: Object.keys(entryPoints).reduce( + (acc, key) => + Object.assign(acc, { [key]: entryPoints[key].values() }), + {} + ), + }) + ); + } + + toString(options) { + return module.exports.toString(this.toConfig(), options); + } + + merge(obj = {}, omit = []) { + const omissions = [ + 'node', + 'output', + 'resolve', + 'resolveLoader', + 'devServer', + 'optimization', + 'performance', + 'module', + ]; + + if (!omit.includes('entry') && 'entry' in obj) { + Object.keys(obj.entry).forEach(name => + this.entry(name).merge([].concat(obj.entry[name])) + ); + } + + if (!omit.includes('plugin') && 'plugin' in obj) { + Object.keys(obj.plugin).forEach(name => + this.plugin(name).merge(obj.plugin[name]) + ); + } + + omissions.forEach(key => { + if (!omit.includes(key) && key in obj) { + this[key].merge(obj[key]); + } + }); + + return super.merge(obj, [...omit, ...omissions, 'entry', 'plugin']); + } +}; diff --git a/node_modules/webpack-chain/src/DevServer.js b/node_modules/webpack-chain/src/DevServer.js new file mode 100644 index 00000000..23c13639 --- /dev/null +++ b/node_modules/webpack-chain/src/DevServer.js @@ -0,0 +1,68 @@ +const ChainedMap = require('./ChainedMap'); +const ChainedSet = require('./ChainedSet'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + + this.allowedHosts = new ChainedSet(this); + + this.extend([ + 'bonjour', + 'clientLogLevel', + 'color', + 'compress', + 'contentBase', + 'disableHostCheck', + 'filename', + 'headers', + 'historyApiFallback', + 'host', + 'hot', + 'hotOnly', + 'https', + 'info', + 'inline', + 'lazy', + 'noInfo', + 'open', + 'openPage', + 'overlay', + 'pfx', + 'pfxPassphrase', + 'port', + 'proxy', + 'progress', + 'public', + 'publicPath', + 'quiet', + 'setup', + 'socket', + 'staticOptions', + 'stats', + 'stdin', + 'useLocalIp', + 'watchContentBase', + 'watchOptions', + ]); + } + + toConfig() { + return this.clean( + Object.assign( + { + allowedHosts: this.allowedHosts.values(), + }, + this.entries() || {} + ) + ); + } + + merge(obj, omit = []) { + if (!omit.includes('allowedHosts') && 'allowedHosts' in obj) { + this.allowedHosts.merge(obj.allowedHosts); + } + + return super.merge(obj, ['allowedHosts']); + } +}; diff --git a/node_modules/webpack-chain/src/Module.js b/node_modules/webpack-chain/src/Module.js new file mode 100644 index 00000000..01993227 --- /dev/null +++ b/node_modules/webpack-chain/src/Module.js @@ -0,0 +1,44 @@ +const ChainedMap = require('./ChainedMap'); +const Rule = require('./Rule'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + this.rules = new ChainedMap(this); + this.defaultRules = new ChainedMap(this); + this.extend(['noParse']); + } + + defaultRule(name) { + return this.defaultRules.getOrCompute(name, () => new Rule(this, name)); + } + + rule(name) { + return this.rules.getOrCompute(name, () => new Rule(this, name)); + } + + toConfig() { + return this.clean( + Object.assign(this.entries() || {}, { + defaultRules: this.defaultRules.values().map(r => r.toConfig()), + rules: this.rules.values().map(r => r.toConfig()), + }) + ); + } + + merge(obj, omit = []) { + if (!omit.includes('rule') && 'rule' in obj) { + Object.keys(obj.rule).forEach(name => + this.rule(name).merge(obj.rule[name]) + ); + } + + if (!omit.includes('defaultRule') && 'defaultRule' in obj) { + Object.keys(obj.defaultRule).forEach(name => + this.defaultRule(name).merge(obj.defaultRule[name]) + ); + } + + return super.merge(obj, ['rule', 'defaultRule']); + } +}; diff --git a/node_modules/webpack-chain/src/Optimization.js b/node_modules/webpack-chain/src/Optimization.js new file mode 100644 index 00000000..cb061f87 --- /dev/null +++ b/node_modules/webpack-chain/src/Optimization.js @@ -0,0 +1,27 @@ +const ChainedMap = require('./ChainedMap'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + this.extend([ + 'concatenateModules', + 'flagIncludedChunks', + 'mergeDuplicateChunks', + 'minimize', + 'minimizer', + 'namedChunks', + 'namedModules', + 'nodeEnv', + 'noEmitOnErrors', + 'occurrenceOrder', + 'portableRecords', + 'providedExports', + 'removeAvailableModules', + 'removeEmptyChunks', + 'runtimeChunk', + 'sideEffects', + 'splitChunks', + 'usedExports', + ]); + } +}; diff --git a/node_modules/webpack-chain/src/Orderable.js b/node_modules/webpack-chain/src/Orderable.js new file mode 100644 index 00000000..abb8a079 --- /dev/null +++ b/node_modules/webpack-chain/src/Orderable.js @@ -0,0 +1,40 @@ +module.exports = Class => + class extends Class { + before(name) { + if (this.__after) { + throw new Error( + `Unable to set .before(${JSON.stringify( + name + )}) with existing value for .after()` + ); + } + + this.__before = name; + return this; + } + + after(name) { + if (this.__before) { + throw new Error( + `Unable to set .after(${JSON.stringify( + name + )}) with existing value for .before()` + ); + } + + this.__after = name; + return this; + } + + merge(obj, omit = []) { + if (obj.before) { + this.before(obj.before); + } + + if (obj.after) { + this.after(obj.after); + } + + return super.merge(obj, [...omit, 'before', 'after']); + } + }; diff --git a/node_modules/webpack-chain/src/Output.js b/node_modules/webpack-chain/src/Output.js new file mode 100644 index 00000000..296c3674 --- /dev/null +++ b/node_modules/webpack-chain/src/Output.js @@ -0,0 +1,39 @@ +const ChainedMap = require('./ChainedMap'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + this.extend([ + 'auxiliaryComment', + 'chunkCallbackName', + 'chunkFilename', + 'chunkLoadTimeout', + 'crossOriginLoading', + 'devtoolFallbackModuleFilenameTemplate', + 'devtoolLineToLine', + 'devtoolModuleFilenameTemplate', + 'devtoolNamespace', + 'filename', + 'globalObject', + 'hashDigest', + 'hashDigestLength', + 'hashFunction', + 'hashSalt', + 'hotUpdateChunkFilename', + 'hotUpdateFunction', + 'hotUpdateMainFilename', + 'jsonpFunction', + 'library', + 'libraryExport', + 'libraryTarget', + 'path', + 'pathinfo', + 'publicPath', + 'sourceMapFilename', + 'sourcePrefix', + 'strictModuleExceptionHandling', + 'umdNamedDefine', + 'webassemblyModuleFilename', + ]); + } +}; diff --git a/node_modules/webpack-chain/src/Performance.js b/node_modules/webpack-chain/src/Performance.js new file mode 100644 index 00000000..79c23fa8 --- /dev/null +++ b/node_modules/webpack-chain/src/Performance.js @@ -0,0 +1,8 @@ +const ChainedMap = require('./ChainedMap'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + this.extend(['assetFilter', 'hints', 'maxAssetSize', 'maxEntrypointSize']); + } +}; diff --git a/node_modules/webpack-chain/src/Plugin.js b/node_modules/webpack-chain/src/Plugin.js new file mode 100644 index 00000000..418b32d4 --- /dev/null +++ b/node_modules/webpack-chain/src/Plugin.js @@ -0,0 +1,71 @@ +const ChainedMap = require('./ChainedMap'); +const Orderable = require('./Orderable'); + +module.exports = Orderable( + class extends ChainedMap { + constructor(parent, name) { + super(parent); + this.name = name; + this.extend(['init']); + + this.init((Plugin, args = []) => { + if (typeof Plugin === 'function') { + return new Plugin(...args); + } + return Plugin; + }); + } + + use(plugin, args = []) { + return this.set('plugin', plugin).set('args', args); + } + + tap(f) { + this.set('args', f(this.get('args') || [])); + return this; + } + + merge(obj, omit = []) { + if ('plugin' in obj) { + this.set('plugin', obj.plugin); + } + + if ('args' in obj) { + this.set('args', obj.args); + } + + return super.merge(obj, [...omit, 'args', 'plugin']); + } + + toConfig() { + const init = this.get('init'); + let plugin = this.get('plugin'); + const args = this.get('args'); + let pluginPath = null; + + // Support using the path to a plugin rather than the plugin itself, + // allowing expensive require()s to be skipped in cases where the plugin + // or webpack configuration won't end up being used. + if (typeof plugin === 'string') { + pluginPath = plugin; + // eslint-disable-next-line global-require, import/no-dynamic-require + plugin = require(pluginPath); + } + + const constructorName = plugin.__expression + ? `(${plugin.__expression})` + : plugin.name; + + const config = init(plugin, args); + + Object.defineProperties(config, { + __pluginName: { value: this.name }, + __pluginArgs: { value: args }, + __pluginConstructorName: { value: constructorName }, + __pluginPath: { value: pluginPath }, + }); + + return config; + } + } +); diff --git a/node_modules/webpack-chain/src/Resolve.js b/node_modules/webpack-chain/src/Resolve.js new file mode 100644 index 00000000..48360714 --- /dev/null +++ b/node_modules/webpack-chain/src/Resolve.js @@ -0,0 +1,71 @@ +const ChainedMap = require('./ChainedMap'); +const ChainedSet = require('./ChainedSet'); +const Plugin = require('./Plugin'); + +module.exports = class extends ChainedMap { + constructor(parent) { + super(parent); + this.alias = new ChainedMap(this); + this.aliasFields = new ChainedSet(this); + this.descriptionFiles = new ChainedSet(this); + this.extensions = new ChainedSet(this); + this.mainFields = new ChainedSet(this); + this.mainFiles = new ChainedSet(this); + this.modules = new ChainedSet(this); + this.plugins = new ChainedMap(this); + this.extend([ + 'cachePredicate', + 'cacheWithContext', + 'concord', + 'enforceExtension', + 'enforceModuleExtension', + 'symlinks', + 'unsafeCache', + ]); + } + + plugin(name) { + return this.plugins.getOrCompute(name, () => new Plugin(this, name)); + } + + toConfig() { + return this.clean( + Object.assign(this.entries() || {}, { + alias: this.alias.entries(), + aliasFields: this.aliasFields.values(), + descriptionFiles: this.descriptionFiles.values(), + extensions: this.extensions.values(), + mainFields: this.mainFields.values(), + mainFiles: this.mainFiles.values(), + modules: this.modules.values(), + plugins: this.plugins.values().map(plugin => plugin.toConfig()), + }) + ); + } + + merge(obj, omit = []) { + const omissions = [ + 'alias', + 'aliasFields', + 'descriptionFiles', + 'extensions', + 'mainFields', + 'mainFiles', + 'modules', + ]; + + if (!omit.includes('plugin') && 'plugin' in obj) { + Object.keys(obj.plugin).forEach(name => + this.plugin(name).merge(obj.plugin[name]) + ); + } + + omissions.forEach(key => { + if (!omit.includes(key) && key in obj) { + this[key].merge(obj[key]); + } + }); + + return super.merge(obj, [...omit, ...omissions, 'plugin']); + } +}; diff --git a/node_modules/webpack-chain/src/ResolveLoader.js b/node_modules/webpack-chain/src/ResolveLoader.js new file mode 100644 index 00000000..e1491a38 --- /dev/null +++ b/node_modules/webpack-chain/src/ResolveLoader.js @@ -0,0 +1,34 @@ +const Resolve = require('./Resolve'); +const ChainedSet = require('./ChainedSet'); + +module.exports = class extends Resolve { + constructor(parent) { + super(parent); + this.moduleExtensions = new ChainedSet(this); + this.packageMains = new ChainedSet(this); + } + + toConfig() { + return this.clean( + Object.assign( + { + moduleExtensions: this.moduleExtensions.values(), + packageMains: this.packageMains.values(), + }, + super.toConfig() + ) + ); + } + + merge(obj, omit = []) { + const omissions = ['moduleExtensions', 'packageMains']; + + omissions.forEach(key => { + if (!omit.includes(key) && key in obj) { + this[key].merge(obj[key]); + } + }); + + return super.merge(obj, [...omit, ...omissions]); + } +}; diff --git a/node_modules/webpack-chain/src/Rule.js b/node_modules/webpack-chain/src/Rule.js new file mode 100644 index 00000000..45e16955 --- /dev/null +++ b/node_modules/webpack-chain/src/Rule.js @@ -0,0 +1,98 @@ +const ChainedMap = require('./ChainedMap'); +const ChainedSet = require('./ChainedSet'); +const Use = require('./Use'); + +module.exports = class Rule extends ChainedMap { + constructor(parent, name) { + super(parent); + this.name = name; + this.names = []; + + let rule = this; + while (rule instanceof Rule) { + this.names.unshift(rule.name); + rule = rule.parent; + } + + this.uses = new ChainedMap(this); + this.include = new ChainedSet(this); + this.exclude = new ChainedSet(this); + this.oneOfs = new ChainedMap(this); + this.extend([ + 'enforce', + 'issuer', + 'parser', + 'resource', + 'resourceQuery', + 'sideEffects', + 'test', + 'type', + ]); + } + + use(name) { + return this.uses.getOrCompute(name, () => new Use(this, name)); + } + + oneOf(name) { + return this.oneOfs.getOrCompute(name, () => new Rule(this, name)); + } + + pre() { + return this.enforce('pre'); + } + + post() { + return this.enforce('post'); + } + + toConfig() { + const config = this.clean( + Object.assign(this.entries() || {}, { + include: this.include.values(), + exclude: this.exclude.values(), + oneOf: this.oneOfs.values().map(oneOf => oneOf.toConfig()), + use: this.uses.values().map(use => use.toConfig()), + }) + ); + + Object.defineProperties(config, { + __ruleNames: { value: this.names }, + }); + + return config; + } + + merge(obj, omit = []) { + if (!omit.includes('include') && 'include' in obj) { + this.include.merge(obj.include); + } + + if (!omit.includes('exclude') && 'exclude' in obj) { + this.exclude.merge(obj.exclude); + } + + if (!omit.includes('use') && 'use' in obj) { + Object.keys(obj.use).forEach(name => this.use(name).merge(obj.use[name])); + } + + if (!omit.includes('oneOf') && 'oneOf' in obj) { + Object.keys(obj.oneOf).forEach(name => + this.oneOf(name).merge(obj.oneOf[name]) + ); + } + + if (!omit.includes('test') && 'test' in obj) { + this.test(obj.test instanceof RegExp ? obj.test : new RegExp(obj.test)); + } + + return super.merge(obj, [ + ...omit, + 'include', + 'exclude', + 'use', + 'oneOf', + 'test', + ]); + } +}; diff --git a/node_modules/webpack-chain/src/Use.js b/node_modules/webpack-chain/src/Use.js new file mode 100644 index 00000000..8ab3078e --- /dev/null +++ b/node_modules/webpack-chain/src/Use.js @@ -0,0 +1,41 @@ +const merge = require('deepmerge'); +const ChainedMap = require('./ChainedMap'); +const Orderable = require('./Orderable'); + +module.exports = Orderable( + class extends ChainedMap { + constructor(parent, name) { + super(parent); + this.name = name; + this.extend(['loader', 'options']); + } + + tap(f) { + this.options(f(this.get('options'))); + return this; + } + + merge(obj, omit = []) { + if (!omit.includes('loader') && 'loader' in obj) { + this.loader(obj.loader); + } + + if (!omit.includes('options') && 'options' in obj) { + this.options(merge(this.store.get('options') || {}, obj.options)); + } + + return super.merge(obj, [...omit, 'loader', 'options']); + } + + toConfig() { + const config = this.clean(this.entries() || {}); + + Object.defineProperties(config, { + __useName: { value: this.name }, + __ruleNames: { value: this.parent && this.parent.names }, + }); + + return config; + } + } +); |
