Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!