Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing problem on document creation #406

Closed
zorkow opened this issue Dec 15, 2019 · 5 comments
Closed

Timing problem on document creation #406

zorkow opened this issue Dec 15, 2019 · 5 comments
Milestone

Comments

@zorkow
Copy link
Member

zorkow commented Dec 15, 2019

There is a node issue on initialisation where CONFIG.require is not set. Consider the following minimal example (working directory '/tmp').

const mj = require('mathjax');
let promise = mj.init({loader: {load: ['/tmp/node_modules/mathjax/es5/input/tex']}});

That works fine when executed in node, but not when executed with node as in node test.js.

@zorkow
Copy link
Member Author

zorkow commented Dec 15, 2019

When giving loader the require method explicitly, it works as expected. E.g.,

const mj = require('mathjax');
let promise = mj.init({
  loader: {require: require,
           load: ['/tmp/node_modules/mathjax/es5/input/tex']}});
promise.then(m => console.log(m.tex2mml('x^2')));

works fine. Not sure if this is intended.
I am also not quite sure why require is not bound to the global object when node is executed in shell mode, which could be the reason for the observed problem.

dpvc added a commit that referenced this issue Dec 17, 2019
…ctly regardless of webpacking or location of the node script. Resolves issue #406
@dpvc
Copy link
Member

dpvc commented Dec 17, 2019

The require field was not being set properly, nor is the default mathjax path for loading components. The webpacking was affecting the results (and it seems I didn't adequately check that). These two changes should resolve the issue. The original global.require() was an attempt to avoid error messages where webpack would complain about not being able to resolve the files being required, but failed to get the right value in the web packed file. The method used in the PR listed above seems to work.

@dpvc
Copy link
Member

dpvc commented Dec 17, 2019

PS, it also fixes the problem with the mathjax root path, so that

const mj = require('mathjax');
let promise = mj.init({loader: {load: ['input/tex']}});

should work (no need for full path to the component).

@dpvc dpvc added the bug label Dec 17, 2019
@dpvc dpvc added this to the 3.0.1 milestone Dec 31, 2019
dpvc added a commit that referenced this issue Jan 3, 2020
Fix node-main.js to get require() and correct mathjax path.  #406
@dpvc dpvc added fixed and removed fixed labels Feb 5, 2020
@dpvc
Copy link
Member

dpvc commented Feb 11, 2020

OK, this is not yet fully fixed. It works for the mathjax npm package, but not for mathjax-full, or from the MathJax-src repository (it should work for both the es5 directory and the components/src/node-main copies).

@dpvc
Copy link
Member

dpvc commented Feb 11, 2020

I've made a PR to address the problem.

@dpvc dpvc added fixed and removed fixed labels Mar 5, 2020
@dpvc dpvc modified the milestones: 3.0.1, 3.0.2 Mar 5, 2020
dpvc added a commit that referenced this issue Mar 30, 2020
Set loader's mathjax path to work in more situations.  #406
@dpvc dpvc added the fixed label Mar 30, 2020
@dpvc dpvc closed this as completed Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants