Ah.... got it I think. Does this look close to MathJax3's AllPackages?
I manually installed the mhchem package bits and switched to mathjax/src:
"@mathjax/mathjax-mhchem-font-extension": "^4.0.0",
"@mathjax/mathjax-newcm-font": "^4.0.0",
"@mathjax/src": "^4.0.0",
"mhchemparser": "^4.2.1",
then switched mathJaxConverters.js to use:
const CoreV3ish = [
// mirrors MathJax v3's AllPackages (practical subset)
'ams', 'boldsymbol', 'bbox', 'braket', 'cancel',
'color', 'colorv2', 'enclose', 'html', 'mathtools', 'newcommand',
'noundefined', 'noerrors', 'setoptions', 'tagformat',
'textmacros', 'unicode', 'upgreek'
];
// Add the extras you want:
const WantedPackages = [...new Set([...CoreV3ish, 'mhchem', 'physics'])];
// Init: you can either load them all, or just load what you need.
// Loading all is fine in a server where you want feature parity.
global.MathJax ={
loader: {
paths: { mathjax: '@mathjax/src/bundle' },
require: require,
load: [
'input/tex', 'input/mml', 'input/asciimath',
'output/svg', 'adaptors/liteDOM',
// Load the TeX extensions as components (prefixed form):
...WantedPackages.map(p => `[tex]/${p}`)
]
},
startup: { typeset: false },
tex: {
// enable the packages in the TeX input jax
packages: { '[+]': WantedPackages },
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
},
svg: {
fontCache: 'none',
font: 'mathjax-newcm'
}
};
// Load the startup component and wait for it
require('@mathjax/src/bundle/startup.js');
const mathJaxReady = MathJax.startup.promise.then(() => {
console.log('✓ MathJax initialized successfully');
}).catch((err) => {
console.error('✗ MathJax initialization error:', err.message);
throw err;
});