Page MenuHomePhabricator

Add non-minified files to Codex package used in MediaWiki lib
Closed, ResolvedPublic1 Estimated Story Points

Description

Background

MediaWiki, following Debian package requirements, requires to feature non-minified files for every library. This should also apply to Codex.

@matmarex brought this up:

I've just noticed (while checking out the changes in Codex v0.20.0) that the Codex build in MediaWiki only includes the minified files, but not the unminified ones. A non-minified build should probably be included as well, for reasons documented here: https://www.mediawiki.org/wiki/ResourceLoader/Foreign_resources#Minified_files

You may use minified distribution files provided by the library, but in that case, the corresponding non-minified files must also be downloaded and committed, and they should be used when ResourceLoader debug mode is active. This is because of the requirements for Debian packages, and to improve the developer experience given the lack of support for source maps of external libraries. (related tasks: T217351, T257878, T346075)

(I only added that documentation a few weeks ago, but I think the unwritten recommendation has existed for years)

Would it be feasible to add a non-minified build to Codex, and use it in MediaWiki?

Acceptance Criteria

Update the Codex build configuration to produce the following bundles:

  • Minified UMD build (suitable for script-tag inclusion / CDN usage)
  • Unminified ESM build (we assume users of this will have their own build tools available)
  • Unminified CJS build (RL will take care of minification in MW usage)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Adding in a non-minified build is pretty easy to do (just set minify: false in the appropriate Vite configuration). But we should be thoughtful about how we organize the files in dist/ so that people don't end up using the wrong things in the wrong places.

Should the un-minified, CommonJS bundle of the library serve as the default entry point to the library in package.json, for example?

Should we minify the UMD bundle we provide (since that's intended for use w/o a build step, via CDN or whatever) and leave both the CommonJS (for use in MW) and ESM (for use in more modern environments) bundles un-minified?

egardner set the point value for this task to 1.Oct 2 2023, 7:12 PM

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

[design/codex@main] build: Don't minify the ESM library build

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

Change 967545 merged by jenkins-bot:

[design/codex@main] build: Don't minify the ESM library build

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

Change 968345 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[mediawiki/core@master] Update Codex from v1.0.0-rc.1 to v1.0.0

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

Test wiki created on Patch demo by ATomasevich (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/b8a4f83606/w

Change 968345 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.0.0-rc.1 to v1.0.0

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

Change 968370 had a related patch set uploaded (by Jforrester; author: Anne Tomasevich):

[mediawiki/core@REL1_41] Update Codex from v1.0.0-rc.1 to v1.0.0

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

Change 968370 merged by jenkins-bot:

[mediawiki/core@REL1_41] Update Codex from v1.0.0-rc.1 to v1.0.0

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

Test wiki on Patch demo by ATomasevich (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/b8a4f83606/w/