File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " react-server-renderer" ,
3- "version" : " 0.1.0 " ,
3+ "version" : " 0.1.1 " ,
44 "description" : " simple React SSR solution inspired by vue-server-render" ,
55 "repository" : " git@github.com:JounQin/react-server-render.git" ,
66 "main" : " lib/index.js" ,
2727 },
2828 "peerDependencies" : {
2929 "react" : " ^16.2.0" ,
30- "react-dom" : " ^16.2.0" ,
31- "serialize-javascript" : " ^1.4.0"
30+ "react-dom" : " ^16.2.0"
3231 },
3332 "dependencies" : {
3433 "lodash" : " ^4.17.4" ,
3534 "resolve" : " ^1.5.0" ,
35+ "serialize-javascript" : " ^1.4.0" ,
3636 "source-map" : " ^0.6.1"
3737 },
3838 "devDependencies" : {
4242 "prettier" : " ^1.9.2" ,
4343 "react" : " ^16.2.0" ,
4444 "react-dom" : " ^16.2.0" ,
45- "serialize-javascript" : " ^1.4.0" ,
4645 "tslint" : " ^5.8.0" ,
4746 "tslint-config-prettier" : " ^1.6.0" ,
4847 "tslint-plugin-prettier" : " ^1.3.0" ,
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ export function createBundleRendererCreator(
144144 if ( rendererOptions && rendererOptions . template ) {
145145 renderStream
146146 . on ( 'beforeStart' , ( ) => res . emit ( 'beforeStart' ) )
147- . on ( 'beforeEnd' , ( ) => res . emit ( 'beforeEnd' ) )
148- . on ( 'redirect' , url => res . emit ( 'redirect' , url ) )
147+ . on ( 'beforeEnd' , ( ... args ) => res . emit ( 'beforeEnd' , ... args ) )
148+ . on ( 'redirect' , ( ... args ) => res . emit ( 'redirect' , ... args ) )
149149 }
150150
151151 renderStream . pipe ( res )
Original file line number Diff line number Diff line change @@ -58,15 +58,24 @@ export default class TemplateStream extends Transform {
5858 }
5959 }
6060
61- this . push ( this . template . neck ( this . context ) + '<div id="app">' )
61+ this . push ( this . template . neck ( this . context ) )
62+
63+ if ( this . inject ) {
64+ this . push ( '<div id="app">' )
65+ }
6266 }
6367
6468 _flush ( done : ( ) => void ) {
65- this . emit ( 'beforeEnd' )
69+ this . emit ( 'beforeEnd' , this . started )
6670
67- this . push ( '</div>' )
71+ if ( ! this . started ) {
72+ done ( )
73+ return
74+ }
6875
6976 if ( this . inject ) {
77+ this . push ( '</div>' )
78+
7079 const { asyncContext } = this . context
7180
7281 if ( asyncContext ) {
You can’t perform that action at this time.
0 commit comments