-
Notifications
You must be signed in to change notification settings - Fork 922
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
Dev server improvements #762
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/btpz1ahx3 |
1733a33
to
691d27b
Compare
691d27b
to
1013f18
Compare
1013f18
to
4cff6bf
Compare
4cff6bf
to
82262df
Compare
82262df
to
7068602
Compare
7068602
to
cbbbcc8
Compare
@@ -275,6 +236,12 @@ export async function command(commandOptions: CommandOptions) { | |||
await updateLockfileHash(DEV_DEPENDENCIES_DIR); | |||
} | |||
|
|||
// Start painting dev dashboard after successful install |
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 annoying thing: we still have a pino
instance in install.ts
, which means any install errors get wiped away when the dev server starts (because it logs to stderr
, not console.error
, so changing that means changing all pino
instances too). We don’t throw an error in install
, currently. And we don’t allow passing a logger in that function.
What should we do here? Should we throw an error in install.ts
? Should we add dev
vs build
logic in install
to handle different logging ability (pino vs messageBus)? Unclear what the simplest way would be to take an install error and pass it to the dev server’s array of logs.
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.
currentlyRunningCommand = null; | ||
}); | ||
} | ||
} |
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 more auto-install on dev! 🎉
if (errors && errors.length > 0) { | ||
console.error(JSON.stringify(errors)); | ||
throw new Error(displayError({error: errors[0], contents, filePath})); |
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 error display for Vue was real bad, so I added one (see screenshots)
Wow! Huge improvement! I'm going to try to pull it down tomorrow and play around with it. How does the proxy output look? Might be nice to have that listed below the main line? |
cbbbcc8
to
bfaa126
Compare
bfaa126
to
78698f0
Compare
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 is already a huge improvement!
I have some basic design feedback of the output, but if it's alright with you I'd love to play around with the PR a bit to test some ideas before making any suggestions.
@@ -95,12 +102,22 @@ async function runPipelineLoadStep( | |||
// if source maps disabled, don’t return any | |||
if (!sourceMaps) result[ext].map = undefined; | |||
}); | |||
if (devMessageBus && isDev) { | |||
devMessageBus.emit('SUCCESS', {id: step.name}); |
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.
already talked through this in person, but this is the bit that isn't really compatible with our current idea of a whole plugin b eing SUCCESS or FAIL.
example 1:
App.svelte
loads in the dev server, has an error, failsIcon.svelte
also loads, succeeds, "SUCCESS" overwrites "ERROR"- End result is no error shown
example 2:
App.svelte
loads in the dev server, has an error, fails- "Svelte" plugin is now in the "error" state
- What does it mean to go back to the "success" state? Do we need to track which files failed, and then only go to "SUCCESS" state when that file succeeds? what if the file is deleted? etc etc
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.
Right. I thought of that convo while doing this, and I agree it’s a bit hacky. But one thing I realized in playing with the dev server we didn’t discuss was it felt “broken” in a sense to show the READY
status if the dev server was running but there was an error and nothing was showing. It felt a lot better to either show READY
or ERROR
based on the state, but to your point this isn’t a perfect implementation.
Maybe we change that READY
status to RUNNING
? Or something else? Or maybe we just take the green color away? Open to a solution where an error is visible and it doesn’t feel like the dev server is “lying” to us telling us everything is good when it’s not.
Seems like the latest batch of changes fixed the issue with it not starting. One thing I noticed which is probably unrelated to these changes, but missing files are a bit annoying. Would still love to see proxy get some love with these changes but I can submit a PR after the fact if you want. Currently, it just logs to console which is now greatly improved to where we can at least see the errors. It would be nice to see something like this (example of Next.js): |
}; | ||
|
||
const MAX_CONSOLE_LENGTH = 500; | ||
const NO_COLOR_ENABLED = process.env.FORCE_COLOR === '0' || process.env.NO_COLOR; |
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 don't know if this is necessary unless we want to support NO_COLOR
which isn't supported by kleur
yet. I opened a PR to address this, lukeed/kleur#37
If we want to support NO_COLOR
before this, we should be able to do colors.$.enabled = !process.env.NO_COLOR && colors.$.enabled
. This should allow all colors.*
calls to do nothing. https://github.com/lukeed/kleur#conditional-support
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.
Just kidding, Luke is on top of it!
https://github.com/lukeed/kleur/releases/tag/v4.1.0
Now we shouldn't need to add anything to support disabling colors.
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.
Nice! Upstream contributions, ftw!
+1 for better proxy output, can take a look at that similar to Next.js Not sure what the service worker issue is but most likely not related to this PR, would love more info if you want to spin up an issue/discussion to debug/triage |
I previously had a service worker registered on that localhost:port, so when I started the app it requested a I just pulled in the latest and ran it again, seems like something changed? Might be an issue with linking? I know at one point it wasn't adding the absolute path Also, just curious if it would make sense to make paths relative to the running directory instead of absolute? For example,
to
since the project is being ran out of |
Lets keep output as is for now, but would be curious to clean up in a follow up PR. I have definitely made mistakes mapping a relative path to an absolute path in my head (when a tool doesn't give you the full absolute path) so I'm sensitive to it as a debugging tool. @stramel I'm confused why the plugin name is that full path in your logs, are you on the latest version of the babel plugin? If updating doesn't fix it, can you share your config file? That's definitely a bug |
It went away after I updated my dependencies. 👍 |
f90f648
to
e16b0ed
Compare
Changes
This improves the dev server logging. Now:
console.*
messages log and keep (even across page loads!)throw
and the output will bubble up to the dev serverERROR
orREADY
, along with error log (error persists even after fix)Screenshots
Default (no errors)
React
Vue
Svelte
Lit Element
How about the status bar at bottom? Any changes needed there?
Testing