webpack-contrib / webpack-hot-middleware

Webpack hot reloading you can attach to your own server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EventSource Polyfill

insin opened this issue · comments

Could you include an EventSource polyfill for IE by default, or recommend one and document how to configure it?

I just got one working, but I had to modify middleware.js:

npm install eventsource-polyfill
  entry: [
    'eventsource-polyfill',
    'webpack-hot-middleware/client',
    './app/index.js'
  ],

Then because the polyfill in question tacks on some query parameters:

--- middleware.js
+++ middleware.js
@@ -26,7 +26,7 @@
     });
   });
   return function(req, res, next) {
-    if (req.url !== opts.path) return next();
+    if (req.path !== opts.path) return next();
     eventStream.handler(req, res);
   };
 }

Yep, happy to do this.

I didn't realise even new IE didn't support EventSource!

As this is mostly a dev tool, I think I'll just pull in a polyfill

Will take a PR, or add something myself soonish.

I've added this in 94da926 - can you confirm it's fixed @insin and i'll cut a release. (Don't have easy access to IE right now)

Released as v2.0.1

Had a few reports of issues with this, so have deprecated v2.0.1 and released v2.0.2 which removes the polyfill (dfb7efb).

I'd like to bring this back in, but need to iron out the kinks

  • Don't rely on req.path - this is an express-only feature. Can use probably use req.uri and substring (#16)
  • Ensure the polyfill works when bundled (#13)
  • Possibly don't include the polyfill, and just add a note to docs?

Not picking a particular polyfill to depend on would save a bunch of hassle in the long run (their bugs become your bugs... and IE-only ones at that 😄).

Documenting the need for one also provides a chance to point out potential bundling gotchas, and again those won't be your bugs, but the user's.

Added a troubleshooting guide that mentions this, and made sure querystring parameters are accepted.

Let me know if you think more is needed.

querystring changes released in v2.2.0