dgp1130 / rules_prerender

A Bazel rule set for prerending HTML pages.
13 stars 0 forks source link

Extract published components #64

Open dgp1130 opened 1 year ago

dgp1130 commented 1 year ago

Currently link_prerender_component() has a pretty minimal implementation. It doesn't support CSS or resources and just copies the same NPM package for prerendering and client-side scripts. We should make a proper extractor which splits the NPM package into distinct TreeArtifacts containing all the individual files for each slice. A few challenges with making this happen:

  1. We basically don't know anything until execution time. What resource files exist, what CSS files exist, etc. is no longer known at analysis time. This means all our providers and implementation details around prerender_component() and prerender_pages() need to be updated to not require analysis-time knowledge. This is probably most impactful for CSS import resolution, which is currently done at analysis time and will need to be updated.
  2. Prerender and client side JS need to be separated, but both should be importable from the same NPM package. This means we'd need to link two different implementations for the same NPM package. This could introduce weird errors if they were ever both imported in the same target (which generally shouldn't happen but is technically possible).
  3. Prerender and client side JS need to exist in two distinct TreeArtifacts but are imported by the package of that name. If we generate dist/bin/node_modules/@rules_prerender/declarative_shadow_dom_prerender, then it would be laid out that way in the output dir of the renderer binary, meaning it needs to be imported at @rules_prerender/declarative_shadow_dom_prerender. We could trivially name the directory the same as the target, but only one directory can have that name, and we have two, leading to conflicts.
dgp1130 commented 1 year ago

Not sure if this is strictly necessary for 1.0.0 if what I have is good enough for officially supported prerender_components(), but I'm adding it to the milestone to make sure I at least don't forget as we approach 1.0.0.