Skip to content

chore(admin): singleton module handling for vite aliases - #27046

Closed
jhoward1994 wants to merge 1 commit into
developfrom
fix/vite-singleton
Closed

jhoward1994 wants to merge 1 commit into
developfrom
fix/vite-singleton

Conversation

@jhoward1994

@jhoward1994 jhoward1994 commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What does it do?

Forces CodeMirror-related packages to resolve as a single runtime instance in the admin Vite graph.

  • Adds ADMIN_VITE_SINGLETON_MODULES (@codemirror/*, @uiw/react-codemirror) separate from admin-pinned alias modules

Why is it needed?

CodeMirror extensions use instanceof checks. When the admin bundler loads more than one physical @codemirror/state (common in monorepo / yarn / yalc graphs where design-system and hoisted @codemirror/lang-json resolve different copies), JSONInput fails with:

Unrecognized extension value in extension set ([object Object]).
This sometimes happens because multiple instances of @codemirror/state are loaded, breaking e2e test

How to test it?

From repo root, run the unit tests covering the change:
yarn nx test @strapi/strapi --testPathPattern='admin-vite-aliases|resolve-development-config'

Merge into e.g #26713 and see that the e2e tests pass

@jhoward1994
jhoward1994 marked this pull request as ready for review July 16, 2026 15:55
@jhoward1994 jhoward1994 self-assigned this Jul 16, 2026
@dosubot dosubot Bot added pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:strapi Source is core/strapi package labels Jul 16, 2026
@innerdvations

innerdvations commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review

Verdict: request changes — one production-code issue before merge.

Blocker: hard getModulePathFrom('@strapi/design-system', …) for packages DS does not declare

buildAdminViteResolveAliases maps every ADMIN_VITE_SINGLETON_MODULES entry through getModulePathFrom('@strapi/design-system', mod) with no fallback.

DS 2.2.3 only declares @codemirror/state, @codemirror/view, @codemirror/lang-json, and @uiw/react-codemirror. The list also includes @codemirror/language, @codemirror/commands, and @codemirror/lint.

On pnpm-strict / nested graphs, those three are typically only reachable under @uiw/react-codemirror's own node_modules, not via Node resolution from the DS package root. resolve-from then throws and admin Vite config never builds.

Suggested fix (small)

Any of these is enough:

  1. Soft-resolve (same idea as fix(strapi): dedupe CodeMirror packages to prevent JSON field crash #27007): try/catch per package; skip or fall back to getModulePath(mod) / cwd if DS resolve fails.
  2. Only DS-resolve what DS declares (state, view, lang-json, @uiw/react-codemirror); resolve the rest from admin/cwd with fallback.
  3. Narrow the list to the packages that actually need the DS copy for instanceof (mainly state / view / uiw).

The singleton approach (alias + dedupe + optimizeDeps.include) is fine — this is just making the resolve path resilient.

Non-blocking

AI-assisted comment.

@trunk-io

trunk-io Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@jhoward1994

Copy link
Copy Markdown
Contributor Author

Closed for #27064

@jhoward1994
jhoward1994 deleted the fix/vite-singleton branch July 21, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:strapi Source is core/strapi package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants