Skip to content

Wildcard: Move each component (group of components) in the wildcard into a separate package

Created by: vovakulikov

Follow-up for https://github.com/sourcegraph/sourcegraph/pull/40209

Problem

https://github.com/sourcegraph/sourcegraph/pull/40209 shows a few important limitation with wildcard package where all components are parts of one big package (wildcard)

  • Names collisions (if you're creating component you need to think about all other component names in the wildcard). This becomes problematic if you want to create component family in compound components style (like Root, Root.Content, Root.Trigger ....) Same problem with type names and their exports
  • In wildcard you can't use @sourcegraph/wildcard imports because jest can't resolve imports like this properly (basically because of cyclic deps) See this comment for more details

Proposal

In order to solve this problem instead of one big package (wildcard) we have to have a list of small package that expose their mimalr surface of API

For example,

  • @wildcard/button (exposes button, button groups)
  • @wildcard/geometry (exposes only types and functions about math geometry)
  • @wildcard/popover (will use @wildcard/geometry package to build popover positioning feature)
  • ...

This will solve problems with cyclic deps in most cases and problem with jest. But this won't solve cyclic deps problem in all cases but it should be more visible for devs to recognize this problem and therefore solve this problem.

/cc @taylorsperry @jasongornall