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
|
# @ice/plugin-stream-error
|
||||||
|
|
||||||
|
## 1.0.3
|
||||||
|
|
||||||
|
- feat: empty root element when stream error
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@ice/plugin-stream-error",
|
"name": "@ice/plugin-stream-error",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
@ -2,13 +2,16 @@ import type { Plugin } from '@ice/app/types';
|
||||||
|
|
||||||
interface PluginOptions {
|
interface PluginOptions {
|
||||||
activeInDev?: boolean;
|
activeInDev?: boolean;
|
||||||
|
rootId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLUGIN_NAME = '@ice/plugin-stream-error';
|
const PLUGIN_NAME = '@ice/plugin-stream-error';
|
||||||
const plugin: Plugin<PluginOptions> = (options = {}) => ({
|
const plugin: Plugin<PluginOptions> = (options = {
|
||||||
|
rootId: 'root',
|
||||||
|
}) => ({
|
||||||
name: PLUGIN_NAME,
|
name: PLUGIN_NAME,
|
||||||
setup: ({ generator, context }) => {
|
setup: ({ generator, context }) => {
|
||||||
const { activeInDev } = options;
|
const { activeInDev, rootId } = options;
|
||||||
const { userConfig } = context;
|
const { userConfig } = context;
|
||||||
if (userConfig.ssr) {
|
if (userConfig.ssr) {
|
||||||
generator.addEntryCode((originalCode) => {
|
generator.addEntryCode((originalCode) => {
|
||||||
|
@ -18,6 +21,11 @@ if (import.meta.renderer === 'client') {
|
||||||
// _$ServerTimePoints will returned at the end of last stream,
|
// _$ServerTimePoints will returned at the end of last stream,
|
||||||
// if the value is undefined, try to re-render app with CSR.
|
// 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') {
|
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 });
|
render({ hydrate: false });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue