You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have a layout named default and two pages, A and B, that each use the layout. Pages A and B have resources that are common between them, so default has a browser.json. For example:
{
"dependencies": [
"./foo.css",
"./bar.js"
]
}
Further, page A does not depend on any extra resources but page B does. Thus, page B has a browser.json:
<lasso-pagepackage-path="./browser.json" /><layout-use('../../layouts/default/template.marko')><layout-putinto="content"><form>some form that gets validated by `baz.js`</form></layout-put></layout-use>
Then when we render the page baz.js will not be referenced; only the lasso-page in the default layout gets processed.
So, in order to "fix" this, we have to remove the lasso-page from the layout template and add one to each of the templates for A and B. Then each page A and B will need to include a dependency of "../../layouts/default/browser.json". Whereas before, A didn't even need a browser.json and B's only listed the additional dependency.
This is quite cumbersome. I'd like to see lasso-marko create a union of all the dependencies listed in all referenced browser.json files. I also think the inner-most dependencies should be inserted last. In this case it would be, for page B:
Thank you for writing up your thoughts @jsumners. @mlrawlings is working on an enhancement to support static code analysis of marko templates to discover which dependencies need to be sent down to the browser. That is, we are making enhancements to allow <lasso-page/> to be invoked with no attributes and it will automatically inspect the page template and all of its dependencies to determine which dependencies need to be sent down from the browser. In addition, if you are using the lasso CLI then the lasso CLI will now support a --page argument:
lasso --page src/pages/home
I think these changes will address any concerns around repetition since it will all be driven off of static code analysis (even for the top-level page).
We'll update here with updates. If you have any other ideas or thoughts, please share. Thanks again.
@mlrawlings has made good progress on this enhancement and demoed it internally this past week with marko v4. Michael, do you want to add any more comments?
Senario:
You have a layout named
default
and two pages,A
andB
, that each use the layout. PagesA
andB
have resources that are common between them, sodefault
has abrowser.json
. For example:Further, page
A
does not depend on any extra resources but pageB
does. Thus, pageB
has abrowser.json
:Now, if the layout were:
And the template for
B
is:Then when we render the page
baz.js
will not be referenced; only thelasso-page
in thedefault
layout gets processed.So, in order to "fix" this, we have to remove the
lasso-page
from the layout template and add one to each of the templates forA
andB
. Then each pageA
andB
will need to include a dependency of"../../layouts/default/browser.json"
. Whereas before,A
didn't even need abrowser.json
andB
's only listed the additional dependency.This is quite cumbersome. I'd like to see
lasso-marko
create a union of all the dependencies listed in all referencedbrowser.json
files. I also think the inner-most dependencies should be inserted last. In this case it would be, for pageB
:The text was updated successfully, but these errors were encountered: