Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Storybook doesn't work with renamed exports

I am writing a component library in/for react and using Rollup to bundle it. As part of the build process I am using Terser to make sure the bundle is as small as possible. As part of the minification process, Terser renames the variables and then renames then back at export. Like so:

export{_ as BtnResponsive,l as Button};

This works fine when importing my library into other ES modules. Like so:

import { BtnResponsive } from '@namespace/component-lib';

But when I create a Storybook story Button.stories.tsx and import my component like so:

import { ComponentStory, ComponentMeta } from '@storybook/react';
import { BtnResponsive } from '@namespace/component-lib';

export default {
    title: 'Components/BtnResponsive',
    component: BtnResponsive,
} as ComponentMeta<typeof BtnResponsive>;

const Template: ComponentStory<typeof BtnResponsive> = (args) => <BtnResponsive {...args} />;

export const Primary = Template.bind({});
Primary.args = { children: 'Primary', theme: 'primary' };

Storybook then renders the component in my story like

<_ theme="primary">
  Primary
</_>

Storybook somehow doesn't respect the renamed export. Does anyone know how to either make storybook respect the component name? or know how I can adjust Terser so Storybook understands the name correctly?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Terser apparently has options that you can use to prevent it from mangling function names. In my rollup.config.js I had to add the following:

terser({
  keep_fnames: true,
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda