Copy __locales__ for all components, and improve default json loading.#1476
Merged
Conversation
zorkow
approved these changes
May 17, 2026
Member
zorkow
left a comment
There was a problem hiding this comment.
Lgtm. I've already added copy blocks to the config.json files yesterday (not yet pushed), so I might get some conflicts...
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.
This PR adds
copyblocks to the component configuration files for the TeX packages that have__locales__files.In addition, it fixes the component name for the main TeX
__locales__file :[tex]translates to[mathjax]/input/tex/extensions, which is where the webpacked versions go. The correct component name is 'input/tex'. In order to get this to work, thecomponents/mjs/core/core.jsfile is modified to always usePackage.resolvePath(), not just when the package name starts with[. We also add amathjax.jsonspecification incore.jsso that it works in node applications (that use the components framework) without their having to override theMathJax.loader.jsonconfiguration value. We include it here so that the webpack comment is present, as this.jsfile doesn't get transpiled, which would remove comments. (Alternatively, it could be ints/mathjax.ts, with a separatetsconfigfile like the one used for the web worker, but I think this is easier.) The componentstsconfigfile is modified to not remove that comment when compiling the CJS versions.The main
input/texconfig file copies both theinput/tex/__locales__directory and theinput/tex/base/__locales__directory, since the base package doesn't have a separate component to do the copying (though I suppose we could make a component directory for it with just a config file for copying the locales, if you thin that is cleaner).The
components/mjs/startup/init.jsfile is modified to load the core component, so that it will share the sameLocaleobject as the core component. Without this, people use use<script src="https://cdn.jsdelivr.net/npm/mathjax@4/startup.js>and theloader.loadarray to load individual components would end up having a separateLocaleobject where the strings get registered, and when startup doesLocale.setLocale(), it would be with its own copy, and there would be no registered packages.The
Bbox.test.tsdoesn't need to specifyasync, as thesetupTex()command already returns a promise.Finally, there are new
mjs/json.tsandcjs/json.tsfiles to implement themathjax.jsonmethod that supports both browser and node use. Node users are supposed to load one of theasyncLoadimplementations, but in case they don't this will allow the locales to be loaded anyway. Without that, the locale loading would break existing node applications that don't currently import one of theasyncLoadfiles. Because the CJS typescript settings don't currently allowimport()to include{with: {type: 'json'}}, we use a separate mjs and cjs implementation, where the cjs version usesrequire()rather thanimport(), since that handles JSON files automatically.