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

feat(plugin-react-router): React Router 7 / Remix support for Rsbuild #4186

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

ScriptedAlchemy
Copy link
Contributor

@ScriptedAlchemy ScriptedAlchemy commented Dec 13, 2024

Summary

This pull request includes several updates and additions to the examples/react-router-sample directory, enhancing the React Router integration and adding various features such as server-side rendering, custom loaders, and CSS styles. The most important changes are summarized below:

Enhancements to React Router Integration:

  • Added a new custom loader in app/about.loader.tsx to simulate data fetching with a delay and return environment-specific messages.
  • Implemented a new layout component in app/layout.tsx with a header, navigation, and message board using React Router's useLoaderData and useNavigation hooks.
  • Created a new routes configuration in app/routes.tsx that dynamically loads components and their respective loaders/actions based on the environment (client/server).

Server-Side and Client-Side Enhancements:

  • Added server-specific loader and action functions in app/layout.server.tsx to handle data fetching and form submissions on the server.
  • Included client-specific loader and action functions in app/layout.client.tsx for handling client-side data fetching and form submissions.

Styling and UI Improvements:

  • Added comprehensive CSS styles for various components including the layout, home, and about pages in app/layout.module.css, app/home.module.css, and app/about.module.css. [1] [2] [3]

Documentation and Configuration:

  • Updated the README.md in the examples/react-router-sample directory to include instructions for running and developing the app.
  • Modified biome.json and cspell.config.cjs to include new paths for ignoring build artifacts and public directories. [1] [2]

These changes collectively enhance the functionality, maintainability, and user experience of the sample React Router application.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Dec 13, 2024

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit f318d3c
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/67638b1977c3d30008c21033
😎 Deploy Preview https://deploy-preview-4186--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 72 (🔴 down 12 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -25,6 +25,14 @@ type ManifestList = {
};
/** Flatten all assets */
allFiles: FilePath[];
/** Assets grouped by chunk name */
namedChunks: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding an option like /webpack-manifest-plugin#generate for customizing the manifest content?

I feel that different users may need different manifest formats, and the generate function can meet differentiated needs. For example, plugin-react-router can generate namedChunks through the generate function.

If this is feasible, I will add the generate option to Rsbuild soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay yeah i can add a generate option, will keep the named chunks for now, then once rsbuild api allows me to send more than true/false to it for manifest, i can move this to my plugin if you do not want to keep named chunks - however i do think named chunks is quite standard output from many stats tools as a default :P. so may be worth providing OOTB?

Copy link
Member

@chenjiahan chenjiahan Dec 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite standard output from many stats tools as a default

Can you provide some references?

We might want to consider making namedChunk optional since it appears to share some overlapping information with the existing entries property. This could help optimize the manifest size.

- Updated '@types/react' and '@types/react-dom' to version 18.3.16 and 18.3.5 respectively.
- Added '@types/react-router' at version 5.1.20.
- Enhanced server-side rendering (SSR) response handling in entry.server.tsx and server.mjs for better streaming support.
- Refactored HTML generation in handleDocumentRequest for improved readability and maintainability.
- Adjusted TypeScript configuration to target ES2022 and include additional libraries.
- Enhanced server-side rendering (SSR) capabilities in entry.server.tsx by introducing new functions for handling data requests and managing streaming responses.
- Refactored response handling in server.mjs to streamline streaming and buffered response management.
- Updated TypeScript configuration to target ES2020 and utilize ESNext module resolution for better compatibility.
- Improved error handling and response header management for SSR requests.
…king

- Added a cspell comment to entry.server.tsx to specify words for spell checking, enhancing code quality and maintainability.
@ScriptedAlchemy ScriptedAlchemy changed the title React router feat(plugin-react-router): React Router 7 / Remix support for Rsbuild Dec 14, 2024
- Deleted obsolete entry.client.tsx and entry.server.tsx files to streamline the project structure.
- Updated entry paths in plugin-react-router to reflect the removal of file extensions for better compatibility.
- Refactored entry.client.tsx template to improve code consistency and maintainability.
…te handling

- Introduced a new `loadRouteModule` function to enhance the loading of route modules in development mode, improving error handling and caching.
- Renamed the original `loadRouteModule` function to `_loadRouteModule` to avoid conflicts.
- Updated the transform logic in the plugin to accommodate the new function, ensuring better performance and reliability during route imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants