Page MenuHomePhabricator

Update all Codex packages to use ESM by default
Closed, ResolvedPublic5 Estimated Story Points

Description

In preparation for Vite 5's deprecation of its CommonJS API, we should update the various Codex packages to use ESM by default. This can be done by adding "type": "module to the package.json file for each workspace.

It's still possible for individual files to opt-in to CJS by using .cjs as their file extension. This workaround will probably be necessary for Jest config files, because Jest still considers ESM support to be experimental.

In the slightly-more-distant-future, we may want to migrate our test suites from Jest to Vitest.

Here's an example of what this change entails (in the codex-docs workspace): https://gerrit.wikimedia.org/r/c/design/codex/+/980943/3

Acceptance Criteria

  • Migrate codex-design-tokens to ESM
  • Migrate codex-icons to ESM
  • Migrate @wikimedia/codex to ESM
  • Migrate codex-docs to ESM

Event Timeline

Change 982362 had a related patch set uploaded (by Tyhopp; author: Tyhopp):

[design/codex@main] build: Migrate codex-design-tokens package to ESM

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

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

[design/codex@main] build: Update custom SVGO plugin to conform to public API

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

Change 987496 merged by jenkins-bot:

[design/codex@main] build: Update custom SVGO plugin to conform to public API

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

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

[design/codex@main] build: Migrate codex-icons package to ESM

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

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

[design/codex@main] build: Migrate @wikimedia/codex package to ESM

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

Change 982362 merged by jenkins-bot:

[design/codex@main] build: Migrate codex-design-tokens package to ESM

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

Change 989250 had a related patch set uploaded (by LWatson; author: LWatson):

[mediawiki/core@master] Update Codex from v1.2.0 to v1.2.1

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

Change 989250 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.2.0 to v1.2.1

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

Change 987862 merged by jenkins-bot:

[design/codex@main] build: Migrate @wikimedia/codex package to ESM

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

Change 987839 merged by jenkins-bot:

[design/codex@main] build: Migrate codex-icons package to ESM

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

These changes will be reflected when we make the next Codex release (next week on Tuesday).

When we upgrade the version of Codex that is included with MediaWiki, we'll also need to update foreign-resources.yml to ensure the right files are referenced. Conveniently I'm the one doing the next release so I'll make sure everything is correctly updated.

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

[mediawiki/core@master] Update Codex from v1.2.1 to v1.3.0

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

Change 992533 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.2.1 to v1.3.0

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

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

[design/codex@main] build: Point "main" to the CJS file rather than the ESM file

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

Change 992765 merged by jenkins-bot:

[design/codex@main] build: Point "main" to the CJS file rather than the ESM file

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

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

[mediawiki/core@master] Update Codex from v1.3.0 to v1.3.1

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

Change 992798 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.3.0 to v1.3.1

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