-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add invalidate endpoint #2493
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ const { join } = require('path'); | |
|
||
const clientBasePath = join(__dirname, '..', '..', 'client'); | ||
|
||
function routes(app, middleware, options) { | ||
function routes(server) { | ||
const app = server.app; | ||
const middleware = server.middleware; | ||
const options = server.options; | ||
|
||
app.get('/__webpack_dev_server__/live.bundle.js', (req, res) => { | ||
res.setHeader('Content-Type', 'application/javascript'); | ||
|
||
|
@@ -30,6 +34,11 @@ function routes(app, middleware, options) { | |
createReadStream(join(clientBasePath, 'live.html')).pipe(res); | ||
}); | ||
|
||
app.get('/invalidate', (_req, res) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should better be prefixed with |
||
server.invalidate(); | ||
res.end(); | ||
}); | ||
|
||
app.get('/webpack-dev-server', (req, res) => { | ||
res.setHeader('Content-Type', 'text/html'); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,10 @@ describe('routes util', () => { | |
}); | ||
}); | ||
|
||
it('GET request to invalidate endpoint', (done) => { | ||
req.get('/invalidate').expect(200, done); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be great to test what we really do invalidate - get stats before do request and do get stats again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't detect any changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange, should be no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've thought about an Idea maybe we can create an option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad idea, maybe we need fix something in tests, need debug |
||
|
||
it('should handles GET request to live html', (done) => { | ||
req.get('/webpack-dev-server/').then(({ res }) => { | ||
expect(res.headers['content-type']).toEqual('text/html'); | ||
|
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.
Why did you change this?
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.
@hiroppy To pass the server, so I can call server.invalidate()
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'm -1 on this change because if you pass
this
, we can't understand what variables are used by this function clearly.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.
@hiroppy I tried
(this.app, this.middleware, this.options, this.invalidate)
and calledinvalidate()
only but this resulted in500 "Internal Server Error"
so what about changingthis
intoserver
for better reading ex: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.
one thing that worked was moving
to
routes.js
and make it only accessable via the api call, but that would require adding an optioninvalidateCallBack
so we can pass it ex:and in
routes.js