fix(storybook): replace require() with ESM import in Toast stories

The RealAlertApiStory component used require('@backstage/core-plugin-api')
inside the function body. Vite bundles Storybook as ESM, where require is
not available at runtime, causing a ReferenceError. Replace with a
standard top-level import.

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
Made-with: Cursor
This commit is contained in:
Charles de Dreuille
2026-03-30 11:55:27 +01:00
parent e21dd5edc4
commit b651807e56
@@ -19,6 +19,7 @@ import preview from '../../../../../.storybook/preview';
import { Button, Flex, Text } from '../../../../../packages/ui/src';
/* eslint-enable @backstage/no-relative-monorepo-imports */
import { ToastQueue } from '@react-stately/toast';
import { useApi, alertApiRef } from '@backstage/core-plugin-api';
import { ToastContainer } from './index';
import type { ToastApiMessageContent } from './types';
import { MemoryRouter } from 'react-router-dom';
@@ -567,8 +568,6 @@ export const AlertApiIntegration = meta.story({
* Backstage app where the app plugin's elements.tsx is used.
*/
function RealAlertApiStory() {
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
const { useApi, alertApiRef } = require('@backstage/core-plugin-api');
const alertApi = useApi(alertApiRef);
return (