Page MenuHomePhabricator

[Spike] Explore integrating Vite (Codex's build tool) into ResourceLoader
Closed, ResolvedPublic8 Estimated Story Points

Description

Vite (Codex's build tool) offers some support for integrating with another web application back-end.

There are some examples of different integrations here – integrations exist for applications like Rails, Laravel, Wordpress, and Craft CMS.

Could we create a similar Vite integration for MediaWiki? This may not be possible without T328699: Consider including a JS runtime as part of MediaWiki but we could at least define a clear use-case for such a runtime in this spike if we consider it to be useful.

One idea on how such an integration could work:

  • Define a PHP function that could be called as a callback in extension.json or skin.json with an argument to generate a virtual file at runtime. This is similar to how we handle Codex icons.
  • A given ResourceLoader module would supply a list of Codex components as the argument to this function. The resulting file would be an optimized bundle containing code only for the requested components plus all of their dependencies and CSS. The CSS would be built to a separate file that could theoretically be loaded first or separately for CSS-only components.
  • In the future this approach might be able to support SSR-generated features as well, since Vite supports SSR itself.

Event Timeline

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

[mediawiki/core@master] [WIP] Codex code splitting experiments

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

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

[mediawiki/extensions/VueTest@master] [Proof of concept] Demonstrate how to use CodexModule

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

Catrope subscribed.

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

Change 944351 abandoned by Catrope:

[mediawiki/core@master] [Proof of concept] CodexModule: Allow loading individual components

Reason:

Superseded by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/970908

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