-
-
Notifications
You must be signed in to change notification settings - Fork 48
feat: add waitForBuild option #102
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 waitForBuild option #102
Conversation
9687a2a to
04722e1
Compare
04722e1 to
9bbce13
Compare
matheus1lva
left a comment
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.
For what i could see from previous comments on old issues, this can decrease the number of weird errors, specially from websocket side.
Also, don't forget to update the typescript definition file. Almost the same as the joi validation.
9bbce13 to
a071e80
Compare
|
@playma256 thx for review. definitions are updated now. |
|
Great work and thank you for the PR. Please give me some time to consider the verbiage of the option name and documentation. In the mean time, it looks like Node 10 tests are failing, and those need to be resolved. |
a071e80 to
e7d6238
Compare
|
Alright. Tests are passing now. |
|
I'm not quite sure, how to write test to cover bundle rebuilding case. |
You'd have to overwrite a file that's in the bundle to force a rebuild, and then wait for that rebuild to finish. I think we have some tests that do something similar, but if it works for the first build. it's probably going to work for the second, third, etc @sibelius please give this PR a look when you get the chance |
shellscape
left a comment
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.
A few semantic changes I'd like to make.
8c7e965 to
570f855
Compare
570f855 to
a38305e
Compare
|
Ready for final review |
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.
LGTM, thanks for the effort!! 🥂
The coverage error reminds me i have to get home today and merge my tests! LOL
lib/index.js
Outdated
| options.static = []; | ||
| } | ||
|
|
||
| if (options.waitForBuild) { |
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 do we need a done handler here as well as on line 170? is it to catch the first build and then any subsequent builds?
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.
Yes
lib/server.js
Outdated
|
|
||
| if (waitForBuild) { | ||
| app.use(async (ctx, next) => { | ||
| if (!this.compiled) { |
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 the next line is just awaiting a promise, we don't need a logical check here. we can always await the promise. once the promise is resolved, this will pass-through. I'll push this change to your branch.
|
I'm working on a few changes to the PR now. One big problem that strikes me is probably going to be |
| if (this.options.waitForBuild) { | ||
| // track the first build of the bundle | ||
| this.state.compiling = new Promise((resolve) => { | ||
| this.once('done', () => resolve()); |
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.
Can be shortened to this.once('done', resolve);
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.
it could :) in certain situations I like to be a bit more verbose.
| // track subsequent builds from watching | ||
| this.on('invalid', () => { | ||
| this.state.compiling = new Promise((resolve) => { | ||
| this.once('done', () => resolve()); |
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.
same here
This PR contains:
Breaking Changes?
Please Describe Your Changes
This PR adds 'waitForBundleReady' option, which prevents all server middlewares to run until bundle is fully compiled. Same functionality is supported by webpack-dev-middleware via serverSideRender option