-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
custom_relational_functions example not working #3332
Comments
(Btw, just a workaround in case someone does encounter this, you can directly call the factory metohd with an empty context to overwrite the functions on the instance, but I am not sure what side effects that might have.) |
Hm yeah that is confusing, sorry. Let me try to explain what's going on. The npm library contains a static function Now, the browser bundle is not the same as the npm library: it exports a mathjs instance. So, the not the static function So in short: it's not possible to do with the browser bundle right now. It would be good to think through if we can address this issue. I did a quick test: if we change the contents of import * as math from './index.js'
export default math And then create the browser bundle, your jsfiddle example works as expected. The browser bundle grows from 183 KB to 202 KB when zipped: it is larger because it now exports all named factories. |
I "forked" a version with the suggested fix that did the trick for me, so thank you very much for that 👍 . |
That's good news, glad to here this workaround works. I still have to think through how to solve this issue. At least we should rename |
Here is a JSFiddle with MathJS 14 using a direct copy of the custom_relation_functions code:
https://jsfiddle.net/uonxj72q/
The output shows that the custom relation functions do not seem to be used. (E.g. when I put a debugger into them).
Oddly enough this seems to be related somehow to how the browser bundler is working, because the same code is working for me when using Vite to bundle it from node_modules.
Been trying to figure out what's going on for a couple of hours now, and frankly hitting a wall 😟.
The text was updated successfully, but these errors were encountered: