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

Optimize server compilation of routes config #6857

Open
ClarkXia opened this issue Apr 8, 2024 · 0 comments
Open

Optimize server compilation of routes config #6857

ClarkXia opened this issue Apr 8, 2024 · 0 comments
Labels

Comments

@ClarkXia
Copy link
Collaborator

ClarkXia commented Apr 8, 2024

Summary | 概述

No response

Motivation | 背景

The framework will analyze all route components and retrieve the pageConfigexport, regardless of whether the application is configured as SPA. The purpose of extracting pageConfig from each route component is to modify the initial HTML generated by the document, including elements like title and meta.

However, when it comes to SPA configurations, updating the initial HTML with pageConfig isn't necessary, as there is often a separate server dedicated to serving HTML. Additionally, the compilation process for pageConfig tends to result in errors due to certain pieces of code and dependencies that are incompatible with Node.js.

Furthermore, this additional compilation step can significantly hinder the development velocity of the framework by introducing extra complexity and processing time.

Usage example | 使用示例

No response

Detailed design | 方案设计

The compilation step for routes-config.bundle.mjs will be eliminated to address concerns in two specific scenarios:

  • SPA : The initial HTML will not be dynamically updated with route-specific pageConfig prior to client-side rendering. Instead, it will be updated once the client bundle has been executed and the application is running in the browser.
  • SSR / SSG : The initial HTML will indeed be updated with pageConfig derived directly from the route components' configurations during server-side execution or static site generation.

To accommodate cases where custom plugins need access to a specific route's configuration, such as PHA plugin, the framework will continue to provide an API named getRoutesConfig. This ensures that while direct compilation is removed to streamline processes, essential route configuration information remains accessible as needed.

Additional context | 额外信息

For apps configured as SPA, the pageConfig will not be applied to update the HTML. Developers who need to customize the initial HTML structure can directly modify the document.tsx file to implement the required configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant