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
Watch for changes to html.js #1473
Watch for changes to html.js #1473
Conversation
Deploy preview ready! Built with commit ee15e2c |
Deploy preview ready! Built with commit ee15e2c |
No check out develop-html.js — it only builds one index.html page.
Yeah exactly. Gatsby's entry for development would connect to the dev server and then would refresh when instructed. |
Looking good so far! |
Deploy preview ready! Built with commit ee15e2c |
Deploy preview failed. Built with commit ee15e2c https://app.netlify.com/sites/using-styled-components/deploys/5967ea667960b10804296eb5 |
Deploy preview failed. Built with commit d607b3e81176053c02993fc66685579218834d0e https://app.netlify.com/sites/using-glamor/deploys/5965d5216f4c507bc0303652 |
Deploy preview failed. Built with commit 1c2b4a1101cde779e723007cde9320364fb7206e https://app.netlify.com/sites/using-postcss-sass/deploys/59669e7b424ef23c4ea8996e |
Deploy preview failed. Built with commit d607b3e81176053c02993fc66685579218834d0e https://app.netlify.com/sites/image-processing/deploys/5965d5216f4c507bc030364f |
Deploy preview failed. Built with commit ee15e2c https://app.netlify.com/sites/using-contentful/deploys/5967ea667960b10804296eb8 |
OK. This works end-to-end now. @KyleAMathews, I'm not sure if I put the client code in the right places. Could you review the code please? |
Hah, I guess I still have to add some tests 😉 |
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.
Looks great!
Tests would be fantastic too!
packages/gatsby/src/cache-dir/app.js
Outdated
@@ -8,6 +8,13 @@ window.___emitter = require(`./emitter`) | |||
// Let the site/plugins run code very early. | |||
apiRunner(`onClientEntry`) | |||
|
|||
if (process.env.NODE_ENV === `development`) { |
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 isn't necessary as this file is only used in development.
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.
Ah, good to know. I wasn't sure, but I guess I should have taken a closer look at the webpack config 😁
I've added tests for the |
Wow, getting those windows tests right took longer than it should have 🙄 |
Just tested it, worked perfectly! Slick work! The only change I'd suggest making is to add a console.log when Gatsby starts rebuilding the html.js file so the user knows something is happening and why. |
I'm going to do another minor release now and want this in it so I'll just merge this but please do the above in a follow-up PR. Thanks for taking this on! Hot reload all the things :-) |
Woohoo! Yeah, what you say makes a lot of sense 😀. |
This fails on Windows. Doing a check for filename validity on Windows [is costly](https://github.com/sindresorhus/filename-reserved-regex/blob/master/index.js) and should probably be done by the user but in this case if the file doesn't exists then so does the link. Surrounding this with a `try...catch` solves the issue with no further consequences. This should be solved once [libuv v2.0](https://github.com/libuv/libuv) will be out. Report of the error : ``` fs.js:1103 return binding.unlink(pathModule._makeLong(path)); ^ Error: ENOENT: no such file or directory, unlink 'C:\{your-path}\public\render-page.js' at Error (native) at Object.fs.unlinkSync (fs.js:1103:18) at C:\{your-path}\node_modules\gatsby\dist\utils\develop-html.js:59:30 at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:194:14) at Compiler.emitRecords (C:\{your-path}\node_modules\webpack\lib\Compiler.js:282:37) at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:187:11) at C:\{your-path}\node_modules\webpack\lib\Compiler.js:275:11 at Compiler.applyPluginsAsync (C:\{your-path}\node_modules\tapable\lib\Tapable.js:60:69) at Compiler.afterEmit (C:\{your-path}\node_modules\webpack\lib\Compiler.js:272:8) at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:267:14) at C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:52:16 at done (C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:246:17) at C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:44:16 at C:\{your-path}\node_modules\graceful-fs\graceful-fs.js:43:10 at FSReqWrap.oncomplete (fs.js:123:15) ``` Related to #1473 #1442
This fails on Windows. Doing a check for filename validity on Windows [is costly](https://github.com/sindresorhus/filename-reserved-regex/blob/master/index.js) and should probably be done by the user but in this case if the file doesn't exists then so does the link. Surrounding this with a `try...catch` solves the issue with no further consequences. This should be solved once [libuv v2.0](https://github.com/libuv/libuv) will be out. Report of the error : ``` fs.js:1103 return binding.unlink(pathModule._makeLong(path)); ^ Error: ENOENT: no such file or directory, unlink 'C:\{your-path}\public\render-page.js' at Error (native) at Object.fs.unlinkSync (fs.js:1103:18) at C:\{your-path}\node_modules\gatsby\dist\utils\develop-html.js:59:30 at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:194:14) at Compiler.emitRecords (C:\{your-path}\node_modules\webpack\lib\Compiler.js:282:37) at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:187:11) at C:\{your-path}\node_modules\webpack\lib\Compiler.js:275:11 at Compiler.applyPluginsAsync (C:\{your-path}\node_modules\tapable\lib\Tapable.js:60:69) at Compiler.afterEmit (C:\{your-path}\node_modules\webpack\lib\Compiler.js:272:8) at Compiler.<anonymous> (C:\{your-path}\node_modules\webpack\lib\Compiler.js:267:14) at C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:52:16 at done (C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:246:17) at C:\{your-path}\node_modules\webpack\node_modules\async\lib\async.js:44:16 at C:\{your-path}\node_modules\graceful-fs\graceful-fs.js:43:10 at FSReqWrap.oncomplete (fs.js:123:15) ``` Related to #1473 #1442
Hiya @felixjung! 👋 This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here. Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! 💪💜 |
Thanks a ton @jlengstorf! I had heard about this in various podcasts, but wasn’t expecting it anymore. What a nice surprise. Keep it up! |
Addresses #1442.
@KyleAMathews, I think we can address the configuration via socket support in a separate topic branch?