Skip to content

fix: singleton modules for consistent runtime instances - #27064

Merged
jhoward1994 merged 2 commits into
developfrom
fix/vite-codemirror-singleton
Jul 21, 2026
Merged

jhoward1994 merged 2 commits into
developfrom
fix/vite-codemirror-singleton

Conversation

@jhoward1994

@jhoward1994 jhoward1994 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

What does it do?

Forces the CodeMirror packages used by the JSON custom field to resolve to a single runtime instance in the admin bundle, for both the Vite and webpack bundlers.

This branch combines and supersedes two PRs that fixed the same bug two different ways, unifying them behind a single PR

Concretely:

  • Adds admin-vite-singleton-modules.ts listing the CodeMirror singletons (@codemirror/state, @codemirror/view, @codemirror/language, @codemirror/lang-json, @codemirror/commands, @codemirror/lint, @uiw/react-codemirror).
  • Generalises resolve-module.ts with getModulePathFrom(host, mod) (cached) so singletons resolve from @strapi/design-system's closure — the package that actually externalizes and consumes CodeMirror — while admin-pinned aliases keep resolving from @strapi/admin.
  • Aliases + dedupes the singletons in Vite (vite/config.ts) and webpack (webpack/config.ts), and pre-bundles them via optimizeDeps.include.
  • Guards the singletons in admin-vite-optimize-exclude.ts so @uiw/react-codemirror (ESM + React peer) is never auto-excluded from pre-bundling.
  • Tolerant resolution: an optional/transitive CodeMirror package that cannot be resolved is skipped instead of crashing the build (buildSingletonAliasEntries), and optimizeDeps.include uses the same resolvable subset (getResolvableSingletonModules) so it stays in lockstep with resolve.alias.
  • Dedupes the @codemirror/state / @codemirror/view version ranges in yarn.lock.

Why is it needed?

After a fresh install, opening any entry with a JSON field could crash with:
(especially in e2e tests)

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

Fixes #27003

Supersedes #27046 and #27007

@jhoward1994 jhoward1994 self-assigned this Jul 20, 2026
@jhoward1994
jhoward1994 marked this pull request as ready for review July 20, 2026 10:33
@dosubot dosubot Bot added pr: fix This PR is fixing a bug source: core:admin Source is core/admin package labels Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Size Change: -99.2 kB (-2.96%)

Total Size: 3.25 MB

📦 View Changed
Filename Size Change
examples/getstarted/build/constants-*********** 716 B +458 B (+177.52%) 🆘
examples/getstarted/build/CreateView-*********** 299 B -81 B (-21.32%) 🎉
examples/getstarted/build/da.json-*********** 125 B -7.36 kB (-98.33%) 🏆
examples/getstarted/build/de.json-*********** 79 B -6.69 kB (-98.83%) 🏆
examples/getstarted/build/EditPage-*********** 4.74 kB +2.63 kB (+125.25%) 🆘
examples/getstarted/build/en.json-*********** 1.74 kB -4.72 kB (-73.11%) 🏆
examples/getstarted/build/es.json-*********** 5 kB -9.87 kB (-66.38%) 🏆
examples/getstarted/build/fr.json-*********** 12.7 kB +7.1 kB (+126.7%) 🆘
examples/getstarted/build/hooks-*********** 92 B +10 B (+12.2%) ⚠️
examples/getstarted/build/it.json-*********** 1.47 kB -1.44 kB (-49.54%) 🏆
examples/getstarted/build/layout-*********** 3.5 kB -5 B (-0.14%)
examples/getstarted/build/Layout-*********** 2.19 kB -6 B (-0.27%)
examples/getstarted/build/nl.json-*********** 5.84 kB -10.3 kB (-63.75%) 🏆
examples/getstarted/build/strapi-*********** 1.78 MB -56.8 kB (-3.09%)
examples/getstarted/build/sv.json-*********** 10.4 kB +6.69 kB (+181.09%) 🆘
examples/getstarted/build/tr.json-*********** 296 B -13.4 kB (-97.84%) 🏆
examples/getstarted/build/useLicenseLimitNotification-*********** 705 B -6 B (-0.84%)
examples/getstarted/build/Widgets-*********** 2.55 kB +732 B (+40.2%) 🚨
examples/getstarted/build/zh.json-*********** 4.69 kB -6.1 kB (-56.54%) 🏆
ℹ️ View Unchanged
Filename Size Change
examples/getstarted/build/_baseEach-*********** 220 B 0 B
examples/getstarted/build/_baseMap-*********** 188 B -1 B (-0.53%)
examples/getstarted/build/AdminSeatInfo-*********** 845 B -1 B (-0.12%)
examples/getstarted/build/AIUsage-*********** 704 B +3 B (+0.43%)
examples/getstarted/build/apiTokens-*********** 616 B -4 B (-0.65%)
examples/getstarted/build/App-*********** 22.8 kB +1 B (0%)
examples/getstarted/build/ApplicationInfoPage-*********** 4.31 kB -3 B (-0.07%)
examples/getstarted/build/ar.json-*********** 15.6 kB 0 B
examples/getstarted/build/AuthenticatedLayout-*********** 57.9 kB 0 B
examples/getstarted/build/AuthResponse-*********** 418 B -2 B (-0.48%)
examples/getstarted/build/ca.json-*********** 9.44 kB 0 B
examples/getstarted/build/CardDragPreview-*********** 589 B -1 B (-0.17%)
examples/getstarted/build/ColorPickerInput-*********** 4.25 kB 0 B
examples/getstarted/build/ComponentConfigurationPage-*********** 1.61 kB -2 B (-0.12%)
examples/getstarted/build/ConfigureTheView-*********** 1.54 kB 0 B
examples/getstarted/build/core.esm-*********** 14.5 kB -1 B (-0.01%)
examples/getstarted/build/CreateActionEE-*********** 513 B -2 B (-0.39%)
examples/getstarted/build/CreatePage-*********** 2 kB +4 B (+0.2%)
examples/getstarted/build/cs-*********** 76 B 0 B
examples/getstarted/build/cs.json-*********** 16.7 kB 0 B
examples/getstarted/build/dummy-preview-*********** 3.32 kB -1 B (-0.03%)
examples/getstarted/build/EditConfigurationPage-*********** 1.09 kB 0 B
examples/getstarted/build/EditView-*********** 2.01 kB +1 B (+0.05%)
examples/getstarted/build/EditViewPage-*********** 4.79 kB -1 B (-0.02%)
examples/getstarted/build/en-*********** 74 B 0 B
examples/getstarted/build/en-GB-*********** 15.1 kB 0 B
examples/getstarted/build/es-*********** 74 B 0 B
examples/getstarted/build/eu.json-*********** 10.4 kB 0 B
examples/getstarted/build/EventsTable-*********** 389 B -1 B (-0.26%)
examples/getstarted/build/fi.json-*********** 15.3 kB 0 B
examples/getstarted/build/FieldTypeIcon-*********** 462 B -1 B (-0.22%)
examples/getstarted/build/Form-*********** 5.48 kB -2 B (-0.04%)
examples/getstarted/build/FormApiTokenContainer-*********** 1.04 kB -1 B (-0.1%)
examples/getstarted/build/getActionTypesDefaultMessages-*********** 498 B -2 B (-0.4%)
examples/getstarted/build/getTrad-*********** 379 B -4 B (-1.04%)
examples/getstarted/build/groupBy-*********** 368 B 0 B
examples/getstarted/build/gu.json-*********** 9.06 kB 0 B
examples/getstarted/build/he.json-*********** 6.11 kB 0 B
examples/getstarted/build/hi.json-*********** 11.1 kB 0 B
examples/getstarted/build/History-*********** 6.95 kB -2 B (-0.03%)
examples/getstarted/build/HomePage-*********** 247 kB +1 B (0%)
examples/getstarted/build/hu.json-*********** 11.2 kB 0 B
examples/getstarted/build/id-*********** 7.64 kB -1 B (-0.01%)
examples/getstarted/build/id.json-*********** 4.51 kB 0 B
examples/getstarted/build/index-*********** 215 kB -3 B (0%)
examples/getstarted/build/index.html 592 B -3 B (-0.5%)
examples/getstarted/build/InstalledPlugins-*********** 778 B +1 B (+0.13%)
examples/getstarted/build/isNil-*********** 122 B -1 B (-0.81%)
examples/getstarted/build/ja.json-*********** 17.2 kB 0 B
examples/getstarted/build/ko.json-*********** 17.1 kB 0 B
examples/getstarted/build/LazyOutlet-*********** 308 B -1 B (-0.32%)
examples/getstarted/build/ListConfigurationPage-*********** 4.38 kB -4 B (-0.09%)
examples/getstarted/build/ListPage-*********** 3.46 kB +2 B (+0.06%)
examples/getstarted/build/ListView-*********** 6.84 kB 0 B
examples/getstarted/build/ListViewPage-*********** 7.61 kB -2 B (-0.03%)
examples/getstarted/build/Login-*********** 462 B -1 B (-0.22%)
examples/getstarted/build/MagicLinkEE-*********** 388 B 0 B
examples/getstarted/build/ml.json-*********** 11.3 kB 0 B
examples/getstarted/build/ModalForm-*********** 243 B 0 B
examples/getstarted/build/ms.json-*********** 3.93 kB 0 B
examples/getstarted/build/no.json-*********** 5.47 kB 0 B
examples/getstarted/build/NoContentTypePage-*********** 454 B -2 B (-0.44%)
examples/getstarted/build/NoPermissionsPage-*********** 231 B -1 B (-0.43%)
examples/getstarted/build/Permissions-*********** 11.7 kB +1 B (+0.01%)
examples/getstarted/build/pl.json-*********** 16.4 kB 0 B
examples/getstarted/build/PrivateRoute-*********** 249 B -1 B (-0.4%)
examples/getstarted/build/ProfilePage-*********** 2.48 kB -2 B (-0.08%)
examples/getstarted/build/pt-BR.json-*********** 10.5 kB 0 B
examples/getstarted/build/pt.json-*********** 4.17 kB 0 B
examples/getstarted/build/purchase-review-workflows-*********** 66.3 kB -1 B (0%)
examples/getstarted/build/PurchaseAuditLogs-*********** 70.5 kB -1 B (0%)
examples/getstarted/build/PurchaseContentHistory-*********** 80.9 kB 0 B
examples/getstarted/build/PurchaseContentReleases-*********** 55.9 kB 0 B
examples/getstarted/build/PurchaseSingleSignOn-*********** 25 kB -2 B (-0.01%)
examples/getstarted/build/RelativeTime-*********** 405 B -4 B (-0.98%)
examples/getstarted/build/ReleasesPage-*********** 4.1 kB -1 B (-0.02%)
examples/getstarted/build/ReleasesSettingsPage-*********** 1.52 kB -3 B (-0.2%)
examples/getstarted/build/router-*********** 389 B -1 B (-0.26%)
examples/getstarted/build/ru-*********** 91 B 0 B
examples/getstarted/build/ru.json-*********** 17.2 kB 0 B
examples/getstarted/build/sa.json-*********** 11.2 kB 0 B
examples/getstarted/build/schemas-*********** 3.14 kB -1 B (-0.03%)
examples/getstarted/build/SearchInput-*********** 646 B -2 B (-0.31%)
examples/getstarted/build/selectors-*********** 111 B 0 B
examples/getstarted/build/SelectRoles-*********** 1.03 kB -1 B (-0.1%)
examples/getstarted/build/SessionsPage-*********** 1.48 kB -3 B (-0.2%)
examples/getstarted/build/Settings-*********** 3.66 kB -1 B (-0.03%)
examples/getstarted/build/SettingsPage-*********** 3.02 kB -1 B (-0.03%)
examples/getstarted/build/SingleSignOnPage-*********** 1.81 kB -1 B (-0.06%)
examples/getstarted/build/sk-*********** 76 B 0 B
examples/getstarted/build/sk.json-*********** 16.9 kB 0 B
examples/getstarted/build/sortable.esm-*********** 2.86 kB 0 B
examples/getstarted/build/sortBy-*********** 694 B -2 B (-0.29%)
examples/getstarted/build/SSOProviders-*********** 757 B -1 B (-0.13%)
examples/getstarted/build/strapi-************ 844 B 0 B
examples/getstarted/build/Table-*********** 1.44 kB -4 B (-0.28%)
examples/getstarted/build/tail-*********** 242 B -2 B (-0.82%)
examples/getstarted/build/th.json-*********** 6.16 kB 0 B
examples/getstarted/build/TokenBox-*********** 122 kB 0 B
examples/getstarted/build/tr-*********** 83 B 0 B
examples/getstarted/build/transferTokens-*********** 501 B -3 B (-0.6%)
examples/getstarted/build/uk-*********** 91 B 0 B
examples/getstarted/build/uk.json-*********** 15.5 kB 0 B
examples/getstarted/build/useAdminRoles-*********** 244 B -2 B (-0.81%)
examples/getstarted/build/UseCasePage-*********** 1.39 kB 0 B
examples/getstarted/build/useDragLayer-*********** 179 B -2 B (-1.1%)
examples/getstarted/build/users-*********** 352 B 0 B
examples/getstarted/build/useWebhooks-*********** 643 B -3 B (-0.46%)
examples/getstarted/build/validation-*********** 533 B -2 B (-0.37%)
examples/getstarted/build/vi.json-*********** 13.7 kB 0 B
examples/getstarted/build/WidgetHelpers-*********** 463 B -1 B (-0.22%)
examples/getstarted/build/widgetVisibility-*********** 260 B -3 B (-1.14%)
examples/getstarted/build/zh-Hans.json-*********** 15.4 kB 0 B

compressed-size-action

@trunk-io

trunk-io Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@innerdvations innerdvations added the publish-experimental Trigger the Experimental publish on npm (publish-prerelease.yml) label Jul 20, 2026
@innerdvations innerdvations added this to the 5.50.3 milestone Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Experimental build

Version 0.0.0-experimental.08c99a975cc5e5610592b41d9c853d43df960653
Dist tag experimental
Commit 08c99a9
npx create-strapi-app@0.0.0-experimental.08c99a975cc5e5610592b41d9c853d43df960653 my-project --non-interactive --skip-cloud --no-run

To upgrade an existing app, install all @strapi/* packages at the same version.

@innerdvations innerdvations left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested npm, yarn, and pnpm with the experimental, LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix This PR is fixing a bug publish-experimental Trigger the Experimental publish on npm (publish-prerelease.yml) source: core:admin Source is core/admin package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin panel broken by CodeMirror release.

2 participants