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
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2dcdd10
Update Vite template
frandiox Mar 26, 2024
c4e1065
Support skipDevDependencies in diff options
frandiox Mar 26, 2024
6be5ede
Add classic-remix example
frandiox Mar 26, 2024
3af3078
Setup Vite in skeleton
frandiox Mar 26, 2024
a760a72
Soft-merge dev and build commands
frandiox Mar 26, 2024
671d4c2
Remove Vite example
frandiox Mar 26, 2024
183f2c1
Update diff examples to Vite
frandiox Mar 26, 2024
889ae02
Fix preview and deploy commands
frandiox Mar 26, 2024
e910faa
Deploy classic-remix example
frandiox Mar 26, 2024
4e5e12e
Fix examples in deploy script
frandiox Mar 26, 2024
b286fa3
Fix i18n replacers
frandiox Mar 27, 2024
3929c72
Fix route dependencies algo to support Vite querystirngs
frandiox Mar 27, 2024
ad4a2b7
Temporary disable styling support
frandiox Mar 27, 2024
b94ae2b
Fix logs in dev-vite
frandiox Mar 27, 2024
4fc648d
Adapt init tests to Vite
frandiox Mar 27, 2024
9bf6a58
Add tests for classic compiler
frandiox Mar 27, 2024
fcaf824
Support Vite in setup command to fix tests
frandiox Mar 27, 2024
611ac69
Fix other tests and commands
frandiox Mar 27, 2024
48ae7dd
Update Oclif manifest
frandiox Mar 27, 2024
0e39a5b
Merge branch 'main' into fd-skeleton-vite
frandiox Apr 1, 2024
3eb7b3c
Add link to Remix docs
frandiox Apr 1, 2024
0e2a82b
Fix file paths
frandiox Apr 1, 2024
b8e84fd
Merge branch 'main' into fd-skeleton-vite
frandiox Apr 4, 2024
4686f33
Throw error in setup:css command for Vite projects
frandiox Apr 4, 2024
212b9ac
Filter more logs
frandiox Apr 4, 2024
925f260
Improve logs spacing and filtering
frandiox Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
examples:
[
{name: 'optimistic-cart-ui', token: '1000014888'},
{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 😅

{name: 'third-party-queries-caching', token: '1000014929'},
{name: 'custom-cart-method', token: '1000014930'},
]
Expand Down
40 changes: 40 additions & 0 deletions examples/classic-remix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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 👍


## What's included

- Remix
- Hydrogen
- Oxygen
- Shopify CLI
- ESLint
- Prettier
- GraphQL generator
- TypeScript and JavaScript flavors
- Minimal setup of components and routes

## Getting started

**Requirements:**

- Node.js version 18.0.0 or higher

```bash
npm create @shopify/hydrogen@latest -- --template classic-remix
```

## Building for production

```bash
npm run build
```

## Local development

```bash
npm run dev
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Meta,
Outlet,
Scripts,
LiveReload,
useMatches,
useRouteError,
useLoaderData,
Expand All @@ -17,8 +18,8 @@ import {
type ShouldRevalidateFunction,
} from '@remix-run/react';
import favicon from './assets/favicon.svg';
import resetStyles from './styles/reset.css?url';
import appStyles from './styles/app.css?url';
import resetStyles from './styles/reset.css';
import appStyles from './styles/app.css';
import {Layout} from '~/components/Layout';

/**
Expand Down Expand Up @@ -123,6 +124,7 @@ export default function App() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down Expand Up @@ -164,6 +166,7 @@ export function ErrorBoundary() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down
24 changes: 24 additions & 0 deletions examples/classic-remix/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "example-classic-remix",
"private": true,
"type": "commonjs",
"prettier": "@shopify/prettier-config",
"scripts": {
"build": "shopify hydrogen build --diff",
"dev": "shopify hydrogen dev --codegen --customer-account-push --diff",
"preview": "npm run build && shopify hydrogen preview",
"lint": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx .",
"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 🤔

"skipFiles": [
"vite.config.ts",
"env.d.ts"
],
"skipDevDependencies": [
"vite",
"vite-tsconfig-paths"
]
}
}
4 changes: 2 additions & 2 deletions examples/vite/server.ts → examples/classic-remix/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Virtual entry point for the app
// @ts-ignore
import * as remixBuild from 'virtual:remix/server-build';
import * as remixBuild from '@remix-run/dev/server-build';
import {
cartGetIdDefault,
cartSetIdDefault,
Expand Down Expand Up @@ -71,6 +70,7 @@ export default {
*/
const cart = createCartHandler({
storefront,
customerAccount,
getCartId: cartGetIdDefault(request.headers),
setCartId: cartSetIdDefault(),
cartQueryFragment: CART_QUERY_FRAGMENT,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="@remix-run/dev" />
/// <reference types="vite/client" />
/// <reference types="@shopify/remix-oxygen" />
/// <reference types="@shopify/oxygen-workers-types" />

Expand Down
3 changes: 2 additions & 1 deletion examples/custom-cart-method/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-ignore
// Virtual entry point for the app
import * as remixBuild from '@remix-run/dev/server-build';
import * as remixBuild from 'virtual:remix/server-build';
import {
cartGetIdDefault,
cartSetIdDefault,
Expand Down
7 changes: 2 additions & 5 deletions examples/legacy-customer-account-flow/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Meta,
Outlet,
Scripts,
LiveReload,
useMatches,
useRouteError,
useLoaderData,
Expand All @@ -19,8 +18,8 @@ import {
} from '@remix-run/react';
import type {CustomerAccessToken} from '@shopify/hydrogen/storefront-api-types';
import favicon from './assets/favicon.svg';
import resetStyles from './styles/reset.css';
import appStyles from './styles/app.css';
import resetStyles from './styles/reset.css?url';
import appStyles from './styles/app.css?url';
import {Layout} from '~/components/Layout';

/**
Expand Down Expand Up @@ -128,7 +127,6 @@ export default function App() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down Expand Up @@ -170,7 +168,6 @@ export function ErrorBoundary() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="@remix-run/dev" />
/// <reference types="vite/client" />
/// <reference types="@shopify/remix-oxygen" />
/// <reference types="@shopify/oxygen-workers-types" />

Expand Down
3 changes: 2 additions & 1 deletion examples/legacy-customer-account-flow/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-ignore
// Virtual entry point for the app
import * as remixBuild from '@remix-run/dev/server-build';
import * as remixBuild from 'virtual:remix/server-build';
import {
cartGetIdDefault,
cartSetIdDefault,
Expand Down
7 changes: 2 additions & 5 deletions examples/metaobjects/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Meta,
Outlet,
Scripts,
LiveReload,
useMatches,
useRouteError,
useLoaderData,
Expand All @@ -18,8 +17,8 @@ import {
type ShouldRevalidateFunction,
} from '@remix-run/react';
import favicon from './assets/favicon.svg';
import resetStyles from './styles/reset.css';
import appStyles from './styles/app.css';
import resetStyles from './styles/reset.css?url';
import appStyles from './styles/app.css?url';
import {Layout} from '~/components/Layout';

/**
Expand Down Expand Up @@ -129,7 +128,6 @@ export default function App() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down Expand Up @@ -171,7 +169,6 @@ export function ErrorBoundary() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="@remix-run/dev" />
/// <reference types="vite/client" />
/// <reference types="@shopify/remix-oxygen" />
/// <reference types="@shopify/oxygen-workers-types" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="@remix-run/dev" />
/// <reference types="vite/client" />
/// <reference types="@shopify/remix-oxygen" />
/// <reference types="@shopify/oxygen-workers-types" />

Expand Down
2 changes: 1 addition & 1 deletion examples/third-party-queries-caching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"prettier": "@shopify/prettier-config",
"scripts": {
"build": "shopify hydrogen build --diff",
"build": "shopify hydrogen build --codegen --diff",
"dev": "shopify hydrogen dev --codegen --customer-account-push --diff",
"preview": "npm run build && shopify hydrogen preview",
"lint": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx .",
Expand Down
3 changes: 2 additions & 1 deletion examples/third-party-queries-caching/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-ignore
// Virtual entry point for the app
import * as remixBuild from '@remix-run/dev/server-build';
import * as remixBuild from 'virtual:remix/server-build';
import {
cartGetIdDefault,
cartSetIdDefault,
Expand Down
64 changes: 0 additions & 64 deletions examples/vite/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions examples/vite/package.json

This file was deleted.

Loading
Loading