Skip to content

Add note about Vite .mts ESM syntax support#3080

Open
pwizla wants to merge 3 commits intomainfrom
repo/vite-mts-esm-support
Open

Add note about Vite .mts ESM syntax support#3080
pwizla wants to merge 3 commits intomainfrom
repo/vite-mts-esm-support

Conversation

@pwizla
Copy link
Copy Markdown
Collaborator

@pwizla pwizla commented Apr 21, 2026

This PR updates documentation based on strapi/strapi#25238.

Adds a new TabItem example showing .mts ESM syntax for Vite configuration, along with a note explaining that ESM syntax is now supported and recommended.

Generated automatically by the docs self-healing workflow (micro-edit, Haiku).
Review before merging.

Add TabItem for .mts files and include note about ESM syntax support
in Vite configuration.
@pwizla pwizla added the auto-doc-healing Automatically generated documentation PR label Apr 21, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
documentation Ready Ready Preview, Comment Apr 22, 2026 10:08am

Request Review

@strapi-cla
Copy link
Copy Markdown

strapi-cla commented Apr 21, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ pwizla
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added internal PRs created by the Strapi core team pr: updated content PRs updating existing documentation content source: CMS labels Apr 21, 2026
@pwizla pwizla self-assigned this Apr 21, 2026
@pwizla
Copy link
Copy Markdown
Collaborator Author

pwizla commented Apr 22, 2026

After reviewing the source PR (strapi/strapi#25238) and checking the Vite documentation and Strapi codebase, here are some concerns about the third "TypeScript (ESM)" tab:

The code is identical across the TypeScript and TypeScript (ESM) tabs. The only difference is the filename (vite.config.tsvite.config.mts). Both use the same import/export ESM syntax. A dedicated tab for identical code with just a different extension adds UI noise without adding clarity.

The claim "CJS is being phased out by Vite" is misleading. The official Vite config docs (vite.dev/config) still recommend vite.config.js and vite.config.ts as primary options. CJS is not formally deprecated for config files.

Potential loader issue in Strapi. The USER_CONFIGS array was updated to include vite.config.mts, but the loadFile function in packages/core/strapi/src/node/core/files.ts registers esbuild with extensions ['.js', '.mjs', '.ts'].mts is not explicitly included. This may cause issues in practice.

Proposed changes:

  • Remove the third tab
  • Replace with a short tip/note mentioning .mts support for users who need explicit ESM module resolution in their package.json
  • Remove the :::info admonition about CJS being phased out (unsupported claim)

The TypeScript (ESM) tab had identical code to the TypeScript tab.
A short tip is sufficient to mention .mts support for users who need
explicit ESM module resolution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pwizla pwizla marked this pull request as ready for review April 22, 2026 10:04
@pwizla pwizla added this to the 6.22.0 milestone Apr 22, 2026
@pwizla
Copy link
Copy Markdown
Collaborator Author

pwizla commented Apr 22, 2026

Correction to my earlier comment: Vite 6 does deprecate the CJS Node API (see Vite 6 troubleshooting), so the direction is real. However, Strapi currently ships with Vite 5.4.21, where CJS is not deprecated.

The .mts support is worth documenting as a forward-looking option, but calling it "the recommended approach" is premature while Strapi runs on Vite 5. I've updated the tip in the code to reflect this nuance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pwizla
Copy link
Copy Markdown
Collaborator Author

pwizla commented Apr 22, 2026

Now fully approved ✅

@pwizla pwizla added the flag: merge pending release Pending Strapi Release label Apr 22, 2026
@pwizla pwizla changed the title [Docs self-healing] Document Vite .mts ESM syntax support Add note about Vite .mts ESM syntax support Apr 22, 2026
@pwizla pwizla added pr: chore and removed flag: merge pending release Pending Strapi Release pr: updated content PRs updating existing documentation content labels Apr 22, 2026
@pwizla pwizla modified the milestones: 6.22.0, 6.23.0 Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-doc-healing Automatically generated documentation PR internal PRs created by the Strapi core team pr: chore source: CMS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants