Page MenuHomePhabricator

[Spike] Code Splitting: Explore "package for every component" approach
Closed, ResolvedPublic8 Estimated Story Points

Description

Summary

As part of our investigation of potential different solutions to the problem of minimizing bundle size / code splitting, one option on the table is to investigate doing a separate package for every component. We should prototype this option and describe the tradeoffs, at least for completeness' sake.

Acceptance Criteria

  • Create a prototype illustrating what this would look like with Web's use cases in mind
  • Create a list of pros/cons to this solution to factor into our next steps / decision-making

Event Timeline

One thing to keep in mind here is that some Codex components (like Combobox) themselves depend on other components within the library (Button, TextInput, Menu, etc).

If we're packaging up components individually, we might need to consider the trade-offs between ensuring each component package is self-contained (bundling all a component's dependencies in the package) versus ensuring that there is no chance for redundancy (at the cost of requiring the user to keep track of the component's dependencies themselves).

Maybe there is a way to leverage some kind of automated solution to get the best of both worlds – a PHP function that accepts a list of desired Codex components as arguments (similar to how we handle icons) and returns a minified JS file with only the specified components and any dependencies they might have...

Vite can generate a manifest.json file that is basically a dependency graph. This might be something to explore in another spike task, T343144

Catrope set the point value for this task to 8.
Catrope removed the point value for this task.
Catrope set the point value for this task to 8.

Change 943652 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[design/codex@main] Build: Generate stand-alone Codex bundles for every component

https://gerrit.wikimedia.org/r/943652

Change 944325 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex@main] [WIP] Build multiple bundles

https://gerrit.wikimedia.org/r/944325

CCiufo-WMF renamed this task from [SPIKE] Code Splitting: Explore "package for every component" approach to [Spike] Code Splitting: Explore "package for every component" approach.Aug 11 2023, 9:19 PM
Catrope subscribed.

This spike is now done, and the work/discussion continues on T344386.

Change 943652 abandoned by Eric Gardner:

[design/codex@main] [PoC, DNM] Build: Generate Codex bundles for every component

Reason:

Abandoned in favor of https://gerrit.wikimedia.org/r/c/design/codex/+/958597/

https://gerrit.wikimedia.org/r/943652

Change 944325 abandoned by Eric Gardner:

[design/codex@main] [WIP] Build multiple bundles

Reason:

See https://gerrit.wikimedia.org/r/c/design/codex/+/958597

https://gerrit.wikimedia.org/r/944325