-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple node http server for webpack dev #1729
simple node http server for webpack dev #1729
Conversation
Yisheng Jiang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@@ -0,0 +1,80 @@ | |||
/* eslint-disable @typescript-eslint/no-var-requires */ | |||
export {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer needed
@@ -11,6 +12,7 @@ const electrodeServer = optionalRequire("electrode-server"); | |||
const Hapi = optionalRequire("@hapi/hapi"); | |||
const Koa = optionalRequire("koa"); | |||
const express = optionalRequire("express"); | |||
const http = optionalRequire("http"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http
is a built-in module, no need to optionalRequire
it.
also, use import
.
@@ -20,7 +22,21 @@ if (process.env.WEBPACK_DEV === undefined) { | |||
process.env.WEBPACK_DEV = "true"; | |||
} | |||
|
|||
if (fastifyServer) { | |||
if (http) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would always be true.
CI failed, run |
a145f00
to
2176861
Compare
fix eslint errors
use import on http
import { createServer, IncomingMessage, RequestListener, ServerResponse } from "http"; | ||
import * as Url from "url"; | ||
import { resolve } from "path"; | ||
const Middleware = require("./middleware"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think middleware is typed, so you can import it normally
.end(`<!DOCTYPE html>${html}`); | ||
}, | ||
replyError: err => { | ||
res.writeHead(500, err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is res.end() needed?
server.addListener(event.toString(), cb); | ||
}, | ||
stop: () => { | ||
server.close(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is asynchronous, it's a good idea to make this return a promise?
rebased to