-
Notifications
You must be signed in to change notification settings - Fork 106
feat: react router support #390
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
Draft
adriandlam
wants to merge
1
commit into
refactor-rollup-plugin_
Choose a base branch
from
feat/react-router-support
base: refactor-rollup-plugin_
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,779
−165
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .DS_Store | ||
| .env | ||
| /node_modules/ | ||
|
|
||
| # React Router | ||
| /.react-router/ | ||
| /build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| FROM node:20-alpine AS development-dependencies-env | ||
| COPY . /app | ||
| WORKDIR /app | ||
| RUN npm ci | ||
|
|
||
| FROM node:20-alpine AS production-dependencies-env | ||
| COPY ./package.json package-lock.json /app/ | ||
| WORKDIR /app | ||
| RUN npm ci --omit=dev | ||
|
|
||
| FROM node:20-alpine AS build-env | ||
| COPY . /app/ | ||
| COPY --from=development-dependencies-env /app/node_modules /app/node_modules | ||
| WORKDIR /app | ||
| RUN npm run build | ||
|
|
||
| FROM node:20-alpine | ||
| COPY ./package.json package-lock.json /app/ | ||
| COPY --from=production-dependencies-env /app/node_modules /app/node_modules | ||
| COPY --from=build-env /app/build /app/build | ||
| WORKDIR /app | ||
| CMD ["npm", "run", "start"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Welcome to React Router! | ||
|
|
||
| A modern, production-ready template for building full-stack React applications using React Router. | ||
|
|
||
| [](https://stackblitz.com/github/remix-run/react-router-templates/tree/main/default) | ||
|
|
||
| ## Features | ||
|
|
||
| - 🚀 Server-side rendering | ||
| - ⚡️ Hot Module Replacement (HMR) | ||
| - 📦 Asset bundling and optimization | ||
| - 🔄 Data loading and mutations | ||
| - 🔒 TypeScript by default | ||
| - 🎉 TailwindCSS for styling | ||
| - 📖 [React Router docs](https://reactrouter.com/) | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Installation | ||
|
|
||
| Install the dependencies: | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| ### Development | ||
|
|
||
| Start the development server with HMR: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Your application will be available at `http://localhost:5173`. | ||
|
|
||
| ## Building for Production | ||
|
|
||
| Create a production build: | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| ## Deployment | ||
|
|
||
| ### Docker Deployment | ||
|
|
||
| To build and run using Docker: | ||
|
|
||
| ```bash | ||
| docker build -t my-app . | ||
|
|
||
| # Run the container | ||
| docker run -p 3000:3000 my-app | ||
| ``` | ||
|
|
||
| The containerized application can be deployed to any platform that supports Docker, including: | ||
|
|
||
| - AWS ECS | ||
| - Google Cloud Run | ||
| - Azure Container Apps | ||
| - Digital Ocean App Platform | ||
| - Fly.io | ||
| - Railway | ||
|
|
||
| ### DIY Deployment | ||
|
|
||
| If you're familiar with deploying Node applications, the built-in app server is production-ready. | ||
|
|
||
| Make sure to deploy the output of `npm run build` | ||
|
|
||
| ``` | ||
| ├── package.json | ||
| ├── package-lock.json (or pnpm-lock.yaml, or bun.lockb) | ||
| ├── build/ | ||
| │ ├── client/ # Static assets | ||
| │ └── server/ # Server-side code | ||
| ``` | ||
|
|
||
| ## Styling | ||
|
|
||
| This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever CSS framework you prefer. | ||
|
|
||
| --- | ||
|
|
||
| Built with ❤️ using React Router. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @import "tailwindcss"; | ||
|
|
||
| @theme { | ||
| --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif, | ||
| "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| @apply bg-white dark:bg-gray-950; | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| color-scheme: dark; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { | ||
| isRouteErrorResponse, | ||
| Links, | ||
| Meta, | ||
| Outlet, | ||
| Scripts, | ||
| ScrollRestoration, | ||
| } from 'react-router'; | ||
|
|
||
| import type { Route } from './+types/root'; | ||
| import './app.css'; | ||
|
|
||
| export const links: Route.LinksFunction = () => [ | ||
| { rel: 'preconnect', href: 'https://fonts.googleapis.com' }, | ||
| { | ||
| rel: 'preconnect', | ||
| href: 'https://fonts.gstatic.com', | ||
| crossOrigin: 'anonymous', | ||
| }, | ||
| { | ||
| rel: 'stylesheet', | ||
| href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap', | ||
| }, | ||
| ]; | ||
|
|
||
| export function Layout({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charSet="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <Meta /> | ||
| <Links /> | ||
| </head> | ||
| <body> | ||
| {children} | ||
| <ScrollRestoration /> | ||
| <Scripts /> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } | ||
|
|
||
| export default function App() { | ||
| return <Outlet />; | ||
| } | ||
|
|
||
| export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { | ||
| let message = 'Oops!'; | ||
| let details = 'An unexpected error occurred.'; | ||
| let stack: string | undefined; | ||
|
|
||
| if (isRouteErrorResponse(error)) { | ||
| message = error.status === 404 ? '404' : 'Error'; | ||
| details = | ||
| error.status === 404 | ||
| ? 'The requested page could not be found.' | ||
| : error.statusText || details; | ||
| } else if (import.meta.env.DEV && error && error instanceof Error) { | ||
| details = error.message; | ||
| stack = error.stack; | ||
| } | ||
|
|
||
| return ( | ||
| <main className="pt-16 p-4 container mx-auto"> | ||
| <h1>{message}</h1> | ||
| <p>{details}</p> | ||
| {stack && ( | ||
| <pre className="w-full p-4 overflow-x-auto"> | ||
| <code>{stack}</code> | ||
| </pre> | ||
| )} | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { type RouteConfig, index } from '@react-router/dev/routes'; | ||
|
|
||
| export default [index('routes/home.tsx')] satisfies RouteConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Route } from './+types/home'; | ||
| import { Welcome } from '../welcome/welcome'; | ||
|
|
||
| export function meta({}: Route.MetaArgs) { | ||
| return [ | ||
| { title: 'New React Router App' }, | ||
| { name: 'description', content: 'Welcome to React Router!' }, | ||
| ]; | ||
| } | ||
|
|
||
| export default function Home() { | ||
| return <Welcome />; | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Dockerfile is incompatible with the project's package manager. It uses
npmand referencespackage-lock.json, but this project is configured to usepnpmwithpnpm-lock.yaml.View Details
📝 Patch Details
Analysis
Dockerfile incompatible with project's pnpm package manager
What fails:
workbench/react-router/Dockerfileusesnpm ciand referencespackage-lock.jsonwhich doesn't exist. The project is configured for pnpm withpnpm-lock.yaml.How to reproduce:
Result:
Expected behavior: The Dockerfile should use pnpm since:
package.jsonspecifiespackageManager: "pnpm@10.20.0"pnpm-lock.yaml(exists at repository root)package-lock.jsonexists in the repositoryworkspace:*) inworkbench/react-router/package.jsonFix applied: Updated Dockerfile to use pnpm:
npm ciwithpnpm install(andpnpm install --prodfor production stage)package-lock.jsontopnpm-lock.yaml