Skip to content
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

replace serve-handler with serve-static #9594

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"mocha-junit-reporter": "^2.0.0",
"mocha-multi-reporters": "^1.5.1",
"prettier": "2.4.1",
"punycode": "^1.4.1",
"rimraf": "^5.0.5",
"semver": "^7.5.2",
"sinon": "^7.3.1"
Expand Down
1 change: 0 additions & 1 deletion packages/reporters/dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"launch-editor": "^2.3.0",
"mime-types": "2.1.18",
"nullthrows": "^1.1.1",
"serve-handler": "^6.0.0",
"ws": "^7.0.0"
}
}
21 changes: 6 additions & 15 deletions packages/reporters/dev-server/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import serverErrors from './serverErrors';
import fs from 'fs';
import ejs from 'ejs';
import connect from 'connect';
import serveHandler from 'serve-handler';
import serveStatic from 'serve-static';
import {createProxyMiddleware} from 'http-proxy-middleware';
import {URL, URLSearchParams} from 'url';
import launchEditor from 'launch-editor';
Expand Down Expand Up @@ -362,20 +362,11 @@ export default class Server {
return;
}

return serveHandler(
req,
res,
{
public: root,
cleanUrls: false,
},
{
lstat: path => fs.stat(path),
realpath: path => fs.realpath(path),
createReadStream: (path, options) => fs.createReadStream(path, options),
readdir: path => fs.readdir(path),
Comment on lines -373 to -376
Copy link
Member

@mischnic mischnic Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to override the FS of server-static? You could use an in-memory FS with Parcel, then it would not work without this

Copy link
Author

@iacore iacore Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Not that I know of.

I thought the fs.* refer to real files.

In-memory FS: /dev/shm/xxxx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parcel has other implementations of the fs interface, such as https://github.com/parcel-bundler/parcel/blob/v2/packages/core/fs/src/MemoryFS.js

That's why the fs parameter exist in that function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, Parcel can fork serve-static (it's small).

https://github.com/expressjs/serve-static/blob/master/index.js

},
);
// Serve up public/ftp folder
const serve = serveStatic(root, {
index: false,
})
return serve(req, res, next);
}

sendError(res: Response, statusCode: number) {
Expand Down
1 change: 0 additions & 1 deletion packages/utils/node-resolver-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.0",
"process": "^0.11.10",
"punycode": "^1.4.1",
"querystring-es3": "^0.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.1.0",
Expand Down
Loading