fred-wang / TeXZilla

LALR Javascript LaTeX-to-MathML converter compatible with Unicode
http://fred-wang.github.io/TeXZilla/
130 stars 21 forks source link

Can't resolve 'webserver' #66

Open johanneswilm opened 5 years ago

johanneswilm commented 5 years ago

Hey, when packing our site with webpack which depends on texzilla, we run into #53 . If we then add "system" as a dependency, we get this warning message instead:

Module not found: Error: Can't resolve 'webserver' in './node_modules/texzilla'
 @ ./node_modules/texzilla/TeXZilla.js
...

It seems like both this issue and #53 still need to be fixed. In #53 it sounds like you are not planning to fix it here - so maybe somewhere else?

fred-wang commented 5 years ago

I was not able to reproduce the error last time I tried. I think someone who can should probably investigate the cause and try and propose a patch for this.

johanneswilm commented 5 years ago

I can see a require("webserver") that is in a try block [1], which is likely why this is a warning and not an error. And at least two references to system [2][3].

[1] https://github.com/fred-wang/TeXZilla/blob/master/commonJS.js#L181

[2] https://github.com/fred-wang/TeXZilla/blob/master/commonJS.js#L233

[3] https://github.com/fred-wang/TeXZilla/blob/master/commonJS.js#L249

fred-wang commented 5 years ago

So should https://github.com/fred-wang/TeXZilla/blob/master/package.json contains something more? I'm not very familiar with NPM

johanneswilm commented 5 years ago

Looking at this list of suggestions [1], I found that if I replace all occurrences of require("system") with window.require("system") and require("webserver") with window.require("webserver") solves the issue for the packager. @fred-wang Will that also work when using it in the kinds of environments where these packages are available by default?

[1] https://stackoverflow.com/questions/34828722/how-can-i-make-webpack-skip-a-require

johanneswilm commented 5 years ago

It seems like the fundamental issue here is that you use the same file as an import for other websites and the same file to run as a command line program. So it's choking on the bits that are only meant for commandline usage. Is that a fair assessment, @fred-wang ?

fred-wang commented 5 years ago

that's possible. I would need to check in details :-)

johanneswilm commented 5 years ago

excellent. I hope to see a solution to this.