Install

Works with Drupal: ^11 || ^12

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 62.45 KB
MD5: e2c7120cb08de7df11188265c3f5e4d9
SHA-1: 8608dfc7b846bcad11a23f8e8de393e21092fc4b
SHA-256: 61b4e7be8a67465daad753b9d4e666a5bbfe9ffc207a3416aa1475e75e9bd85f
Download zip 112.26 KB
MD5: 1f7ffe83b2b4e2a2a7bd500e431dd6a7
SHA-1: 9aa2f9cc575da6cf1be186ecf93ef11f2ee05b73
SHA-256: 91b4f21e6e0e7f8ac1ee6c13e4def8efd4a69cb71b3151e82ffd0c10a587a4a4

Release notes

The first stable release of Web Component Runtime: the shared runtime that makes web component libraries work in Drupal. A library module or theme registers with it through a data file and carries no runtime code of its own. Libraries generated by Custom Elements Manifest to SDC Generator, such as Cordwainer Elements from 1.1.0, depend on it.

Features

  • Library registry. An extension registers its libraries in <extension>.web_component_runtime.yml, validated against registry schema 1 (schema/web_component_runtime.schema.json). Each library is validated on its own, so an invalid one is logged to the web_component_runtime channel and left out without taking the rest of its file with it. Other modules read the result through LibraryRegistryInterface.
  • One import map per page. The map is added only to responses that load a registered library, directly or as a dependency, and goes first in the page's <head> content. AJAX responses, BigPipe placeholders included, add the entries a page doesn't define yet through an AJAX command.
  • Scoped entries. A library's imports apply only to modules under its scope, so two libraries can ship different versions of the same dependency. An entry marked global: true goes in the map's top-level imports. A scope whose path core URL-encodes is listed under both URLs.
  • Conflict detection. When two libraries map the same specifier to different addresses in the top-level imports, or within one scope, the library registered first keeps it, and the conflict is logged.
  • Content Security Policy. With the Content-Security-Policy module installed, the map carries the response's nonce and the nonce is added to the policy's script-src, unless the policy already allows inline scripts. A map added by AJAX uses the nonce of the page it lands on. The module isn't required.
  • Named slots in Twig. The slot_name filter assigns a slot's content to a custom element's named slot, as in {% apply slot_name('primary-navigation') %}. It scans the rendered HTML as text, so render and BigPipe placeholders stay intact. The has_slot_content test tells whether a slot prints anything a browser shows, so a template can leave an empty slot out and let the element show its fallback content.
  • Older generated libraries keep working. A map attached by a library generated before the generator targeted this module, such as Cordwainer Elements 1.0.x, is merged into the runtime's map, and such a library's own slot_name filter gives identical output.

Requirements

  • Drupal ^11 || ^12.
  • Browsers that support custom elements, ES modules and import maps.

Registry schema 1 is stable

A change that isn't backwards compatible will come as schema 2. A key the installed runtime doesn't know fails validation, so a misspelled key is reported instead of being silently dropped. A library that uses a field added in a later release raises its drupal/web_component_runtime constraint to that release.

The optional fields base_path, loader, tags, categories, form_controls, events and color_scheme are validated and passed on through the registry, but this release doesn't act on them yet.

Known limitations

  • Browsers before Chrome 133, Safari 18.4 and Firefox 150 honor only the first import map, and accept one added by AJAX only while no module script has loaded yet.
  • A page that renders a Canvas code component next to a registered library's component gets two import maps, Canvas's and the runtime's, until #3627762 hands the entries to Canvas. Canvas pages without code components get only the runtime's map.
  • A library's module scripts have to load from under its scope. Core never aggregates them, but a hook_js_alter() implementation or contributed aggregator that does breaks their bare imports.

Upgrading from 1.0.0-alpha1

No code changes. The README now documents the module instead of its development roadmap.

Issues in this release

  • #3627747: Scaffold the module with info file, composer.json and GitLab CI
  • #3627749: Define the library registry file and its discovery
  • #3627751: Emit one aggregated import map
  • #3627752: Scope each library's import map entries and detect global specifier conflicts
  • #3627753: Add a CSP nonce to the import map
  • #3627754: Provide the slot_name Twig filter and has_slot_content test
  • #3627947: Prepare and publish the 1.0.0 release
Created by: matthand
Created on: 23 Nov 2026 at 13:00 UTC
Last updated: 23 Nov 2026 at 13:01 UTC
New features
Unsupported

Other releases