Install

Works with Drupal: ^11 || ^12

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 90.53 KB
MD5: 18ef5b324ed523bda4c4375de9704ba9
SHA-1: dd97678a4ace537e6e26015b786b36f6881ba740
SHA-256: 5d447890ad127a73e58836c22ce3932277d2c222134aca5122be46568dabc2bd
Download zip 175.49 KB
MD5: 96f58192e8b23096256920114d777a15
SHA-1: 38a39dcc93f215ff20a4fc3428f71104fb73e001
SHA-256: d446c81c776ac8d3a24778f71094336a44dbb878b84d0355848bbaf83c8a984d

Release notes

1.2.0 integrates with Drupal Canvas through a new submodule, web_component_runtime_canvas, and moves the base path handover from the import map onto each library's own scripts, so a base path reaches every document its library does. Registry files don't change, so 1.1 libraries keep working.

New features

  • Canvas submodule (#3627761). Everything Canvas-specific lives in web_component_runtime_canvas, which depends on Canvas, so Canvas stays optional for registered libraries. Enable it on sites that use Canvas.
  • One import map on Canvas pages (#3627762). On a page with a registered library, the submodule folds Canvas's own import map into the runtime's, so a page with a Canvas code component and a registered library's component has one map instead of two. Canvas's entries win a conflict, its modulepreload links stay for its own entries only, and the map keeps its CSP nonce. A page with no registered library keeps Canvas's map as before.
  • Import maps in component previews (#3627762). Canvas's Library hover previews get the registry's entries, the <head> script and, for a lazy library, the lazy loader, so a registered library's components upgrade there.
  • Base paths through the library's scripts (#3627762). A library with base_path_api: { attribute: data-… } gets the attribute on its own first script, or on the lazy loader's in lazy mode. A library with { module: …, export: … } gets a module script served from /web-component-runtime/base-path/{library}, loaded right before its own, which calls the setter. Both reach full pages, AJAX responses, BigPipe placeholders and Canvas previews.

Upgrading

  • On a site with Canvas, enable web_component_runtime_canvas and export your configuration. Canvas component versions don't change, since Canvas computes them from a component's source settings, slots and props only.
  • Rebuild caches after updating, so Canvas rebuilds its Library previews. Base path URLs are fixed when Drupal builds its script cache, so a site moved to another base path needs its caches rebuilt too.
  • Libraries don't need changes. base_path and base_path_api work as before. An attribute library has to look for its attribute on any <script>, as Shoelace-style libraries and cw-elements do. One that only reads it from the import map's element should use a setter instead.
  • Code that uses the runtime's classes directly: ImportMap no longer has $basePathAttributes, $basePathSetters or hasBasePaths(), HtmlHeadImportMapEmitter::SETTER_KEY_PREFIX is gone, and the AJAX import map command's data no longer carries basePathAttributes or basePathSetters. ImportMapBuilder gains url() and pageAttachments().

Content Security Policy

With the Content-Security-Policy module, the import map still carries the response's nonce, Canvas pages included. Base path setters are now ordinary same-origin script files instead of inline scripts, so they need no nonce: a policy that allows 'self' for scripts allows them.

Requirements

Drupal 11 or 12, with no new dependencies. The Canvas submodule needs Drupal 11.3 or later and Canvas, which Composer doesn't install for you.

See the README's "Canvas" and "Base paths" sections for details.

Created by: matthand
Created on: 28 Nov 2026 at 17:54 UTC
Last updated: 28 Nov 2026 at 17:59 UTC
New features
Unsupported

Other releases