Custom components remove sibling vendor CSS

Hello hello.

I noticed strange behavior when multiple custom components are in the same app.
I dug around to figure out if it was something weird with the way I was importing the vendor CSS or what and found the culprit.

When provideDependencies receives a different manifest, it:

  • compares JSON.stringify values
  • clears the shared module cache
  • then removes every stylesheet link in the accidentally(?) shared cache - a4 below:
provideDependencies(t) {
  this.dependencies && JSON.stringify(this.dependencies) !== JSON.stringify(t) && (Object.keys(l0$1).forEach(o => delete l0$1[o]),
  Object.keys(a4).forEach(o => {
	let r = a4[o];
	r.parentNode?.removeChild(r),
	delete a4[o]
  }
  )),
  this.dependencies = t
}

An existing sibling component can therefore lose its vendor stylesheet while its rendered content remains present.

Reproduction:

  • Create two custom components that utilize different vendor CSS imports.
    • tabulator-tables and react-big-calendar, for example:
      • In uib-tabulator → @/app/app.tsx: import 'tabulator-tables/dist/css/tabulator.min.css';
      • In uib-rbc → @/app/app.tsx: import 'calendar/lib/css/react-big-calendar.css';
  • Place both within the same UIB app.
  • Reload page and check header tags for vendor CSS links.
  • Observe that only the final custom component to initialize retains it’s vendor CSS link; all others are removed.

Workaround:

  • Manually add vendor CSS as custom component local files.

Create uib-tabulator → @/tabulator.min.css and copy the vendor CSS into it.

Then, in @/app/app.tsx:

/* import 'tabulator-tables/dist/css/tabulator.min.css'; */
import '@/tabulator.min.css';

Hope this helps!

Hi @Audio

Thanks for the detailed investigation. We’ve confirmed this is a bug: when multiple custom components use different dependency manifests, initializing one component can remove vendor stylesheets still needed by another. I’ve escalated it to our engineering team.

As a workaround, add the vendor stylesheet as a local file in each affected custom component and import that file instead of importing it from the package:

// Replace:
// import 'tabulator-tables/dist/css/tabulator.min.css';

import '@/tabulator.min.css';

Local CSS is bundled with the component and won’t be removed when another custom component initializes.

One more option going by that snippet: the cache only gets cleared when the manifests differ as JSON strings. So if you can give all the custom components the exact same dependency list (same packages, same versions, same order), the stylesheets shouldn’t get wiped at all. Probably easier than the local CSS copy if you’ve got a lot of components.