Skip to content

Commit e68c42f

Browse files
authored
Merge pull request #1304 from mathjax/update/node-main
Improve loading of @mathjax/src by import and require
2 parents 20acddf + 21a253a commit e68c42f

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

components/mjs/node-main/node-main.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ if (!global.MathJax) global.MathJax = {};
22

33
global.MathJax.__dirname = __dirname;
44

5-
module.exports = require('./node-main.js');
5+
module.exports = require('./node-main.js').MathJax;

components/mjs/node-main/node-main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import '../core/core.js';
2727
import '../adaptors/liteDOM/liteDOM.js';
2828
import {source} from '../source.js';
2929

30-
const path = eval('require("path")'); // get path from node, not webpack
31-
const dir = global.MathJax.config.__dirname; // set up by node-main.mjs or node-main.cjs
30+
const MathJax = global.MathJax;
31+
32+
const path = eval('require("path")'); // get path from node, not webpack
33+
const dir = MathJax.config.__dirname; // set up by node-main.mjs or node-main.cjs
3234

3335
/*
3436
* Set up the initial configuration
@@ -78,7 +80,7 @@ MathJax._.mathjax.mathjax.asyncLoad = function (name) {
7880
* The init() function returns a promise that is resolved when MathJax is loaded and ready, and that
7981
* is passed the MathJax global variable when it is called.
8082
*/
81-
const init = (config = {}) => {
83+
const init = MathJax.init = (config = {}) => {
8284
combineConfig(MathJax.config, config);
8385
return Loader.load(...CONFIG.load)
8486
.then(() => CONFIG.ready())
@@ -88,6 +90,6 @@ const init = (config = {}) => {
8890
}
8991

9092
/*
91-
* Export the init() function
93+
* Export MathJax (with its init() function)
9294
*/
93-
export {init};
95+
export {MathJax};
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
import './node-main-setup.mjs';
2-
export * from './node-main.js';
2+
import {MathJax} from './node-main.js';
3+
export default MathJax;
4+
export const init = MathJax.init;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = (pkg) => {
22
pkg.output.library = {
3-
name: 'init',
3+
name: 'MathJax',
44
type: 'commonjs',
5-
export: 'init'
5+
export: ['MathJax'],
66
}
77
return pkg;
8-
}
8+
}

0 commit comments

Comments
 (0)