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

Improve CPU performance in RSC #1452

Merged
merged 2 commits into from
Jun 7, 2022
Merged

Improve CPU performance in RSC #1452

merged 2 commits into from
Jun 7, 2022

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Jun 7, 2022

Description

This change takes the median CPU time in workers for the demo-store down from 25-40ms to 10-17ms.

Before:
image

After:
image

The change itself is simple but we need to read from React internals. Originally, we were relying on the fact that useState is not implemented in RSC, which is not very performant.


Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@frandiox frandiox requested a review from a team June 7, 2022 09:28
Copy link
Contributor

@jplhomer jplhomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there are plans to introduce getCacheForType into Fizz as well, so this logic has a limited shelf life. Regardless, planning to get rid of the Proxy and use node conditions instead so 👍

@jplhomer jplhomer merged commit ed1586a into v1.x-2022-07 Jun 7, 2022
@jplhomer jplhomer deleted the fd-cpu-profile branch June 7, 2022 13:17
lordofthecactus added a commit that referenced this pull request Jun 8, 2022
* Center logo in Demo Store header (#1378)

* Template favicons updated with SVGs, and moved to /src/assets (#1377)

* Automatically fix GQL imports in exisiting Hydrogen Projects (#1336)

* Add eslint rule to fix gql imports

* Update README.md

* add tests with fixer

* Update packages/eslint-plugin/src/rules/prefer-gql/README.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Final copy edits

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Remove CLI scripts (#1379)

* Support ESLint v8 in `eslint-plugin` (#1373)

* remove and reorganize duplicated content (#1380)

* Simplify `routes` property in Hydrogen config (#1313)

* Drop import.meta.globEager in dev

* Refactor variables and virtual modules

* Fix code after cherry-pick

* Extract Vitception

* Use Vitception to load routes during build

* Use static imports to fix build

* Add default routes path

* Fix types and paths

* Fix dirPrefix issues

* Fix HMR in route files

* Use default value for config.routes

* Fix issue in Node 16.15

* Extract virtual-files plugin for clarity

* Cleanup

* Fix unit tests

* Update docs

* Changeset

* Cleanup

* Regenerate broken graphql.schema.json

* Disable rules-of-hooks in server components

* Disable prefer-gql in test

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Revert "Disable prefer-gql in test"

This reverts commit d130f1c.

* Revert "Disable rules-of-hooks in server components"

This reverts commit e0ffbf6.

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update formatting of release notes

* minor fixes (#1391)

* Remove hello world code (#1392)

* [ci] release v1.x-2022-07 (#1343)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Remove broken changesets

* [Hydrogen docs]: User authentication (#1353)

* initial draft

* remove useCustomer docs

* add address and order routes

* integrate feedback

* Make graphql-tag a dep instead of a devDep to fix dev errors (#1394)

* [ci] release v1.x-2022-07 (#1396)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* StackBlitz: turn off auto-save (#1386)

* Simplify renderHydrogen internal logic (#1384)

* Simplify entry-server code

* Combine stream and render into runSsr

* Rename some variables and functions for consistency

* Fix: write head before checking redirects in Node

* Remove unnecessary check and add comment

* These li'l babies need a flipperoo (#1398)

* Rename utility `isClient` to `isBrowser` (#1389)

* Rename utility `isClient` to `isBrowser`

* Switch to document check instead of window

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/utilities/isserver.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix unique key issue in old demo store template

* Workers support streaming now (#1227)

* I think streaming is supported now?

* Bump

* Add changeset

* style guide fixes (#1407)

* Move logger options to Hydrogen config (#1403)

* Stop using globalThis for logger and minor refactor

* Move logger options to Hydrogen config file

* Update unit tests

* Remove setLogger call from e2e tests

* Always call setLogger for HMR

* Remove unnecessary type

* Add docs

* Changeset

* Fix link

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix CountrySelector styling in demo store (#1415)

* fix-demo-store-country-selector-styling

* move conditional classes back to newline

* add changeset

* Fix logger title in docs (#1419)

* Fix logger title in docs

* Fix unrelated changeset

* Suppress confusing warnings (#1399)

* Supress confusing warnings

* Changeset

* Typo

* Improve component bundling and reduce total downloaded files (#1361)

* Skip module references for nested client components

* Changeset

* Move Viteception to RSC plugin. Augment Vite module graph. Bundle client components in boundary chunks

* Minor refactor of internal components to reduce generated chunks

* Changeset

* Update plugin with latest changes

* Maybe fix Windows paths

* Fix undefined variable

* Add moduleSideEffects info

* Sync React experimental with upstream

* Deprecate `enableStreaming` (#1401)

* Deprecate enableStreaming option

* Changeset

* Add docs

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix link

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Move client options to Hydrogen config (#1418)

* Move client options to Hydrogen config

* Update docs

* Changeset

* Remove global config (#1422)

* Remove global config

* Fix unit tests

* Move global context to request internals (#1423)

* Move global context to request internals

* Changeset

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Support async logs (#1424)

* Move global context to request internals

* Changeset

* Support async logs

* Change docs example

* Changeset

* Make sure waitUntil exists

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Rename internal Hydrogen global variables (#1425)

* Rename hydrogen globals

* Changeset

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Rename Request/Response classes to `HydrogenRequest` and `HydrogenResponse` (#1408)

* Rename `ServerComponentRequest` to `HydrogenRequest`

* Move `HydrogenRequest` out of weird Hydration folder

* Move test, too

* Rename `ServerComponentResponse` to `HydrogenResponse`

* Update old references of names

* Fix broken references

* Call out breaking changes in changesets

* Move non-CJS files out of `framework` into `foundation` (#1409)

* Move HydrogenRequest to foundation

* Move HydrogenResponse to foundation

* Move HydrogenRequest test

* Move Cache things to foundation

* Move runtime to foundation

* Move Html to foundation

* Move rsc stuff to entry-client

* StackBlitz: temporary start command workaround (#1434)

* Ignore skipped tests to avoid CI noise (#1432)

* Support Node 18 by avoiding `Headers.raw()` (#1427)

* Split cookies manually instead of using `Headers.raw()`

* Add Node v18 to the testing matrix

* Add changeset

* Fix types, logic, and bundling issues

* Add support for sending ReadableStream to node responses

* Update set-cookie-parser to enhance tree-shaking in workers

* Update packages/hydrogen/src/entry-server.tsx

Co-authored-by: Fran Dios <fran.dios@shopify.com>

* Use existing bufferReadableStream utility

* Don't run tests on Node 17 anymore

Co-authored-by: Fran Dios <fran.dios@shopify.com>

* Implement the account details pages (#1334)

* add account create form

add login form

move login to api route and set it in response & server

get e2e login & logout working

remove setting cookie directly into the server

simplify logout

simplify login

condition render account route using customerAccessToken

add account icon link

rename account route and add no cache

add no cache to customer related query & mutation

move login form to a different route

add register & recover route and create account folder

add account creation flow

fix account login redirect

replace cookie module with worktop/cookie

add checking to account details

add customer recover form

add password reset flow

add more test to cart provider

refactor useCookie to useCustomer instead

if user logined already, use the access token for cart creation

explore multipass login

fix up customer related toolings using sessions

remove @shopify/react-form from login

Remove @shopify/react-form from account create

remove @shopify/react-form from password recover

remove @shopify/react-form from password reset

remove @shopify/react-form

* Fixes

* Fix lint problems

* Fix error handling on account creation

* Fixes to login form

* Fix layout for desktop

* Fix create account page

* Fix recovery page

* Fixes

* Fixes

* Move AccountProfile image to a static svg

* Remove multipass stuff for now

* Mo fixes

* Fix lint errors

* Add docs

* Add docs and changeset

* Update the useCustomer hook

* Update docs/hooks/global/usecustomer.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/global/usecustomer.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Prevent account pages from being indexed by bots

* Update docs

* Remove multipassify for now

* Fix verbiage

* Fix docs

* Add activate account page and move client components into common directory

* Fix gql

* Remove `useCustomer` hooks

* Implement account pages

* Fixes

* Fixes

* Fix bad merge

* Fixes

Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Allow scroll restoration to be disabled (#1431)

* Allow scroll restoration to be disabled

* Update examples

* Revert to prior default value

* Always restore scroll on pop events, regardless of initial intent

* Change to `scroll`

Co-authored-by: Bret Little <bret.little@shopify.com>

* [Hydrogen docs]: Specify experimental features (#1445)

* call out experimental features

* add experimental note to showqueryTiming option

* [Hydrogen docs]: Remove references to render props (#1442)

* remove references to render props

* reference customizing components section

* typo fixes (#1446)

* fix note (#1448)

* [Hydrogen docs]: Update app scaffolding commands (#1292)

* update commands

* typo

* typo

* Remove writeHead and make status writable (#1433)

* Remove writeHead and make status writable

* Changeset

* Cleanup

* Add highWaterMark default to React Flight readable (#1451)

* Improve CPU performance in RSC (#1452)

* Improve CPU performance in RSC check

* Changeset

* Generate a default srcset for an image returned by the Shopify CDN (#1330)

* feat: add default img srcset to Shopify images

* feat: add custom widths to Image srcset

* doc: add srcset documentation

* doc: add change set

* feat: lift widths prop to Image level

* feat: use the available loader to generate srcset

* feat:reduce srcset to max-width without distortion

* test: add default img srcset test

* Update packages/hydrogen/src/components/Image/Image.tsx

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* doc: update Image docs with widths prop changes

* feat: generate srcset for extarnal images

* Update docs/components/primitive/image.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* test: add test for images using src

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* Improve error message when storefront API is not JSON (#1444)

* Propagate a better error message when the response from the storefront API is not JSON parseable

* Shopify analytics 2 (#1325)

* Instrumented page view and make sure Shopfiy live view works

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* [ci] release v1.x-2022-07 (#1404)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Get changelogs to see the new name

* Try to retrigger changeset (#1459)

* Product provider work (#1397)

* saving progress

* Saving progress

I think I have the code all working, it's now just updating tests and stuff. I updated the docs but they probably need to be cleaned up more.

* Working on tests

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productprice.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/product-variant/useproductoptions.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/product-variant/useproductoptions.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Get tests passing and fix a lot of issues in the meantime

* Update docs to show nodes instead of edges->node

* Replace ProductProvider with ProductOptionsProvider

* Fix issue with useEffect

* update selectedoptions on initialVariantId change

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix doc links (#1460)

* fix doc links

* add changeset

* Remove demo-store frontmatter

* Revert "[ci] release v1.x-2022-07 (#1404)" (#1462)

This reverts commit c05c999.

* [ci] release v1.x-2022-07 (#1461)

* [ci] release v1.x-2022-07

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* fix link (#1463)

* Lint changesets (#1464)

* Add script to lint changesets

* Add note about avoiding headings as first line of changesets, and a linter for that

* Add more specific actionable stuff

* Try removing emoji

* Revert "Try removing emoji"

This reverts commit 2ce6301.

* Add final success message

* Remove unused dependencies (#1457)

Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* Cart types update (#1237)

* saving progress

* update queries, types, and add documentation

* Saving progress; I think I'm done but the SFAPI may be down?

* Update docs

* Update .changeset/wet-dingos-kick.md

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Update types and make a small update to CartLinePrice

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Updates yarn lock

* Remove unconfig vite files

* Moves demo-store to demo-store-neue folder

* Moves demo-store-archive to demo-store

* Replaces dynamic import with CSS classes

* Temp switch to non-aliased Header/Footer imports to fix dev

* Removes unconfig vite file

* Updates Favicon design

* Hides cart badge when 0

* Fixes Product Page with updated ProductOptionsProvider

* Updates Cart page for dark mode and Icon colors

* Fixes broken query on Collection page

* Fixes imports and other linting errors across several files

* Fix `ProductGrid`

* Fix locations index route

Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>
Co-authored-by: Fran Dios <fran.dios@shopify.com>
Co-authored-by: Josh Larson <josh.larson@shopify.com>
Co-authored-by: Bret Little <bret.little@shopify.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Scott Dixon <59898611+scottdixon@users.noreply.github.com>
Co-authored-by: BradMurchison <48892838+BradMurchison@users.noreply.github.com>
Co-authored-by: Josh Larson <jplhomer@gmail.com>
Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
Co-authored-by: Emilio Franco <ejfranco06@gmail.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>
Co-authored-by: Helen Lin <helen.lin@shopify.com>
Co-authored-by: Daniel Rios Pavia <daniel.riospavia@shopify.com>
lordofthecactus added a commit that referenced this pull request Jun 8, 2022
* Inits new demo store template

* Update package.json

* Use `gql` from `hydrogen` in demo store v2

* Remove server utilities from client build (#1363)

* Remove server utilities from client build

* Changeset

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* remove stray console.log (#1364)

* Prevent encoded props from double decoding  (#1360)

* Prevent encoded props from double decoding in the RSC flight inlined in the initial page load

* Removed unused htmlDecode

* Update stackblitz workflow to manually update files (#1365)

This needs to happen in a single commit as opposed to
concurrent/parallel workflows because they both check out
the main branch first and then force push.

* Add rule override (#1367)

* Adds @types/react to typescript example (#1362)

* Update docs to describe the difference between experimental and unstable releases (#1366)

* Explicitly log errors for Flight onError (#1320)

* wip: Explicitly log errors for Flight onError

* Rename variables for clarity

* Add changeset

* Revert streaming thing

* Bump hydrogen eslint plugin version (#1368)

* Bump hydrogen eslint plugin version

This gets rid of the annoying error we're seeing while developing the monorepo

* Use new name for hook

* Update for more lax server component hooks rules

* Drop prefixes from template names (#1369)

* Drop prefixes from template names

* Update publish_stackblitz.yml

* Update index.server.jsx

* Update index.server.jsx

* Typescript updates (#1374)

* Update typescript and ts-node

ts-node was required to update because of this comment jestjs/jest#12655 (comment)

* Dedupe the react/types and finish the update

* Fix Image typescript issues (#1371)

* Add TS test-ish things for Image's TS types

Make any console.warn only happen in dev

Fix Image's weird types issue with Simplify from type-fest

Update the readme for the TS example

* Fix dev warnings and a type issue

* add changelog

* Update yarn.lock

* Adds basic layout components and content for 404

* @benjaminsehl/demo store neue (#1387)

* Adds basic components for Collection. Refines Product Card. Co-locates mock data.

* Adds Locations page, refines existing components

* Runs yarn format

* Updates Icons to work with SSR

* Removes custom spacing from Tailwind config

* Updates temp country banner

* Refactors product card, adds search page, beginning of product page

* Adds search functionality, adds real data to homepage, improves components

* Completes desktop hero with dynamic data

* Improves layout and adds data for homepage, cart, header, product card, collections, swimlane

* Updates to locations, collections, products all

* Style consistency updates and addition of dark mode

* Adds functioning search bar on search page

* Adds queries and dynamic data for components

* Update styling on hero and search

* Yarn format

* Updates to hero and search

* Revert "Updates to hero and search"

This reverts commit 145defe.

* Style tweaks to header

* Complete locations template

* Update Location template layout

* Demo store neue: collection pagination (#1400)

* Dynamic Product Swimlane & Mobile Layouts (#1412)

* Product Swimlane now works with product recommendations

* Updates Header for mobile

* Mobile layout for header, footer, and key layout components

* Adds expanding menus to footer

* Adds mobile layout for search

* @benjaminsehl/pdp demo store neue (#1414)

* Product Swimlane now works with product recommendations

* Updates Header for mobile

* Mobile layout for header, footer, and key layout components

* Adds expanding menus to footer

* Adds mobile layout for search

* Basic product page layout

* Adds URL param control to PDP

* Added account pages from demo-store (#1410)

* Added account pages from demo-store

* Autofocus email and password inputs

* adds cart functionality (#1417)

* Wire up cart page

* Fixes typeof error in swimlane

* Wires up cart data

* Demo store neue: Intersection Observer for infinite scroll (#1421)

Co-authored-by: Benjamin Sehl <ben.sehl@shopify.com>

* Dy orders (#1420)

* wip - display empty state for order history if customer doesn't have any orders yet

* Updated empty state based on 404 page

* Display custom welcome heading if customer account has a first name

* Added featured collections, products, and locations sections to account details page

* Styling updates on forms

* Styling, padding, alignment for order history

* Demo store neue: clean up country selector (#1436)

* Renames metaobjects to contentEntries

* Updates metaobject references to contentEntry

* Minor visual fixes and a catch for a bug with availableOnSale

* Moves Neue to main demo store, moves existing demo store to demo-store-archive

* Display order history as a grid of cards (#1440)

* Display order history as grid of cards
* Use Text component
* Fixed text spacing

* Fix new demo store build after update to hydrogen@0.22.1 (#1454)

* Remove package-lock file

* Update to `@shopify/cli@2.0.10` and `@shopify/cli-hydrogen@2.0.10`

* Remove `graphql-tag`

* Update yarn lock file with latest new demo store changes

* Fix environment variable in `App.server.jsx`

* Use default routes in hydrogen config

* Revert "Fix new demo store build after update to hydrogen@0.22.1 (#1454)"

This reverts commit ba43a31.

Easier to merge 0.23.0 and then update given the name changes in folders causing too many conflicsts

* Upgrade Demo Store Neue to v23 (#1467)

* Center logo in Demo Store header (#1378)

* Template favicons updated with SVGs, and moved to /src/assets (#1377)

* Automatically fix GQL imports in exisiting Hydrogen Projects (#1336)

* Add eslint rule to fix gql imports

* Update README.md

* add tests with fixer

* Update packages/eslint-plugin/src/rules/prefer-gql/README.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Final copy edits

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Remove CLI scripts (#1379)

* Support ESLint v8 in `eslint-plugin` (#1373)

* remove and reorganize duplicated content (#1380)

* Simplify `routes` property in Hydrogen config (#1313)

* Drop import.meta.globEager in dev

* Refactor variables and virtual modules

* Fix code after cherry-pick

* Extract Vitception

* Use Vitception to load routes during build

* Use static imports to fix build

* Add default routes path

* Fix types and paths

* Fix dirPrefix issues

* Fix HMR in route files

* Use default value for config.routes

* Fix issue in Node 16.15

* Extract virtual-files plugin for clarity

* Cleanup

* Fix unit tests

* Update docs

* Changeset

* Cleanup

* Regenerate broken graphql.schema.json

* Disable rules-of-hooks in server components

* Disable prefer-gql in test

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Revert "Disable prefer-gql in test"

This reverts commit d130f1c.

* Revert "Disable rules-of-hooks in server components"

This reverts commit e0ffbf6.

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update formatting of release notes

* minor fixes (#1391)

* Remove hello world code (#1392)

* [ci] release v1.x-2022-07 (#1343)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Remove broken changesets

* [Hydrogen docs]: User authentication (#1353)

* initial draft

* remove useCustomer docs

* add address and order routes

* integrate feedback

* Make graphql-tag a dep instead of a devDep to fix dev errors (#1394)

* [ci] release v1.x-2022-07 (#1396)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* StackBlitz: turn off auto-save (#1386)

* Simplify renderHydrogen internal logic (#1384)

* Simplify entry-server code

* Combine stream and render into runSsr

* Rename some variables and functions for consistency

* Fix: write head before checking redirects in Node

* Remove unnecessary check and add comment

* These li'l babies need a flipperoo (#1398)

* Rename utility `isClient` to `isBrowser` (#1389)

* Rename utility `isClient` to `isBrowser`

* Switch to document check instead of window

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/utilities/isserver.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix unique key issue in old demo store template

* Workers support streaming now (#1227)

* I think streaming is supported now?

* Bump

* Add changeset

* style guide fixes (#1407)

* Move logger options to Hydrogen config (#1403)

* Stop using globalThis for logger and minor refactor

* Move logger options to Hydrogen config file

* Update unit tests

* Remove setLogger call from e2e tests

* Always call setLogger for HMR

* Remove unnecessary type

* Add docs

* Changeset

* Fix link

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix CountrySelector styling in demo store (#1415)

* fix-demo-store-country-selector-styling

* move conditional classes back to newline

* add changeset

* Fix logger title in docs (#1419)

* Fix logger title in docs

* Fix unrelated changeset

* Suppress confusing warnings (#1399)

* Supress confusing warnings

* Changeset

* Typo

* Improve component bundling and reduce total downloaded files (#1361)

* Skip module references for nested client components

* Changeset

* Move Viteception to RSC plugin. Augment Vite module graph. Bundle client components in boundary chunks

* Minor refactor of internal components to reduce generated chunks

* Changeset

* Update plugin with latest changes

* Maybe fix Windows paths

* Fix undefined variable

* Add moduleSideEffects info

* Sync React experimental with upstream

* Deprecate `enableStreaming` (#1401)

* Deprecate enableStreaming option

* Changeset

* Add docs

* Apply suggestions from code review

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix link

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Move client options to Hydrogen config (#1418)

* Move client options to Hydrogen config

* Update docs

* Changeset

* Remove global config (#1422)

* Remove global config

* Fix unit tests

* Move global context to request internals (#1423)

* Move global context to request internals

* Changeset

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Support async logs (#1424)

* Move global context to request internals

* Changeset

* Support async logs

* Change docs example

* Changeset

* Make sure waitUntil exists

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Rename internal Hydrogen global variables (#1425)

* Rename hydrogen globals

* Changeset

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Rename Request/Response classes to `HydrogenRequest` and `HydrogenResponse` (#1408)

* Rename `ServerComponentRequest` to `HydrogenRequest`

* Move `HydrogenRequest` out of weird Hydration folder

* Move test, too

* Rename `ServerComponentResponse` to `HydrogenResponse`

* Update old references of names

* Fix broken references

* Call out breaking changes in changesets

* Move non-CJS files out of `framework` into `foundation` (#1409)

* Move HydrogenRequest to foundation

* Move HydrogenResponse to foundation

* Move HydrogenRequest test

* Move Cache things to foundation

* Move runtime to foundation

* Move Html to foundation

* Move rsc stuff to entry-client

* StackBlitz: temporary start command workaround (#1434)

* Ignore skipped tests to avoid CI noise (#1432)

* Support Node 18 by avoiding `Headers.raw()` (#1427)

* Split cookies manually instead of using `Headers.raw()`

* Add Node v18 to the testing matrix

* Add changeset

* Fix types, logic, and bundling issues

* Add support for sending ReadableStream to node responses

* Update set-cookie-parser to enhance tree-shaking in workers

* Update packages/hydrogen/src/entry-server.tsx

Co-authored-by: Fran Dios <fran.dios@shopify.com>

* Use existing bufferReadableStream utility

* Don't run tests on Node 17 anymore

Co-authored-by: Fran Dios <fran.dios@shopify.com>

* Implement the account details pages (#1334)

* add account create form

add login form

move login to api route and set it in response & server

get e2e login & logout working

remove setting cookie directly into the server

simplify logout

simplify login

condition render account route using customerAccessToken

add account icon link

rename account route and add no cache

add no cache to customer related query & mutation

move login form to a different route

add register & recover route and create account folder

add account creation flow

fix account login redirect

replace cookie module with worktop/cookie

add checking to account details

add customer recover form

add password reset flow

add more test to cart provider

refactor useCookie to useCustomer instead

if user logined already, use the access token for cart creation

explore multipass login

fix up customer related toolings using sessions

remove @shopify/react-form from login

Remove @shopify/react-form from account create

remove @shopify/react-form from password recover

remove @shopify/react-form from password reset

remove @shopify/react-form

* Fixes

* Fix lint problems

* Fix error handling on account creation

* Fixes to login form

* Fix layout for desktop

* Fix create account page

* Fix recovery page

* Fixes

* Fixes

* Move AccountProfile image to a static svg

* Remove multipass stuff for now

* Mo fixes

* Fix lint errors

* Add docs

* Add docs and changeset

* Update the useCustomer hook

* Update docs/hooks/global/usecustomer.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/global/usecustomer.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Prevent account pages from being indexed by bots

* Update docs

* Remove multipassify for now

* Fix verbiage

* Fix docs

* Add activate account page and move client components into common directory

* Fix gql

* Remove `useCustomer` hooks

* Implement account pages

* Fixes

* Fixes

* Fix bad merge

* Fixes

Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Allow scroll restoration to be disabled (#1431)

* Allow scroll restoration to be disabled

* Update examples

* Revert to prior default value

* Always restore scroll on pop events, regardless of initial intent

* Change to `scroll`

Co-authored-by: Bret Little <bret.little@shopify.com>

* [Hydrogen docs]: Specify experimental features (#1445)

* call out experimental features

* add experimental note to showqueryTiming option

* [Hydrogen docs]: Remove references to render props (#1442)

* remove references to render props

* reference customizing components section

* typo fixes (#1446)

* fix note (#1448)

* [Hydrogen docs]: Update app scaffolding commands (#1292)

* update commands

* typo

* typo

* Remove writeHead and make status writable (#1433)

* Remove writeHead and make status writable

* Changeset

* Cleanup

* Add highWaterMark default to React Flight readable (#1451)

* Improve CPU performance in RSC (#1452)

* Improve CPU performance in RSC check

* Changeset

* Generate a default srcset for an image returned by the Shopify CDN (#1330)

* feat: add default img srcset to Shopify images

* feat: add custom widths to Image srcset

* doc: add srcset documentation

* doc: add change set

* feat: lift widths prop to Image level

* feat: use the available loader to generate srcset

* feat:reduce srcset to max-width without distortion

* test: add default img srcset test

* Update packages/hydrogen/src/components/Image/Image.tsx

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* doc: update Image docs with widths prop changes

* feat: generate srcset for extarnal images

* Update docs/components/primitive/image.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* test: add test for images using src

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* Improve error message when storefront API is not JSON (#1444)

* Propagate a better error message when the response from the storefront API is not JSON parseable

* Shopify analytics 2 (#1325)

* Instrumented page view and make sure Shopfiy live view works

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* [ci] release v1.x-2022-07 (#1404)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Get changelogs to see the new name

* Try to retrigger changeset (#1459)

* Product provider work (#1397)

* saving progress

* Saving progress

I think I have the code all working, it's now just updating tests and stuff. I updated the docs but they probably need to be cleaned up more.

* Working on tests

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productprice.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/product-variant/useproductoptions.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/hooks/product-variant/useproductoptions.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Update docs/components/product-variant/productoptionsprovider.md

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Get tests passing and fix a lot of issues in the meantime

* Update docs to show nodes instead of edges->node

* Replace ProductProvider with ProductOptionsProvider

* Fix issue with useEffect

* update selectedoptions on initialVariantId change

Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>

* Fix doc links (#1460)

* fix doc links

* add changeset

* Remove demo-store frontmatter

* Revert "[ci] release v1.x-2022-07 (#1404)" (#1462)

This reverts commit c05c999.

* [ci] release v1.x-2022-07 (#1461)

* [ci] release v1.x-2022-07

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* fix link (#1463)

* Lint changesets (#1464)

* Add script to lint changesets

* Add note about avoiding headings as first line of changesets, and a linter for that

* Add more specific actionable stuff

* Try removing emoji

* Revert "Try removing emoji"

This reverts commit 2ce6301.

* Add final success message

* Remove unused dependencies (#1457)

Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>

* Cart types update (#1237)

* saving progress

* update queries, types, and add documentation

* Saving progress; I think I'm done but the SFAPI may be down?

* Update docs

* Update .changeset/wet-dingos-kick.md

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Update types and make a small update to CartLinePrice

Co-authored-by: Josh Larson <josh.larson@shopify.com>

* Updates yarn lock

* Remove unconfig vite files

* Moves demo-store to demo-store-neue folder

* Moves demo-store-archive to demo-store

* Replaces dynamic import with CSS classes

* Temp switch to non-aliased Header/Footer imports to fix dev

* Removes unconfig vite file

* Updates Favicon design

* Hides cart badge when 0

* Fixes Product Page with updated ProductOptionsProvider

* Updates Cart page for dark mode and Icon colors

* Fixes broken query on Collection page

* Fixes imports and other linting errors across several files

* Fix `ProductGrid`

* Fix locations index route

Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>
Co-authored-by: Fran Dios <fran.dios@shopify.com>
Co-authored-by: Josh Larson <josh.larson@shopify.com>
Co-authored-by: Bret Little <bret.little@shopify.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Scott Dixon <59898611+scottdixon@users.noreply.github.com>
Co-authored-by: BradMurchison <48892838+BradMurchison@users.noreply.github.com>
Co-authored-by: Josh Larson <jplhomer@gmail.com>
Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
Co-authored-by: Emilio Franco <ejfranco06@gmail.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>
Co-authored-by: Helen Lin <helen.lin@shopify.com>
Co-authored-by: Daniel Rios Pavia <daniel.riospavia@shopify.com>

* Remove package lock file

* Temporarily comment out missing account components and fixes small issues

* Update to `eslint@18.x`

* Fix graphql schema

Co-authored-by: Benjamin Sehl <ben.sehl@shopify.com>
Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
Co-authored-by: Fran Dios <fran.dios@shopify.com>
Co-authored-by: Josh Larson <josh.larson@shopify.com>
Co-authored-by: Bret Little <bret.little@shopify.com>
Co-authored-by: JrFelix540 <43949819+JrFelix540@users.noreply.github.com>
Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>
Co-authored-by: Scott Dixon <59898611+scottdixon@users.noreply.github.com>
Co-authored-by: Dave Yen <davecyen@gmail.com>
Co-authored-by: Michelle Vinci <michelle.vinci@shopify.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: BradMurchison <48892838+BradMurchison@users.noreply.github.com>
Co-authored-by: Josh Larson <jplhomer@gmail.com>
Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
Co-authored-by: Emilio Franco <ejfranco06@gmail.com>
Co-authored-by: Helen Lin <helen.lin@shopify.com>
@frandiox frandiox mentioned this pull request Jun 13, 2022
4 tasks
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

Successfully merging this pull request may close these issues.

2 participants