-
Notifications
You must be signed in to change notification settings - Fork 210
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
For whatever reason eval being executed in production mode #818
Comments
MathJax uses the webpack DefinePlugin to replace MathJax-src/components/webpack.common.js Lines 49 to 58 in 9f588aa
(so web components will have the value) and tries to look it up at run time otherwise (for node applications). So if you are using some other package manage, you will need to do something similar. It looks like maybe the browserify-replace package might be able to do the job for you. Sorry that this update has had this negative impact for you. |
Thanks! |
Just to chip in here, we have also run into this issue. Unfortunately, for us, we are using I understand the need for If we go down this route, we're going to have to have separate instructions for Rollup, Webpack, Browserify, and so on.... simply for reading the version number. Suggestion to simply target Node.js environments by default, and fallback to a hardcoded string (can be generated at check-in/hooks if required?): const PACKAGE_VERSION = "3.2.1";
export const VERSION = (
typeof window === 'undefined' ?
//
// This will not be included in the webpack version, so only runs in node
//
(function () {
//
// Look up the version from the package.json file
//
/* tslint:disable-next-line:no-eval */
const load = eval('require');
/* tslint:disable-next-line:no-eval */
const dirname = eval('__dirname');
const path = load('path');
return load(path.resolve(dirname, '..', '..', 'package.json')).version;
})() :
PACKAGE_VERSION
); |
I haven't had time to dive deep into this but I agree with @ryangr-texthelp |
@ShaMan123 :) |
Nice. I do it as well in a project. |
Hello, Could this issue be reopened please? I fully agree with @ryangr-texthelp's message: the current approach to get a simple I believe the issue is with projects building mathjax from source. For some reason I couldn't make the DefinePlugin approach work (I'm using webpack). As Ryan said, this won't work down the line for many users. Or even in 2 years when webpack gets replaced ;p It would be great if this issue could be adressed in the next patch. :) Best, |
[Sorry about the slow response, here. I've been away for a week, and am trying to catch up now.] Although we were trying to make things easier, we clearly made things harder for some use-cases like yours, and need to re-evaluate the situation. I've made a feature request in the MathJax issue tracker, and will address it in the next release. There may well be another point release soon to address this plus another issue that has affected the lazy-typesetting extension. |
Thanks for addressing this @dpvc :)) |
I've made a pull request that should resolve this issue. It creates the version.ts file using the package.json version number during the travis-ci publish script, so the version will just be a constant, as requested. |
Great, thanks @dpvc ! |
MathJax waiting on bug fix: mathjax/MathJax-src#818
Make version.ts use a constant and create the file during the build process. (#818)
Just have updated to the latest release |
@solomax, thanks for the confirmation. Glad it works better for you. |
Yes, can confirm here too 👍 Cheers! |
@NicolasCARPi, great thanks! |
TL;DR;
for whatever reason this https://github.com/mathjax/MathJax-src/blob/master/ts/components/version.ts#L37 code being executed at my app :(
Long version:
We are using MathJax to draw beautiful formulas at Apache OpenMeetings: https://github.com/apache/openmeetings/blob/master/openmeetings-web/src/main/front/wb/package.json#L22
And
browserify
as build toolWe are using some sort node-like configuration https://github.com/apache/openmeetings/blob/master/openmeetings-web/src/main/front/wb/src/wb-tool-stat-math.js#L4
Everything was working as expected (and still working in DEV mode)
BUT for whatever reason in PRODUCTION
eval
is being called to determine the MathJax version :(I've hacked this by adding
window.PACKAGE_VERSION = '3.2.1';
to my source codeBut this a bit dirty :(
Maybe it would be possible to introduce some eval-free mode?
Or maybe I'm doing something wrong?
Or maybe it would be possible to store version in some pre/post build step? :)))
Thanks in advance for the help :)
The text was updated successfully, but these errors were encountered: