Unify import maps between backend and code editor preview
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3552914. --> Reported by: [balintbrews](https://www.drupal.org/user/613760) Related to !682 !708 >>> <h3>Overview</h3> <p>Code Components rely on an <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap">import map</a> for their code. This import map is generated by the backend, and the logic is duplicated in the code editor preview.</p> <h3>Proposed resolution</h3> <ol> <li>Unify building the import map on the backend, and pass it to the UI app via <code>drupalSettings</code>. The import map is currently duplicated between the backend (see the latest changes in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3553356" title="Status: Closed (fixed)">#3553356: Allow @plugins support in Global CSS</a></span> and the <a href="https://git.drupalcode.org/project/canvas/-/blob/cfdac0ce82ed8382051fd863efa465bd076b9df9/ui/src/features/code-editor/Preview.tsx#L77">code editor's <code>Preview</code> component</a>. Make sure this is driven by the backend.</li> <li>Document how to alter the import map. See <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3553356" title="Status: Closed (fixed)">#3553356: Allow @plugins support in Global CSS</a></span>.</li> </ol> <h3>User interface changes</h3> <p>n/a</p> > Related issue: [Issue #3398525](https://www.drupal.org/node/3398525) > Related issue: [Issue #3560197](https://www.drupal.org/node/3560197) > Related issue: [Issue #3553356](https://www.drupal.org/node/3553356)
issue