Skip to content

Commit 11f70c5

Browse files
authored
Merge pull request #896 from Shopify/javascript_updates
Convert template to Javascript
2 parents 23fbc88 + a387da6 commit 11f70c5

File tree

10 files changed

+35
-20
lines changed

10 files changed

+35
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# @shopify/shopify-app-template-remix
22

3-
## 2024.11.26
3+
## 2024.12.04
44

5+
- [#891](https://github.com/Shopify/shopify-app-template-remix/pull/891) Enable remix future flags.
6+
-
7+
## 2024.11.26
58
- [888](https://github.com/Shopify/shopify-app-template-remix/pull/888) Update restResources version to 2024-10
69

10+
711
## 2024.11.06
812

913
- [881](https://github.com/Shopify/shopify-app-template-remix/pull/881) Update to the productCreate mutation to use the new ProductCreateInput type

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function loader({ request }) {
8686
},
8787
} = await response.json();
8888

89-
return json(nodes);
89+
return nodes;
9090
}
9191
```
9292

app/entry.server.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createReadableStreamFromReadable } from "@remix-run/node";
55
import { isbot } from "isbot";
66
import { addDocumentResponseHeaders } from "./shopify.server";
77

8-
const ABORT_DELAY = 5000;
8+
export const streamTimeout = 5000;
99

1010
export default async function handleRequest(
1111
request,
@@ -19,11 +19,7 @@ export default async function handleRequest(
1919

2020
return new Promise((resolve, reject) => {
2121
const { pipe, abort } = renderToPipeableStream(
22-
<RemixServer
23-
context={remixContext}
24-
url={request.url}
25-
abortDelay={ABORT_DELAY}
26-
/>,
22+
<RemixServer context={remixContext} url={request.url} />,
2723
{
2824
[callbackName]: () => {
2925
const body = new PassThrough();
@@ -48,6 +44,8 @@ export default async function handleRequest(
4844
},
4945
);
5046

51-
setTimeout(abort, ABORT_DELAY);
47+
// Automatically timeout the React renderer after 6 seconds, which ensures
48+
// React has enough time to flush down the rejected boundary contents
49+
setTimeout(abort, streamTimeout + 1000);
5250
});
5351
}

app/routes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { flatRoutes } from "@remix-run/fs-routes";
2+
3+
export default flatRoutes();

app/routes/_index/route.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { json, redirect } from "@remix-run/node";
1+
import { redirect } from "@remix-run/node";
22
import { Form, useLoaderData } from "@remix-run/react";
33
import { login } from "../../shopify.server";
44
import styles from "./styles.module.css";
@@ -10,7 +10,7 @@ export const loader = async ({ request }) => {
1010
throw redirect(`/app?${url.searchParams.toString()}`);
1111
}
1212

13-
return json({ showForm: Boolean(login) });
13+
return { showForm: Boolean(login) };
1414
};
1515

1616
export default function App() {

app/routes/app._index.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect } from "react";
2-
import { json } from "@remix-run/node";
32
import { useFetcher } from "@remix-run/react";
43
import {
54
Page,
@@ -81,10 +80,10 @@ export const action = async ({ request }) => {
8180
);
8281
const variantResponseJson = await variantResponse.json();
8382

84-
return json({
83+
return {
8584
product: responseJson.data.productCreate.product,
8685
variant: variantResponseJson.data.productVariantsBulkUpdate.productVariants,
87-
});
86+
};
8887
};
8988

9089
export default function Index() {

app/routes/app.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { json } from "@remix-run/node";
21
import { Link, Outlet, useLoaderData, useRouteError } from "@remix-run/react";
32
import { boundary } from "@shopify/shopify-app-remix/server";
43
import { AppProvider } from "@shopify/shopify-app-remix/react";
@@ -11,7 +10,7 @@ export const links = () => [{ rel: "stylesheet", href: polarisStyles }];
1110
export const loader = async ({ request }) => {
1211
await authenticate.admin(request);
1312

14-
return json({ apiKey: process.env.SHOPIFY_API_KEY || "" });
13+
return { apiKey: process.env.SHOPIFY_API_KEY || "" };
1514
};
1615

1716
export default function App() {

app/routes/auth.login/route.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useState } from "react";
2-
import { json } from "@remix-run/node";
32
import { Form, useActionData, useLoaderData } from "@remix-run/react";
43
import {
54
AppProvider as PolarisAppProvider,
@@ -20,15 +19,15 @@ export const links = () => [{ rel: "stylesheet", href: polarisStyles }];
2019
export const loader = async ({ request }) => {
2120
const errors = loginErrorMessage(await login(request));
2221

23-
return json({ errors, polarisTranslations });
22+
return { errors, polarisTranslations };
2423
};
2524

2625
export const action = async ({ request }) => {
2726
const errors = loginErrorMessage(await login(request));
2827

29-
return json({
28+
return {
3029
errors,
31-
});
30+
};
3231
};
3332

3433
export default function Auth() {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
},
4242
"devDependencies": {
4343
"@remix-run/eslint-config": "^2.7.1",
44+
"@remix-run/fs-routes": "^2.15.0",
45+
"@remix-run/route-config": "^2.15.0",
4446
"@shopify/api-codegen-preset": "^1.1.1",
4547
"@types/eslint": "^8.40.0",
4648
"@types/node": "^22.2.0",

vite.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { vitePlugin as remix } from "@remix-run/dev";
2+
import { installGlobals } from "@remix-run/node";
23
import { defineConfig } from "vite";
34
import tsconfigPaths from "vite-tsconfig-paths";
45

6+
installGlobals({ nativeFetch: true });
7+
58
// Related: https://github.com/remix-run/remix/issues/2835#issuecomment-1144102176
69
// Replace the HOST env var with SHOPIFY_APP_URL so that it doesn't break the remix server. The CLI will eventually
710
// stop passing in HOST, so we can remove this workaround after the next major release.
@@ -46,6 +49,14 @@ export default defineConfig({
4649
plugins: [
4750
remix({
4851
ignoredRouteFiles: ["**/.*"],
52+
future: {
53+
v3_fetcherPersist: true,
54+
v3_relativeSplatPath: true,
55+
v3_throwAbortReason: true,
56+
v3_lazyRouteDiscovery: true,
57+
v3_singleFetch: true,
58+
v3_routeConfig: true,
59+
},
4960
}),
5061
tsconfigPaths(),
5162
],

0 commit comments

Comments
 (0)