lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Use `disableSyntheticShadowSupport` to disable synthetic-specific compiler output

Open nolanlawson opened this issue 2 years ago • 1 comments

The compiler emits specific patterns for the benefit of synthetic shadow DOM:

  • @lwc/style-compiler
    • The stylesheet function accepts the params token (undefined for native shadow) as well as useActualHostSelector and useNativeDirPseudoclass, which are always true for native shadow
  • @lwc/template-compiler
    • "Scoped IDs" (genScopedId), used to scope IDs in case of IDREF attributes like aria-labelledby
    • lwc:dom=manual config, which is unused for native shadow
  • (Maybe some other stuff I forgot)

In cases where synthetic shadow support is not needed, though (e.g. off-core), this generates extra code that contributes to the JS bundle size. For those cases, we can add a config like disableSyntheticShadowSupport which, when set to true, disables these synthetic-specific outputs.

This config could be passed to either @lwc/rollup-plugin or @lwc/compiler and would be plumbed through to sub-compilers that can use it (style compiler, template compiler, component compiler).

Checklist:

  • [x] Optimize stylesheet output (#3229)
  • [x] #3658
  • [ ] #3659
  • [ ] #4351

nolanlawson avatar Dec 16 '22 01:12 nolanlawson

This issue has been linked to a new work item: W-12230270

git2gus[bot] avatar Dec 16 '22 01:12 git2gus[bot]