-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
[DevTools Bug]: Hook names fail to parse if source file for Component is an html file #22319
Comments
I think the title of this issue might be misleading. (I might be wrong but) I don't think the cause is an inline We could look into how much weight this additional plug-in would add to the bundle, but initially I lean towards saying that should just explicitly not support JSX syntax. Again though, I could be wrong and maybe it really is the inline tag part. 😄 |
@bvaughn so i tested this by making the index.html file only contain a regular and our call to not sure what the best approach would be here, maybe try to extract the JS from script tags if we detect that the source file is an html file? |
The "HTML" you're referring to above is also JSX :) React.createElement('div', {id: 'root'}; // <div id="root" |
we discussed offline and there was confusion about what I was referring to in this issue. I updated the summary to try to clarify the problem. |
For added context, the error I'm seeing in the console is:
This happens before the parsing step. I wonder what has changed since you originally posted this? Digging in further, that's because hookSource: {
columnNumber: 22,
fileName: undefined,
functionName: "ListItem",
lineNumber: 131,
} Looking at the I'm not sure if there's much we can do about this. I'm seeing this same behavior (an undefined |
When testing our fixture in Safari (
./fixtures/devtools/standalone/index.html
) with the standalone build if DevTools, I noticed that we were unable to parse hook names because the source file where the components are defined isn't a JavaScript file, and instead an HTML file (as inindex.html
), which contains HTML code, and some JS inside script tags, so the babel parser fails to parse the file.Specifically:
In the above code, the call to
parse
fails becauseoriginalSourceCode
is actually html (with JS inside) like:And
parse
expects actual JS code.DevTools should handle the case when source files aren't JS files, and still be able to extract out the hook names, or fail more gracefully. As of #22320, we log to the console a slightly better error message when this happens, as opposed to an obscure parsing error.
Repro steps
The text was updated successfully, but these errors were encountered: