Repository: parcel-bundler/parcel
Pull request #5269 (2020-10-22 11:26:18)

Upgrade http-proxy-middleware to ^1.0.0
<!---
Thanks for filing a pull request 😄 ! Before you submit, please read the following:

Search open/closed issues before submitting since someone might have pushed the same thing before!
-->

# ↪️ Pull Request

Definitive fix to [website#750](https://github.com/parcel-bundler/website/pull/750)

## 💻 Examples

The documentation at v2.parceljs.org is up to date, but the dependency was not. Nothing else needs to change.

## 🚨 Test instructions

Just use an API proxy as per the docs, but remember to import with brackets.

## ✔️ PR Todo

- [x] Added/updated unit tests for this change
- [x] Filled out test instructions (In case there aren't any unit tests)
- [x] Included links to related issues/PRs


height[bot]: > Link [Height](https://parcel.height.app) tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.
>
> 💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.
<!-- Sent by Height -->

Patch:
diff --git a/packages/reporters/dev-server/package.json b/packages/reporters/dev-server/package.json
index e92ac562c..585fc206d 100644
--- a/packages/reporters/dev-server/package.json
+++ b/packages/reporters/dev-server/package.json
@@ -26,7 +26,7 @@
     "serve-handler": "^6.0.0",
     "connect": "^3.7.0",
     "ejs": "^2.6.1",
-    "http-proxy-middleware": "^0.19.1",
+    "http-proxy-middleware": "^1.0.0",
     "nullthrows": "^1.1.1",
     "ws": "^6.2.0"
   },
diff --git a/packages/reporters/dev-server/src/Server.js b/packages/reporters/dev-server/src/Server.js
index 1512c57a4..03155e28e 100644
--- a/packages/reporters/dev-server/src/Server.js
+++ b/packages/reporters/dev-server/src/Server.js
@@ -27,7 +27,7 @@ import fs from 'fs';
 import ejs from 'ejs';
 import connect from 'connect';
 import serveHandler from 'serve-handler';
-import httpProxyMiddleware from 'http-proxy-middleware';
+import {createProxyMiddleware} from 'http-proxy-middleware';
 import {URL} from 'url';
 
 function setHeaders(res: Response) {
@@ -337,7 +337,7 @@ export default class Server extends EventEmitter {
       }
       for (const [context, options] of Object.entries(cfg)) {
         // each key is interpreted as context, and value as middleware options
-        app.use(httpProxyMiddleware(context, options));
+        app.use(createProxyMiddleware(context, options));
       }
     }
 
diff --git a/yarn.lock b/yarn.lock
index e4e6b0e3f..5e9dc2435 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2058,6 +2058,13 @@
     "@types/minimatch" "*"
     "@types/node" "*"
 
+"@types/http-proxy@^1.17.4":
+  version "1.17.4"
+  resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
+  integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==
+  dependencies:
+    "@types/node" "*"
+
 "@types/minimatch@*":
   version "3.0.3"
   resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@@ -7326,20 +7333,21 @@ http-proxy-agent@^2.1.0:
     agent-base "4"
     debug "3.1.0"
 
-http-proxy-middleware@^0.19.1:
-  version "0.19.1"
-  resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-0.19.1.tgz#183c7dc4aa1479150306498c210cdaf96080a43a"
-  integrity sha512-yHYTgWMQO8VvwNS22eLLloAkvungsKdKTLO8AJlftYIKNfJr3GK3zK0ZCfzDDGUBttdGc8xFy1mCitvNKQtC3Q==
+http-proxy-middleware@^1.0.0:
+  version "1.0.6"
+  resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.0.6.tgz#0618557722f450375d3796d701a8ac5407b3b94e"
+  integrity sha512-NyL6ZB6cVni7pl+/IT2W0ni5ME00xR0sN27AQZZrpKn1b+qRh+mLbBxIq9Cq1oGfmTc7BUq4HB77mxwCaxAYNg==
   dependencies:
-    http-proxy "^1.17.0"
-    is-glob "^4.0.0"
-    lodash "^4.17.11"
-    micromatch "^3.1.10"
+    "@types/http-proxy" "^1.17.4"
+    http-proxy "^1.18.1"
+    is-glob "^4.0.1"
+    lodash "^4.17.20"
+    micromatch "^4.0.2"
 
-http-proxy@^1.17.0:
-  version "1.18.0"
-  resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a"
-  integrity sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==
+http-proxy@^1.18.1:
+  version "1.18.1"
+  resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
+  integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==
   dependencies:
     eventemitter3 "^4.0.0"
     follow-redirects "^1.0.0"
@@ -8831,7 +8839,7 @@ lodash@4.17.15:
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
   integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
 
-lodash@^4.16.4, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1:
+lodash@^4.16.4, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1:
   version "4.17.20"
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
   integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==


Test patch:
diff --git a/packages/core/integration-tests/package.json b/packages/core/integration-tests/package.json
index 376c726f4..3836a7c9a 100644
--- a/packages/core/integration-tests/package.json
+++ b/packages/core/integration-tests/package.json
@@ -26,7 +26,7 @@
     "cross-env": "^7.0.0",
     "get-port": "^5.0.0",
     "graphql": "^15.0.0",
-    "http-proxy-middleware": "^0.19.1",
+    "http-proxy-middleware": "^1.0.0",
     "jsdom": "^15.2.1",
     "json5": "^1.0.1",
     "kotlin": "^1.3.11",
diff --git a/packages/core/integration-tests/test/integration/proxyrc-js/.proxyrc.js b/packages/core/integration-tests/test/integration/proxyrc-js/.proxyrc.js
index e32aec03c..18a72c3f4 100644
--- a/packages/core/integration-tests/test/integration/proxyrc-js/.proxyrc.js
+++ b/packages/core/integration-tests/test/integration/proxyrc-js/.proxyrc.js
@@ -1,7 +1,7 @@
-const proxy = require('http-proxy-middleware');
+const {createProxyMiddleware} = require('http-proxy-middleware');
 
 module.exports = function(app) {
-  app.use(proxy('/api', {
+  app.use(createProxyMiddleware('/api', {
     target: 'http://localhost:9753/',
     pathRewrite: {
       '^/api': ''