Macros
WARNING
Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).
Two compile-time markers. They are not imported, the call itself is removed at build time, and each is mandatory in its mode: a base component declares its public surface, an override declares what it replaces.
Rules that apply to both
Shorthand bindings only. The key always equals the local binding name:
swDefinePublic({ count }); // ✓
swDefinePublic({ total: count }); // ✗ renamed
swDefinePublic({ 'count': count }); // ✗ string key
swDefinePublic({ ...state }); // ✗ spreadThe build, the lint rule and the type layer all need a key that is stable at compile time, and a renamed key could silently shadow another binding.
Once, at the top level. A second top-level call is rejected. A call nested inside a function or block is not recognised as the marker, so the file is treated as having none.
Mandatory, even when empty. Pass {} when there is nothing to declare. Writing the call is what marks the file as a base component or an override on purpose, rather than because it happens to have a <script setup> block.
One per mode. swDefinePublic() in an override file is rejected, and so is swDefineOverride() in a base component.
Every one of these is reported by the build and by the sw-core-rules/valid-shopware-setup ESLint rule. See troubleshooting.