1435: Update Storybook to latest version and move to Vite - #495
Conversation
…t path Emulsify Core 4's Vite build nests compiled component JS under dist/js/components/... instead of the old flat dist/js/... layout.
…itializes
dist/js/components/03-organisms/calendar/yds-calendar.js is a real ES module under
the Vite build -- it begins with
`import{n as g}from"../../../../assets/micromodal.es-*.js"`. The calendar and the
modal component both import micromodal, and Rollup hoists a module shared by two
entries into dist/assets/; the webpack build inlined it per entry, which is why
this was a plain script before and why the library never needed a micromodal
dependency.
Loaded as a classic script, a top-level import is a parse-time SyntaxError, so
nothing in the file runs and Drupal.behaviors.eventsCalendar is never registered.
The calendar renders its markup and is completely inert: no month navigation, no
event modals, no day-cell interaction, with only a console parse error to go on.
Swept all 30 CLT dist files this theme loads -- the calendar is the only one
affected (yds-modal.js is also a module but is not loaded here).
`type: module` makes the import legal. Module scripts are deferred but execute
after parsing and before DOMContentLoaded, and Drupal attaches behaviors on
DOMContentLoaded, so the behavior is registered in time. preprocess: false keeps
aggregation from concatenating a module into a classic bundle.
Not fixed on the build side because Rollup deliberately dedupes a module imported
by two entries and offers no supported way to duplicate a static import back into
each one. component-library-twig gains a test that fails when the set of ES modules
under dist/js/ changes, so the next occurrence surfaces there instead of as an
inert component in production.
|
Brought this branch current with The events calendar was inert
import{n as g}from"../../../../assets/micromodal.es-Dp1N63aw.js";Drupal.behaviors.eventsCalendar={...The Cause: the calendar and the modal component both import I swept all 30 component-library Fix: I did not fix it on the build side: Rollup deliberately dedupes a module imported by two entries and offers no supported way to duplicate a static import back into each one. VerifiedAll 30 Please click through the events calendar on the multidev before merging — this is the one thing a build-and-diff review can't confirm, and I couldn't exercise it locally because this checkout's Merge after component-library-twig #672 and before yalesites-project #1413. |
The same rationale was written out in three places across two repos, and the cross-repo copy is the one that drifts unnoticed. Keeps the part a Drupal developer reading this file needs -- why this one script is a module and what breaks without it -- and points at component-library-twig's scripts/dist-module-format.test.mjs, which enforces the contract and carries the full explanation.
|
Pushed one follow-up commit here ( The Also worth recording here: I verified that The events calendar still wants a human click-through on the multidev before merge; I couldn't exercise it locally because this checkout's |
#1435: Update Storybook to latest version and move to Vite (via Emulsify update)
Description of work
dist/js/<tier>/...library reference inatomic.libraries.ymlto the newdist/js/components/<tier>/...pathdist/css/style.css,dist/css/link-treatment.css, and the FontAwesome CSS paths are unchanged as the component-library-twig's build was patched to keep emitting those at their original locationsFunctional testing steps:
Related PRs (cross-repo work unit)
This change spans three repos and has to be reviewed and merged as one unit.
after-2260after-2260dist/layoutafter-2260getAssetPathdocsMerge order: component-library-twig → atomic → yalesites-project. The Vite build code-splits micromodal, so
dist/js/.../yds-calendar.jsis now an ES module; atomic #495 is what loads it withtype: module. If the component library ships ahead of atomic, the events calendar goes inert with nothing but a console parse error. The same coupling applies to thedist/assets/icons.svgsprite path.Issue: yalesites-org/YaleSites-Internal#1435