mirror of https://github.com/alibaba/ice.git
				
				
				
			Merge branch 'master' into release/next
This commit is contained in:
		
						commit
						b2d93c6ffe
					
				|  | @ -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