mirror of https://github.com/alibaba/ice.git
feat: support option rootId to empty root (#7031)
CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Details
CI / build (16.x, windows-latest) (push) Has been cancelled
Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled
Details
CI / build (18.x, windows-latest) (push) Has been cancelled
Details
Coverage / coverage (16.x) (push) Has been cancelled
Details
Release / Release (16) (push) Has been cancelled
Details
CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Details
CI / build (16.x, windows-latest) (push) Has been cancelled
Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled
Details
CI / build (18.x, windows-latest) (push) Has been cancelled
Details
Coverage / coverage (16.x) (push) Has been cancelled
Details
Release / Release (16) (push) Has been cancelled
Details
This commit is contained in:
parent
412faf03d1
commit
bb60ab5a04
|
@ -1,5 +1,9 @@
|
|||
# @ice/plugin-stream-error
|
||||
|
||||
## 1.0.3
|
||||
|
||||
- feat: empty root element when stream error
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/plugin-stream-error",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
|
|
@ -2,13 +2,16 @@ import type { Plugin } from '@ice/app/types';
|
|||
|
||||
interface PluginOptions {
|
||||
activeInDev?: boolean;
|
||||
rootId?: string;
|
||||
}
|
||||
|
||||
const PLUGIN_NAME = '@ice/plugin-stream-error';
|
||||
const plugin: Plugin<PluginOptions> = (options = {}) => ({
|
||||
const plugin: Plugin<PluginOptions> = (options = {
|
||||
rootId: 'root',
|
||||
}) => ({
|
||||
name: PLUGIN_NAME,
|
||||
setup: ({ generator, context }) => {
|
||||
const { activeInDev } = options;
|
||||
const { activeInDev, rootId } = options;
|
||||
const { userConfig } = context;
|
||||
if (userConfig.ssr) {
|
||||
generator.addEntryCode((originalCode) => {
|
||||
|
@ -18,6 +21,11 @@ if (import.meta.renderer === 'client') {
|
|||
// _$ServerTimePoints will returned at the end of last stream,
|
||||
// if the value is undefined, try to re-render app with CSR.
|
||||
if (${activeInDev ? '' : 'process.env.NODE_ENV === \'production\' && '}!window._$ServerTimePoints && window.__ICE_APP_CONTEXT__.renderMode === 'SSR') {
|
||||
const root = document.getElementById('${rootId}');
|
||||
if (root) {
|
||||
root.innerHTML = '';
|
||||
}
|
||||
window.__ICE_APP_CONTEXT__.renderMode = 'CSR';
|
||||
render({ hydrate: false });
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue