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

framework-[contenthash].js includes react-dom-server when using gatsby-plugin-image #37281

Closed
2 tasks done
danilobuerger opened this issue Dec 16, 2022 · 10 comments · Fixed by #37508
Closed
2 tasks done
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby

Comments

@danilobuerger
Copy link
Contributor

Preliminary Checks

Description

When using GatsbyImage from gatsby-plugin-image, the framework-[contenthash].js is getting bloated by including react-dom/server:

Screenshot 2022-12-16 at 12 26 25

This comes from a change at #35226 from @wardpeet by using renderToStaticMarkup from react-dom/server:

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx#L202

Reproduction Link

https://github.com/danilobuerger/gatsby-repro

Steps to Reproduce

  1. Get the reproduction
  2. build & serve, notice the framework-[contenthash].js size (ca 46.2 kb)
  3. Uncomment GatsbyImage in src/pages/index.tsx
  4. build & serve, notice the framework-[contenthash].js size (ca 67.4 kb)

The size between step 2 and 4 will be different

Expected Result

framework-[contenthash].js should not include react-dom/server.

Actual Result

framework-[contenthash].js includes react-dom/server.

Environment

System:
    OS: macOS 12.6.2
    CPU: (8) arm64 Apple M1
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Safari: 16.2
  npmPackages:
    gatsby: ^5.3.2 => 5.3.2
    gatsby-plugin-image: ^3.3.2 => 3.3.2
    gatsby-plugin-sharp: ^5.3.2 => 5.3.2
    gatsby-source-filesystem: ^5.3.1 => 5.3.1
    gatsby-transformer-sharp: ^5.3.1 => 5.3.1


### Config Flags

_No response_
@danilobuerger danilobuerger added the type: bug An issue or pull request relating to a bug in Gatsby label Dec 16, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 16, 2022
@LekoArts LekoArts added topic: media Related to gatsby-plugin-image, or general image/media processing topics status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 18, 2023
@LekoArts
Copy link
Contributor

LekoArts commented Jan 18, 2023

Thanks for the issue!

Analyzing it with Statoscope can give one some more details:

image

I'll play with our webpack configuration. It shouldn't be in the framework bundle, it should be it's own.

@BojanHribernik
Copy link

I can confirm this. Found out about it through Lighthouse report
Screenshot from 2023-01-23 13-59-42

@danilobuerger
Copy link
Contributor Author

Thanks @LekoArts !

@danilobuerger
Copy link
Contributor Author

@LekoArts this seems to not be working on the newest 5.6 release. I am seeing the app-[contenthash].js exploding in size. And the framework-[contenthash].js is not being created.

@LekoArts
Copy link
Contributor

LekoArts commented Feb 8, 2023

Please provide a reproduction, I haven't seen this in my local testing when authoring the PR

@danilobuerger
Copy link
Contributor Author

@LekoArts I narrowed down the issue. It seems to only come up when using pnpm (with the gatsby-plugin-pnpm). Most likely related to the code here:
https://github.com/Js-Brecht/gatsby-plugin-pnpm/blob/master/src/fixes.ts#L6-L10

@LekoArts
Copy link
Contributor

LekoArts commented Feb 8, 2023

The split chunking won't happen in gatsby develop anyways

@danilobuerger
Copy link
Contributor Author

@LekoArts I am seeing this with gatsby build.

@LekoArts
Copy link
Contributor

LekoArts commented Feb 8, 2023

I was referring to the plugin's comment:

Fix missing framework in development.

But yeah, I'm afraid if this is caused through this plugin you'll need to send in a PR fixing it

@danilobuerger
Copy link
Contributor Author

@LekoArts Yeah, but it's really a shame that gatsby doesn't just support pnpm out of the box. There are lots of issues related to pnpm in this repository, it might be worth considering adding pnpm support here if people are using it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants