Rollup not happy with __dirname
edemaine opened this issue · comments
I see from #420 that some Rollup compatibility is maybe desired. I was just trying to port my Web Worker application of MathJax from Webpack to Rollup. I noticed that Loader uses __dirname
which is supported by Webpack but apparently not Rollup:
MathJax-src/ts/components/loader.ts
Lines 202 to 203 in 2dd53ce
In my case, I'm preloading all modules I want, so I don't really want to activate the Loader at all, except to initialize the preLoad
list. Is there some way to bypass this? Maybe I should use direct mode?
I'm also not sure rollup is the best approach; it sadly doesn't seem to end up with smaller bundles. So probably not a high priority thing.
It looks like you have already converted to direct mode, so that should resolve the problem for you. You don't need the MathJax configuration object any longer, as that is only used by the startup
and loader
modules, which you aren't using. So the code
can be removed.
Alternatively, you could probably have used the original approach, by replacing
with
require("mathjax-full/js/components/global.js");
by
require("mathjax-full/js/components/startup.js");
and deleting
though I haven't tested it to make sure. In any case, it could have been worked out, but if you are not planning to use any of the loader functionality, there is not much reason to use the components approach. The direct calls are the better approach, here, I would say.
Many thanks, in particular for spotting that stray code! I confirmed that the direct port indeed works fine on Rollup. So, problem solved!