Skip to content

Commit

Permalink
Upgrade remix-pages-app fixture's Remix version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Dec 9, 2022
1 parent 9b75fcf commit 46cfa63
Show file tree
Hide file tree
Showing 14 changed files with 2,122 additions and 306 deletions.
4 changes: 3 additions & 1 deletion fixtures/remix-pages-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules

/.cache
/build
/functions/\[\[path\]\].js
/functions/\[\[path\]\].js.map
/public/build
.env
21 changes: 20 additions & 1 deletion fixtures/remix-pages-app/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Welcome to Remix!

This is a lightly modified Remix starter (`npx create-remix@latest`) which will let us test changes to wrangler and Pages Functions.
- [Remix Docs](https://remix.run/docs)

## Development

You will be utilizing Wrangler for local development to emulate the Cloudflare runtime. This is already wired up in your package.json as the `dev` script:

```sh
# start the remix dev server and wrangler
npm run dev
```

Open up [http://127.0.0.1:8788](http://127.0.0.1:8788) and you should be ready to go!

## Deployment

Cloudflare Pages are currently only deployable through their Git provider integrations.

If you don't already have an account, then [create a Cloudflare account here](https://dash.cloudflare.com/sign-up/pages) and after verifying your email address with Cloudflare, go to your dashboard and follow the [Cloudflare Pages deployment guide](https://developers.cloudflare.com/pages/framework-guides/deploy-anything).

Configure the "Build command" should be set to `npm run build`, and the "Build output directory" should be set to `public`.
3 changes: 1 addition & 2 deletions fixtures/remix-pages-app/app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { RemixBrowser } from "@remix-run/react";
import { hydrate } from "react-dom";
import { RemixBrowser } from "remix";

hydrate(<RemixBrowser />, document);
5 changes: 2 additions & 3 deletions fixtures/remix-pages-app/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import type { EntryContext } from "@remix-run/cloudflare";
import { RemixServer } from "@remix-run/react";
import { renderToString } from "react-dom/server";
import { RemixServer } from "remix";
import type { EntryContext } from "remix";

export default function handleRequest(
request: Request,
Expand Down
21 changes: 8 additions & 13 deletions fixtures/remix-pages-app/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import React from "react";
import type { MetaFunction } from "@remix-run/cloudflare";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "remix";
import type { MetaFunction } from "remix";
} from "@remix-run/react";

declare global {
const process: { env: { NODE_ENV: string } };
}

export const meta: MetaFunction = () => {
return { title: "New Remix App" };
};
export const meta: MetaFunction = () => ({
charset: "utf-8",
title: "New Remix App",
viewport: "width=device-width,initial-scale=1",
});

export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
<LiveReload />
</body>
</html>
);
Expand Down
2 changes: 0 additions & 2 deletions fixtures/remix-pages-app/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from "react";

export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
Expand Down
38 changes: 16 additions & 22 deletions fixtures/remix-pages-app/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
{
"name": "remix-pages-app",
"version": "0.0.0",
"private": true,
"description": "",
"license": "",
"sideEffects": false,
"main": "dist/worker.js",
"scripts": {
"check:type": "tsc && tsc -p tests/tsconfig.json",
"build": "cross-env NODE_ENV=production remix build",
"dev": "cross-env NODE_ENV=development run-p dev:*",
"postinstall": "remix setup cloudflare-pages",
"build": "remix build",
"dev:remix": "remix watch",
"dev:wrangler": "wrangler pages dev ./public",
"start": "npm run dev:wrangler",
"test": "npx jest --forceExit",
"test:ci": "npx jest --forceExit"
"dev:wrangler": "cross-env NODE_ENV=development wrangler pages dev ./public",
"dev": "remix build && run-p \"dev:*\"",
"start": "cross-env NODE_ENV=production npm run dev:wrangler",
"check:type": "tsc && tsc -p tests/tsconfig.json"
},
"jest": {
"restoreMocks": true,
Expand All @@ -34,21 +27,22 @@
]
},
"dependencies": {
"@remix-run/cloudflare-pages": "^1.1.3",
"@remix-run/react": "^1.1.3",
"@remix-run/cloudflare": "^1.8.2",
"@remix-run/cloudflare-pages": "^1.8.2",
"@remix-run/react": "^1.8.2",
"cross-env": "^7.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"remix": "^1.1.3"
"react-dom": "^17.0.2"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.18.0",
"@remix-run/dev": "^1.1.3",
"@types/react": "^17.0.24",
"@types/react-dom": "^17.0.9",
"esbuild": "0.14.51",
"@remix-run/dev": "^1.8.2",
"@remix-run/eslint-config": "^1.8.2",
"@types/react": "^17.0.52",
"@types/react-dom": "^17.0.18",
"eslint": "^8.27.0",
"npm-run-all": "^4.1.5",
"typescript": "^4.1.2",
"undici": "^5.9.1"
"typescript": "^4.8.4"
},
"engines": {
"node": ">=16.13"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/remix-pages-app/public/_headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/*
Cache-Control: public, max-age=31536000, s-maxage=31536000
5 changes: 5 additions & 0 deletions fixtures/remix-pages-app/public/_routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"include": ["/*"],
"exclude": ["/build/*"]
}
18 changes: 8 additions & 10 deletions fixtures/remix-pages-app/remix.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/**
* @type {import('@remix-run/dev/config').AppConfig}
*/
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
appDirectory: "app",
assetsBuildDirectory: "public/build",
publicPath: "/build/",
serverModuleFormat: "esm",
serverPlatform: "neutral",
serverBuildDirectory: "build",
serverBuildTarget: "cloudflare-pages",
server: "./server.js",
devServerBroadcastDelay: 1000,
ignoredRouteFiles: [".*"],
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "functions/[[path]].js",
// publicPath: "/build/",
};
2 changes: 1 addition & 1 deletion fixtures/remix-pages-app/remix.env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/cloudflare-pages/globals" />
/// <reference types="@remix-run/cloudflare" />
/// <reference types="@cloudflare/workers-types" />
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";

// @ts-expect-error this points to generated assets
import * as build from "../build";
import * as build from "@remix-run/dev/server-build";

const handleRequest = createPagesFunctionHandler({
build,
mode: process.env.NODE_ENV,
getLoadContext: (context) => context.env,
});

export function onRequest(context) {
Expand Down
9 changes: 6 additions & 3 deletions fixtures/remix-pages-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true,
"skipLibCheck": true,

"types": [],
"allowJs": true,
"forceConsistentCasingInFileNames": true
"skipLibCheck": true
}
}
Loading

0 comments on commit 46cfa63

Please sign in to comment.