Styles not applied when creating component library using styled-components bundled with tsup

109 views Asked by At

I have created a component library using styled-components and published it as an NPM package. I bundled it using tsup (which uses esbuild). My issue is that some (most) of the styles are not being applied, some of the components are missing entire sections and I'm not sure why. There are a lot of moving parts and other small issues which make it hard for me to pinpoint the root cause. My components are built correctly and work fine on storybook. Has anyone ever had issues bundling with tsup and styled components? Any recommended setups for creating, bundling and publishing component libraries to NPM?

I've made sure all dependencies are included and up to date in the project that is consuming this package. As well as matched the setup to how it is in my npm package.

I'm using the styled-components ThemeProvider correctly.

These are the flags im using to build the package: --format cjs --minify --clean --dts --sourcemap

I imagine there is an issue with how the package is being bundled but so far the only other solution I can think of is to use a different bundler.

0

There are 0 answers