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

Use Vite in templates and examples #1912

Merged
merged 26 commits into from
Apr 4, 2024
Merged

Use Vite in templates and examples #1912

merged 26 commits into from
Apr 4, 2024

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Mar 26, 2024

WHY are these changes introduced?

We want to dogfood Vite before the stable release.

WHAT is this pull request doing?

  • Use Vite in skeleton template
  • Use Vite in --diff examples
  • Remove the previous example/vite project
  • Add a new example/classic-remix project
  • Soft merge dev and build commands so that we can run h2 dev instead of h2 dev-vite. This merge will need more work a different PR.
  • Patch preview and deploy commands to make them work with both Vite and Classic. This will also require another PR for cleanup.
  • Fix h2 setup and h2 setup markets commands to work with Vite.
  • Disable setup:css features and prompts since they don't work with Vite yet (setup tailwind, etc).

HOW to test your changes?

Run dev, build, preview, deploy commands in skeleton and examples. It should all work 🤞

@frandiox frandiox requested a review from a team March 26, 2024 19:07
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 Mar 26, 2024

Oxygen deployed a preview of your fd-skeleton-vite branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:44 AM
vite ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:45 AM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:37 AM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:54 AM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:45 AM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment April 4, 202411:45 AM

Learn more about Hydrogen's GitHub integration.

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

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

For some reason, not sure why, this double slash seems to be introduced by this PR:
image

@blittle
Copy link
Contributor

blittle commented Mar 29, 2024

It also seems that h2 setup markets doesn't work within the skeleton folder. I get a double path:
image

{name: 'vite', token: '1000014892'},
{name: 'subscriptions', token: '1000014928'},
{name: 'classic-remix', token: '1000014892'},
{name: 'metaobjects', token: '1000014928'},
Copy link
Contributor

Choose a reason for hiding this comment

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

Was subscriptions incorrect? Intentionally change the name to metaobjects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's not an example that uses --diff. And the build script in this workflow uses --diff so we should only list here --diff examples, I think?
We were lucky subscriptions worked but it may break 😅

Comment on lines 1 to 6
# Hydrogen template: Classic Remix

Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dovetail with [Remix](https://remix.run/), Shopify’s full stack web framework. This template contains a **minimal setup** of components, queries and tooling to get started with Hydrogen and the classic Remix compiler (i.e. before Vite).

[Check out Hydrogen docs](https://shopify.dev/custom-storefronts/hydrogen)
[Get familiar with Remix](https://remix.run/docs/en/v1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be more description about what "classic remix" is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a link to Remix docs 👍

"typecheck": "tsc --noEmit",
"codegen": "shopify hydrogen codegen"
},
"h2:diff": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with this new property, I assume this is configuration when the diff is applied, the the vite files in the skeleton template don't end up in the output of this example. Very cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, just a quick escape hatch for a few examples due to the migration from ESBuild to Vite. We can probably remove it when we move completely to Vite and remove the classic compiler 🤔

});
};

if (await hasViteConfig(directory ?? process.cwd())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah so make h2 build automatically detect if there's a vite config and pick the build path from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is a "soft-mergeofdevanddev-vite`. I'll make a new PR reorganizing this code better.

`"name": "example-classic-remix"`,
);

// ---- DEV
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit picky, but would it be better to separate these out, so it's more obvious when one fails? Not a big deal if you prefer to keep them all together.

Copy link
Contributor Author

@frandiox frandiox Apr 1, 2024

Choose a reason for hiding this comment

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

I've been thinking about this and would like to split this file in different ones. But I think this could still be here.
The ones I want to extract are the "build" and "dev" tests.
These should be in build.test and dev.test even if they use runInit to generate fixtures 🤔

For a different PR, tho.

Comment on lines +409 to +410
expect(mb).toBeGreaterThan(0);
expect(mb).toBeLessThan(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great! We'll find a failure if we go over 1mb in the skeleton template output.

@frandiox
Copy link
Contributor Author

frandiox commented Apr 1, 2024

This was fixed it in #1891 👍

image

It also seems that h2 setup markets doesn't work within the skeleton folder. I get a double path:

Nice catch, fixed by replacing joinPath with relativePath:

image

@frandiox frandiox requested a review from blittle April 1, 2024 11:44
Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

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

@frandiox while the error has gone when running h2 setup markets inside the skeleton template, when selecting subfolders, it only updates server.ts, the route folder structure itself doesn't change. Is that intentional? If so, then 🟢 from me.

@frandiox
Copy link
Contributor Author

frandiox commented Apr 4, 2024

when selecting subfolders, it only updates server.ts, the route folder structure itself doesn't change. Is that intentional?

Yes, I think we never implemented this because you also need to modify other things in the files to handle the new param.

@frandiox frandiox merged commit c3d8dbe into main Apr 4, 2024
13 checks passed
@frandiox frandiox deleted the fd-skeleton-vite branch April 4, 2024 12:05
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