Skip to content

Commit

Permalink
feat: add remix app (ycjcl868#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycjcl868 authored Feb 9, 2022
1 parent a978e8c commit 907b150
Show file tree
Hide file tree
Showing 20 changed files with 2,306 additions and 81 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Preview:
- [Vite Vue 3 App](https://monorepo-vite-vue3-app.vercel.app/)
- [Vite React App](https://monorepo-vite-react-app.vercel.app/)
- [Vue 3 Cli App](https://monorepo-vue3-cli-app.vercel.app/)
- [Remix App](https://monorepo-remix-app.vercel.app/)

### React App

Expand Down
8 changes: 8 additions & 0 deletions apps/remix-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules

.cache
.vercel
.output

public/build
api/_build
34 changes: 34 additions & 0 deletions apps/remix-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)

## Deployment

After having run the `create-remix` command and selected "Vercel" as a deployment target, you only need to [import your Git repository](https://vercel.com/new) into Vercel, and it will be deployed.

If you'd like to avoid using a Git repository, you can also deploy the directory by running [Vercel CLI](https://vercel.com/cli):

```sh
npm i -g vercel
vercel
```

It is generally recommended to use a Git repository, because future commits will then automatically be deployed by Vercel, through its [Git Integration](https://vercel.com/docs/concepts/git).

## Development

To run your Remix app locally, make sure your project's local dependencies are installed:

```sh
npm install
```

Afterwards, start the Remix development server like so:

```sh
npm run dev
```

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

If you're used to using the `vercel dev` command provided by [Vercel CLI](https://vercel.com/cli) instead, you can also use that, but it's not needed.
5 changes: 5 additions & 0 deletions apps/remix-app/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { createRequestHandler } = require("@remix-run/vercel");

module.exports = createRequestHandler({
build: require("./_build")
});
4 changes: 4 additions & 0 deletions apps/remix-app/app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { hydrate } from "react-dom";
import { RemixBrowser } from "remix";

hydrate(<RemixBrowser />, document);
21 changes: 21 additions & 0 deletions apps/remix-app/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { renderToString } from "react-dom/server";
import { RemixServer } from "remix";
import type { EntryContext } from "remix";

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
const markup = renderToString(
<RemixServer context={remixContext} url={request.url} />
);

responseHeaders.set("Content-Type", "text/html");

return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode,
headers: responseHeaders
});
}
32 changes: 32 additions & 0 deletions apps/remix-app/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration
} from "remix";
import type { MetaFunction } from "remix";

export const meta: MetaFunction = () => {
return { title: "New Remix App" };
};

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 />}
</body>
</html>
);
}
39 changes: 39 additions & 0 deletions apps/remix-app/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AppType } from '@infras/shared/types'
import { sum } from '@infras/shared/utils'
import { Component } from '@infras/ui/react'

export default function Index() {
return (
<div style={{ fontFamily: 'system-ui, sans-serif', lineHeight: '1.4' }}>
<h1>Welcome to Remix</h1>
<Component />
<p>AppType.Web is {AppType.Web}</p>
<p>sum(1, 1) is {sum(1, 1)}</p>
<ul>
<li>
<a
target='_blank'
href='https://remix.run/tutorials/blog'
rel='noreferrer'
>
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a
target='_blank'
href='https://remix.run/tutorials/jokes'
rel='noreferrer'
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target='_blank' href='https://remix.run/docs' rel='noreferrer'>
Remix Docs
</a>
</li>
</ul>
</div>
)
}
37 changes: 37 additions & 0 deletions apps/remix-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"private": true,
"name": "remix-app",
"description": "",
"license": "",
"scripts": {
"build": "remix build",
"dev": "remix dev",
"start": "remix dev",
"postinstall": "remix setup node"
},
"dependencies": {
"@infras/shared": "workspace:*",
"@infras/ui": "workspace:*",
"@remix-run/react": "^1.1.3",
"@remix-run/serve": "^1.1.3",
"@remix-run/vercel": "^1.1.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"remix": "^1.1.3"
},
"devDependencies": {
"@remix-run/dev": "^1.1.3",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"typescript": "^4.5.5"
},
"dependenciesMeta": {
"@infras/ui": {
"injected": true
}
},
"engines": {
"node": ">=14"
},
"sideEffects": false
}
Binary file added apps/remix-app/public/favicon.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions apps/remix-app/remix.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @type {import('@remix-run/dev/config').AppConfig}
*/
module.exports = {
appDirectory: "app",
assetsBuildDirectory: "public/build",
publicPath: "/build/",
serverBuildDirectory: "api/_build",
ignoredRouteFiles: [".*"]
};
2 changes: 2 additions & 0 deletions apps/remix-app/remix.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node/globals" />
19 changes: 19 additions & 0 deletions apps/remix-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "@infras/shared/configs/tsconfig.base.json",
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
7 changes: 7 additions & 0 deletions apps/remix-app/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"build": {
"env": {
"ENABLE_FILE_SYSTEM_API": "1"
}
}
}
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
"build:pkg": "pnpm run prepare -r"
},
"devDependencies": {
"turbo": "^1.0.23",
"prettier": "^2.5.1"
"prettier": "^2.5.1",
"turbo": "^1.1.2"
},
"pnpm": {
"overrides": {
"@remix-run/dev@1>esbuild": "0.14.21"
}
},
"turbo": {
"npmClient": "pnpm",
Expand All @@ -21,7 +26,9 @@
]
},
"deploy": {
"dependsOn": ["build"]
"dependsOn": [
"build"
]
},
"dev": {
"cache": false
Expand Down
Binary file modified packages/native/native.darwin-x64.node
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "^2.2.0"
"@napi-rs/cli": "^2.4.2"
},
"engines": {
"node": ">= 10"
Expand All @@ -29,4 +29,4 @@
"@infras/native-darwin-x64": "0.0.0",
"@infras/native-linux-x64-gnu": "0.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/native/target/.rustc_info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"rustc_fingerprint":10073983477905605396,"outputs":{"2797684049618456168":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"15537503139010883884":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.56.1 (59eed8a2a 2021-11-01)\nbinary: rustc\ncommit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35\ncommit-date: 2021-11-01\nhost: x86_64-apple-darwin\nrelease: 1.56.1\nLLVM version: 13.0.0\n","stderr":""},"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}}
{"rustc_fingerprint":7102456466161743728,"outputs":{"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.58.1 (db9d1b20b 2022-01-20)\nbinary: rustc\ncommit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b\ncommit-date: 2022-01-20\nhost: x86_64-apple-darwin\nrelease: 1.58.1\nLLVM version: 13.0.0\n","stderr":""},"2797684049618456168":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}}
13 changes: 7 additions & 6 deletions packages/ui/react/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React, { useState } from 'react';
import { map } from 'lodash-es';
import React from 'react'
import { useState } from 'react'
import { map } from 'lodash-es'

const Component: React.FC<{}> = () => {
const [count, setCount] = useState<number>(0);
const [count, setCount] = useState<number>(0)

return (
<div>
<p>count: {count}</p>
<p>{map([1,2,3,4])}</p>
<button onClick={() => setCount(prev => prev + 1)}>Add</button>
<p>{map([1, 2, 3, 4])}</p>
<button onClick={() => setCount((prev) => prev + 1)}>Add</button>
</div>
)
}

export default Component;
export default Component
Loading

0 comments on commit 907b150

Please sign in to comment.