-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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(preset-umi): throw by default when pre-render error #11521
feat(preset-umi): throw by default when pre-render error #11521
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #11521 +/- ##
==========================================
- Coverage 29.03% 29.02% -0.01%
==========================================
Files 484 484
Lines 14701 14705 +4
Branches 3473 3475 +2
==========================================
Hits 4268 4268
- Misses 9678 9681 +3
- Partials 755 756 +1
☔ View full report in Codecov by Sentry. |
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.
+1
@@ -58,6 +58,9 @@ function getExportHtmlData(routes: Record<string, IRoute>): IExportHtmlItem[] { | |||
* get pre-rendered html by route path | |||
*/ | |||
async function getPreRenderedHTML(api: IApi, htmlTpl: string, path: string) { | |||
const { | |||
exportStatic: { ignorePreRenderError = false }, |
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.
下面还有一个 api.config.mountElementId
,所有的属性解构应该放在一起。
@@ -82,6 +85,9 @@ async function getPreRenderedHTML(api: IApi, htmlTpl: string, path: string) { | |||
logger.info(`Pre-render for ${path}`); | |||
} catch (err) { | |||
logger.error(`Pre-render ${path} error: ${err}`); | |||
if (!ignorePreRenderError) { | |||
throw err; |
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.
throw new Error('Pre render error', { cause: err })
@@ -654,6 +654,17 @@ export default { | |||
} | |||
``` | |||
|
|||
`exportStatic` 在搭配 `ssr` 使用时会进行预渲染,在预渲染失败时会抛出异常并终止构建,可以通过配置 `ignorePreRenderError` 来忽略预渲染失败的错误,例如: |
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.
- `exportStatic` 在搭配 `ssr` 使用时会进行预渲染,在预渲染失败时会抛出异常并终止构建,可以通过配置 `ignorePreRenderError` 来忽略预渲染失败的错误,例如:
+ `exportStatic` 在搭配 `ssr` 使用时会进行预渲染,默认在预渲染失败时会抛出异常并终止构建,通过配置 `ignorePreRenderError` 来忽略预渲染异常报错,例如:
Background
现在 Pre-render 失败时仍会跑完整个构建,用户不注意的话就不会发现有编译问题。
Solution
exportStatic.ignorePreRenderError
配置,开启后会和以前的行为一样