Fix cache invalidation for clsx and tailwind-merge chunks in astro-hydration build

Created on 8 January 2026, 23 days ago
Updated 9 January 2026, 22 days ago

Overview

The astro-hydration build produces separate chunks for clsx and tailwind-merge when they're imported by drupal-canvas/utils.

These chunks are imported via relative paths (e.g., import {c as o} from "./clsx.js"), which bypass the cache-busting mechanism applied to entries in Canvas's import map (added in 🐛 Provide cache buster query string on imports Active ).

This can cause runtime errors after deployments when old chunk versions are cached at edge or in browsers. The minified export names are not stable across builds (e.g., export {i as c}). When a browser loads a new utils.js expecting export {i as c} but serves a cached clsx.js with export {i as x}, the import fails:

Uncaught SyntaxError: The requested module './clsx.js' does not provide an export named 'c'

Proposed resolution

Configure the drupal-canvas package to bundle clsx and tailwind-merge using tsdown's noExternal option. This inlines the dependency code into drupal-canvas/utils, eliminating the separate chunks and their unstable relative imports.

Trade-off

This causes minor code duplication since Stub.jsx also imports clsx and tailwind-merge directly, creating separate chunks for those imports. (However, those direct imports go through the import map correctly, so cache-busting works.)

🐛 Bug report
Status

RTBC

Version

1.0

Component

Theme builder

Created by

🇳🇱Netherlands balintbrews Amsterdam, NL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024