Extras
The extras config contains options to enable new/experimental features in
Stencil, add & remove runtime for DOM features that require manipulations to
polyfills, etc. For example, not all DOM APIs are fully polyfilled when using
the Slot polyfill. Most of these are opt-in, since not all users require the
additional runtime.
appendChildSlotFix
Slotポリフィルは、デフォルトではappendChild()を更新しないため、Shadow DOMのように新しい子ノードを正しい子スロットに追加します。これは、必要な人のためのオプトインポリフィルです。
cloneNodeFix
ランタイムは、デフォルトではSlotポリフィルを使用するコンポーネントを複製するときに、cloneNode()をポリフィルしません。これは、必要な人のためのオプトインポリフィルです。
tagNameTransform
The tagNameTransform option in the extras config enables support for customizing the tag names of your Stencil components at runtime. This is especially useful if you want to add a prefix, suffix, or otherwise modify the tag names when registering your custom elements, for example to avoid naming conflicts.
When tagNameTransform is enabled in your stencil.config.ts:
extras: {
tagNameTransform: true
}
You can use the transformTagName function when calling defineCustomElements in your consuming project:
import { defineCustomElements } from 'my-button/loader';
defineCustomElements(window, {
transformTagName: (tagName: string) => `${tagName}`
} as never);
In this example, the function simply returns the original tag name, but you can customize it as needed. For example, to add a suffix:
defineCustomElements(window, {
transformTagName: (tagName: string) => `${tagName}-v1`
} as never);