-
-
Notifications
You must be signed in to change notification settings - Fork 2k
preact/debug #633
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
preact/debug #633
Conversation
|
The |
|
What is the rationale for making each of these warnings configurable? I would be inclined to make the debug package zero or minimally configurable until we have a clear use case, since that reduces the risk of having to make a breaking change in future. |
debug_src/debug.js
Outdated
| arrayChildren: true | ||
| }; | ||
|
|
||
| preact.h = function(nodeName, attributes) { |
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.
Could this be built on Preact's existing options.vnode hook rather than patching h directly? Then it should work for createElement as well. This would also be consistent with how the devtools module works - hooking into Preact's global hooks.
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, but that way you won't get good stack trace, i.e. the call before throwing the error will point directly to the place of h() invocation. If this won't provide good stack traces I'm not really interested in having this package myself.
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 want to check if we can prune the stack trace - we'd know it's 2 levels up, and the stack is just a String so we could remove the first two lines. My reasoning is that preact is actually a frozen object when bundled via Webpack 2 - this is already causing issues with React Ho Loader since it does the patching technique used here, and I'm worried it's going to become an issue. Thoughts?
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.
Stacks aren't that simple. Firefox have weird stack format and you cannot just modify it. There is no docs about the format and people in Mozilla IRC doesn't answer really to that question. There might be some lib by Fx extensions team, but I don't know about it.
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, but that way you won't get good stack trace
Not sure I follow. Surely throwing in the vnode hook would just result in a trace with the point of the h(...) invocation being one more entry up in the stack trace?
robertknight
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.
Couple of initial thoughts:
- Could this be built on the existing global hooks rather than trying to replace exports directly? This would be consistent with how the devtools integration and a number of other debugging/testing aids for Preact work.
- I would be inclined to drop the configurability in the initial release of this unless you have a clear use case for it.
|
@robertknight I for example need only |
@developit suggests to not use This is in addition to that this option is just annoying for myself. |
|
I'm inclined to agree about the keys option, only because I've got codebases that would probably crash the console from the sheer number of warnings that would generate 😇 @NekR one option would be to hold off on releasing the So maybe if we turned off key warnings for now we could release with no options? Still keep it a constructor but have the defaults be to warn both for undefined components and string refs. BTW - I wonder if we need to detect |
As I said in PR comment all debug checks are ON by default :-) Config is there just to disable things.
Makes sense, not sure how to so it though. |
|
I just know the keys warning is something I've complained about in React a lot, I'm kinda tempted to avoid promoting that people go crazy with keys out-of-the-box haha. |
|
@lukeed, @robertknight, @developit fine, fine, I'll do as you all want 😇 |
|
Okay, I did requested changed but didn't test them :-) |
debug.js
Outdated
| @@ -0,0 +1,90 @@ | |||
| 'use strict'; | |||
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.
we should .gitignore the built files here
| return oldVnodeOption.call(this, vnode); | ||
| }; | ||
|
|
||
| const inspectChildren = (children, inspect) => { |
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.
children should always be pre-flattened (though I'm fine leaving this here)
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'll remove that eventually, too lazy right now.
developit
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.
Everything looks good, just thinking we'll want to gitignore the built files. Also it might be nice to bundle to UMD (-f umd) so they run in a browser context too?
|
@developit I did with |
|
Devtools seems to be UMD - https://unpkg.com/preact@8.1.0/devtools.js The preact import gets transformed to a detection, should work nicely. |
|
I mean with folder/generation. You have |
|
True, and that's working (guess that's my answer haha). |
|
I think we're ready to merge this :) |
|
@developit yeah, I think so. But if you wish it to be UMD then I can try that. |
|
Changes Unknown when pulling b0263af on OpenJSX:master into ** on developit:master**. |
|
I merged it |
|
In React, we make warnings only fire once so the console isn't spammed. Might be worth doing it here too :) |
|
For the same element/component or in general write to console once for a each warning? |
|
For each warning usually. Spamming a console is known to have an adverse affect on DX. We had really great feedback when we changed how this worked. |
|
I like that idea. Keeping it global keeps things simple. |
|
I have nothing against it, but I won't have time for it for some time.
Someone may want to create a new issue for it and assign it to me :-)
…On May 29, 2017 3:20 AM, "Jason Miller" ***@***.***> wrote:
I like that idea. Keeping it global keeps things simple.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#633 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABIlkRIgExOFFMma8UEaOiP2V246eISbks5r-g84gaJpZM4M3rkj>
.
|
|
@NekR I see a different and strange behavior of React-dev-tools using Preact/debug. React-dev-tools are active with this config only (as suggested in this PR description), in our project, we are using Preact with React as an alias. |
|
@rupav the redux devtools should work right out of the box as they are not framework dependent. |
|
Forgive me @marvinhagemeister for asking without checking again. I had not configured setup redux-dev-tools on configureStore. Yeah its working great. But what is your opinion on React-dev-tools with Preact/debug? How it can be best utilized. |
|
@rupav easiest way to do it is by including |

preact/debugis here 🎉Usage
To use
preact/debug, you have to setprocess.env.NODE_ENVto'development'for your bundler, e.g. for webpack:Also,
preact/debugimportspreact/devtoolsautomatically 👌Initialization
Basic
Configurable
Config options
(all turned on by default)
undefinedComponents:boolean, throw or not on undefined componentsstringRefs:boolean, throw or not on string refs (this throws anyway, but better track trace with the option)arrayChildren:boolean, warn or not about missingkeyproperties on elements in array childrenWarning example:
Side notes
debug_src/and is transpiled todebug/. Ideally source directory should bedebug/and transpiled todebug.js, but I don't know anyway to do so with requiring only'./debug.js'module in it an ignoring everything else (can be done with browserify but WAT 😨).preact-debug, but there is a problem that webpack makes ES6+ imports getter only so you won't be able to overridepreact.hproperty. If this could be worked around, then probably is the way to go.preact.createElementisn't hooked just yet