-
Notifications
You must be signed in to change notification settings - Fork 10.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
JSX in gatsby-browser.js causes error in monorepo #19042
Comments
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
The problem with this issue isn't in Gatsby but in that particular plugin. I've submitted a PR to fix it. Related to #19234 |
Nicely done, @alexlbr ❤️ Closing this for now then! |
I think this issue has come back to life: You can see that
import React from "react"
import { ColorModeScript } from "@chakra-ui/react"
import { WrapRootElement } from "./src/provider"
import theme from "./src/theme"
export const onRenderBody = ({ setPreBodyComponents }) => {
setPreBodyComponents([
<ColorModeScript
initialColorMode={theme.config.initialColorMode}
key="chakra-ui-no-flash"
/>,
])
}
export const wrapRootElement = (props) => {
return <WrapRootElement {...props} />
}
"gatsby": "3.2.1",
"@chakra-ui/gatsby-plugin": "^2.0.0", |
@alexluong / @dustinlacewell - did you ever find a long-term solution to this? Plenty of popular plugins contain raw JSX in I'm reasonably confident that JSX in a shipped Gatsby plugin is legal. What I need to find is the unique set of conditions where it starts to fail. |
I figured it out! By default, Gatsby appears to use Webpack to simply transpile any dependency with Crucially, though, it appears to arrive at this list of dependencies by parsing In my monorepo, I had not explicitly defined a dependency on the local theme package in the site's I'll report this in a new issue, since I've finally narrowed down the cause and it took almost a day to narrow down. It should at least be possible to report a better error message or a warning earlier in the process, since it should be easy enough for Gatsby to identify when a package has configured a plugin, but no corresponding dependency can be found in its recursive dependencies. |
Description
I use a plugin
gatsby-plugin-chakra-ui
that has some JSX ingatsby-browser.js
. The plugin works fine when it's used inside a normal site.I'm now building a theme inside a monorepo (yarn workspaces), and I receive an error on
gatsby develop
:I'm not entirely sure if this is because of JSX, but the location in the file (9:2) is the beginning of the JSX section.
When I move the code inside the plugin inside the theme (from
node_modules/gatsby-plugin-chakra-ui/gatsby-browser.js
topackages/theme/gatsby-browser.js
), it works perfectly fine.Steps to reproduce
Here is a minimal reproduction. Here is the code for the
gatsby-plugin-chakra-ui
.Expected result
The site should work.
Actual result
I received an error 👆
Environment
The text was updated successfully, but these errors were encountered: