lasso-js / lasso

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

Lasso Prebuild #251

Closed austinkelleher closed 6 years ago

austinkelleher commented 7 years ago

Currently, when Lasso is being configured on the server for the first time, it builds the pages for the first time. This causes initial startup time to be slow. We should allow Lasso to generate prebuild files that can then be loaded at runtime on the server during the initial load. Flags can be passed to prebuildPage, so that there can be multiple prebuilds for a single page.

lasso.prebuildPage({ ... })
lasso.loadPrebuild({ ... })

page.prebuild.json

[
  {
    "slots": {
      "body": "<script src=\"./test.js\"></script>",
      "head": "<link rel=\"stylesheet\" href=\"./style.css\">"
    },
    "name": "page"
  },
  {
    "slots": {
      "body": "<script src=\"./test.js\"></script>",
      "head": "<link rel=\"stylesheet\" href=\"./style.css\">"
    },
    "flags": ["mobile"],
    "name": "page"
  }
]