Repository navigation
🐛 TinaCMS admin - Load the extra Prism grammars without require so the admin starts again - #2807
Merged
Merged
Conversation
…e admin starts again Since #2781, the Tina admin stops at load with "Dynamic require of "prismjs/components/prism-csharp" is not supported", and it then shows "Failed loading TinaCMS assets". The admin is a browser ES module bundle, and lib/prism-grammars.ts used require calls. - The grammars load as static imports on the prismjs core instance, and the module copies them to the Prism instance of prism-react-renderer. - A form that sets the global Prism from an ES module does not work: the bundler runs the grammar code first, and the admin stops with "Prism is not defined" (tested). - PrismJS.manual is true, so the prismjs core does not highlight the code blocks that React renders. Tested: production admin and a local admin build in headless Chromium. Before, the asset error. After, the admin loads. The grammar tests pass (one new test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
AntPolkanov
reviewed
Nov 12, 2026
Member
Author
|
🎬 Explainer video for this pull request (about 40 seconds, no sound): the problem, the change, and how it helps. 🤖 Generated with Claude Code pr-2807.mp4 |
bradystroud
added a commit
that referenced
this pull request
Nov 13, 2026
…na admin (#2808) A require call in code that the Tina admin bundles stops the admin in the browser (#2807). The CI admin build passes with such a call, and Jest runs CommonJS, so only a person who opens /admin finds it. - style/noCommonJs is an error for the application code. - The rule is off for the root config files (*.js) and scripts/, which are CommonJS Node scripts. - lib/appInsights.server.ts keeps its two require calls, with a biome-ignore comment that gives the reason. Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
✏️ Since #2781, the Tina admin does not start. It shows "Failed loading TinaCMS assets" for every rule, and the browser console shows:
Cause:
lib/prism-grammars.tsloads four Prism grammars withrequire(). The typography components import that file, and the admin bundle contains them through the box and email embeds. The admin is a browser ES module bundle, sorequire()throws there. The public pages are not affected, because Next.js supportsrequire.Fix:
prismjscore instance. The module then copiescsharp,bash,powershellandhttpto the Prism instance ofprism-react-renderer, with the same aliases as before (cs,dotnet,sh,shell).PrismJS.manual = true, so theprismjscore does not highlight the code blocks that React renders.Prismand the grammars load after it, the bundler runs the grammar code first, and the admin stops withPrism is not defined. The comment in the file says this.Tests
Dynamic require of "prismjs/components/prism-csharp" is not supported, and the asset error banner.tinacms build --local) with the first fix form:Prism is not defined.__tests__/lib/prismGrammars.test.ts: 5 of 5 pass, one new test forPrismJS.manual. The tests check that the grammars still give several token types, so code blocks keep their colors.pnpm lintandpnpm testpass.Not tested: the editor with a TinaCloud login, and a full site build.
Screenshot (optional)
✏️ Not applicable.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb