Skip to content
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

why-did-you-render is bundled in production build #2

Open
mwskwong opened this issue Mar 7, 2021 · 1 comment
Open

why-did-you-render is bundled in production build #2

mwskwong opened this issue Mar 7, 2021 · 1 comment

Comments

@mwskwong
Copy link

mwskwong commented Mar 7, 2021

As the title suggests. The reason behind this is you import the packages at the very top of gatsby-browser.ts regardless of what environment it is.

import whyDidYouRender from '@welldone-software/why-did-you-render';

Instead, what you should be doing is

export const onClientEntry = (_: undefined, pluginOptions = defaultOptions): void => {
  if (process.env.NODE_ENV !== 'production') {
    const whyDidYouRender = require("why-did-you-render");
  }
}
@steveadams
Copy link
Owner

Thanks @mwskwong, I'll have this fixed pretty soon. Apologies for the delay, I suddenly stopped working with Gatsby and have been deep in the Next.js world. Though there are few people using this package, I should have kept it more up to date. I appreciate the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants