lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
581 stars 75 forks source link

Lasso / Marko: server-render does not send entire HTML down #193

Closed maximilianschmitt closed 7 years ago

maximilianschmitt commented 7 years ago

Hi!

I'm using Lasso 2.11.7, Marko 4.2.0 and lasso/middleware to serve my example app with express. I'm getting the following HTML rendered if I view-source:

<!doctype html><html><head><title Renderer></title></head><body><div>Hello world</div><div><img src="/static/icon-edit-557d230d.svg">

(scroll to see that it's incomplete)

The svg is being pulled in with lasso-img. I'm expecting something like this:

<!doctype html><html><head><title Renderer></title></head><body><div>Hello world</div><div><img src="/static/icon-edit-557d230d.svg"></div></body></html>

If I restart the server it will render correctly the first time I hit the page. All subsequent requests are served incomplete HTML.

The code I'm using for express:

'use strict'

require('marko/node-require') // allow requiring templates

var express = require('express')

var app = express()

app.get('/', function (req, res, next) {
  require('./index.marko').render({}, res)
})

app.use(require('lasso/middleware').serveStatic())

app.listen(8001, function () {
  console.log('Listening on port 8001')
})

require('lasso').configure({
  plugins: [
    'lasso-marko'
  ],
  outputDir: __dirname + '/static'
})

I also put this in an example repository: https://github.com/maximilianschmitt/lasso-test

patrick-steele-idem commented 7 years ago

/cc @mlrawlings

mlrawlings commented 7 years ago

Thanks for the report! Fixed via https://github.com/lasso-js/lasso/commit/b81bc848ccfc3ba49abffca2199410b75322d094. lasso@2.11.8 published.

maximilianschmitt commented 7 years ago

Nice, thanks for the quick fix! :)