Conditional bundling using Lasso Flags in a CI job.
pedramphp opened this issue · 1 comments
Hi team,
it's been a long time, I hope everyone is doing great.
I am trying to dynamically generate JS bundles for a SDUI experience. The list of components are dynamically resolved during run time, since the server drivers the UI, passing down UI Model to the Node.js server.
The question that I have is, can we leverage Lasso flags (one flag per component) to generate bundles during run time (server startup or application load time)?
I am not sure if Lasso creates the bundles during build time or run time? if it creates the bundles during build time, then the number of generated files will grow exponentially (All possible permutations) dependent on the number of flags.
if there is a warm-up mode, which we can run the Node.js server by kicking off a CI job, making request to the presentation service, then Lasso can detect what are the dependencies and then generate the bundle. in this case bundles are created and locked during runtime before its deployed to Production.
The only problem with approach is whenever there is a change in the Presentation service response, the bundles needs to get generated and uploaded to the CDN.
I have checked both Webpack and Rollup, they both don't have a solution to the problem.
Please share your thoughts
Mahdi
Lasso builds all bundles as they are requested to the server. A typical lasso warmup script simply hits the url's early so that lasso's cache would be primed.
If you use lasso flags, each flag set is bundled on the fly as it is requested at runtime.
You can write a writer plugin to tell lasso how to upload assets to different locations. You can see https://github.com/lasso-js/lasso-s3-writer as an example.