Skip to main content

foundation-utils.avoidtreeshaking

Home > @genesislcap/foundation-utils > avoidTreeShaking

avoidTreeShaking() function​

Explicitly prevents tree-shaking of custom element classes by referencing them.

Bundlers may incorrectly remove code that it thinks has no side effects, such as custom element definitions that are only referenced in templates. By passing these classes to avoidTreeShaking, we create a side effect that signals to the bundler to preserve the code.

Signature:

avoidTreeShaking: (...classes: unknown[]) => void

Parameters​

Parameter

Type

Description

classes

unknown[]

One or more custom element classes that should not be tree-shaken.

Returns:

void