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 monorepo DX #2154

Merged
merged 18 commits into from
May 29, 2024
Merged

Improve monorepo DX #2154

merged 18 commits into from
May 29, 2024

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented May 27, 2024

  • Fix hydrogen-react to refresh the proper files during development. Its dev process was refreshing dist/browser-prod instead of dist/browser-dev, which is what we use in local development.
  • Restart the codegen process when modifying hydrogen-codegen
  • Print a message when modifying the CLI source to remind us to restart the h2 dev process (we can't do this automatically without creating more problems).
  • Changes in hydrogen/remix-oxygen should be reflected in the skeleton template without restarting the server
  • Changes to Hydrogen or Oxygen Vite plugins should restart the server but it depends on this fix in Vite to fully work. If this is not merged then I'll make a workaround.
  • Changes to skeleton files will automatically rebuild the CLI so that h2 generate xyz uses the latest files.
  • Diff examples are now merged to skeleton source files from the monorepo, not from the CLI build. This means we don't need to npm run dev in the CLI to get files applied in diff examples.
  • Diff examples are now updated when files in skeleton template changes without restarting the dev server:
    • If the file changed in the skeleton template exists in the diff example, it won't use it.
    • If the file changed in the skeleton template doesn't exist in the diff example, it will be used automatically.
    • If a file is removed from the diff example, it will fallback to the same file in the skeleton template if it exists instead of just removing it in the dev server.

Any other thing that is not working properly in local dev?

@frandiox frandiox requested a review from a team May 27, 2024 10:37
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run npm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

Copy link
Contributor

shopify bot commented May 27, 2024

Oxygen deployed a preview of your fd-monorepo-dx branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:55 AM
vite ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:54 AM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:55 AM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:54 AM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:54 AM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment May 29, 2024 1:54 AM

Learn more about Hydrogen's GitHub integration.

@wizardlyhel
Copy link
Contributor

wizardlyhel commented May 27, 2024

Validated for cases:

  • When running skeleton, making edits to hydrogen or hydrogen-react package will force vite re-optimization of dependencies that will bring in the new edits
  • When running an example, making edits to hydrogen or hydrogen-react package will force vite re-optimization of dependencies that will bring in the new edits

@frandiox There is one case that I found that didn't work or broken. When running an example, when making edits to the skeleton template, the example doesn't get the new diff on files that didn't get override in the example folder. We used to be able to just ctrl-c and re-run npm run dev within the example folder and that would bring in the latest skeleton changes. But on this branch, I am not able to get the skeleton diff into the example at all.


if (isHydrogenMonorepo) {
// Force reoptimizing deps without printing the message
await removeFile(joinPath(root, 'node_modules/.vite'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also remove the node_modules/.vite that now also appears in the skeleton folder when running npm run dev:app or npm run dev within the skeleton folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the one we are removing here. root should point to the skeleton template when running it there or with npm run dev:app 🤔

@frandiox
Copy link
Contributor Author

@wizardlyhel

We used to be able to just ctrl-c and re-run npm run dev within the example folder and that would bring in the latest skeleton changes. But on this branch, I am not able to get the skeleton diff into the example at all.

The files came from packages/cli/dist/.../starter, not from templates/skeleton, which means you would need to rebuild the CLI to get new changes in the example diff virtual files. So I don't think it was related to this branch but I might be wrong 🤔 -- In any case I've fixed this and now we use templates/skeleton source files directly for diff examples so it shouldn't be an issue anymore.

When running an example, when making edits to the skeleton template, the example doesn't get the new diff on files that didn't get override in the example folder.

I've added an extra watcher to make this possible. Now changes in skeleton source files should reflect in the diff example without restarting the dev server. Diff example files still have higher priority so they won't be overwritten by skeleton files even if they change.

Copy link
Contributor

@wizardlyhel wizardlyhel left a comment

Choose a reason for hiding this comment

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

Looks good on my end.

[Non blocking] When I am running a diff example and making changes to skeleton template, I get this banner in terminal. The update did work.

Screenshot 2024-05-28 at 10 20 07 AM

@frandiox
Copy link
Contributor Author

Thanks for checking again. I've removed that banner completely since it's actually not that useful and it might be confusing 👍

@frandiox frandiox merged commit ea2c3d4 into main May 29, 2024
13 checks passed
@frandiox frandiox deleted the fd-monorepo-dx branch May 29, 2024 03:51
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