lasso-js / lasso

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

Problem: How to generate all static assets for the whole app? #192

Open schetnikovich opened 7 years ago

schetnikovich commented 7 years ago

Hello!

For application like "marko-js-samples/marko-lasso", what command can help us to generate all static assets for the whole application? When you use Lasso.js Taglib for Marko, static assets usually generated when you visit page for the first time. This results in a long pause for the first visitor of each page (and, most importantly, prevents us to use readonly filesystems, found in Docker or Amazon Lambda)

Today we use the following package, written by me: lasso-marko-extras. It was mostly "okay" for Marko v3 and relied heavily on browser.json and explicit listing of all used tags on each page.

With Marko v4 I see support for automatic dependencies tracking (i.e., when you use some tag, you do not need to list it in page's browser.json). With this new version of Marko, developers usually don't use browser.json anymore, in most cases. It means, that we need to find another way to generate all static assets for the whole app.

How do you solve this problem? Can you point me to some direction that will solve this problem for Marko v4?

Thank you!

mlrawlings commented 7 years ago

With Marko 4.0, you can load a *.marko file and call getDependencies() which will give you an object structured similarly to a browser.json dependencies array

schetnikovich commented 7 years ago

@mlrawlings, thank you! We added compatibility with Marko v4 by using getDependencies().

Everything seems working so far :)

Did you consider adding support for "packaging for deploy to production" functionality for those of us, who prefer to use <lasso-page />, <lasso-img /> and other tags from Lasso.js Taglib for Marko? Today we use lasso-marko-extras that is simple, but we always worry, that we are doing something different, than Lasso.js Taglib for Marko. Conceptually, we just want to prepare all static assets at compile time, instead of runtime. But we would like to continue to use Taglib for Marko :)

Thank you!