Production errors with Svelte
I'm attempting to use this library with Svelte(Kit). In development, I immediately run into a pair of solvable issues:
global is not defined-- Either setglobal = windowin a<svelte:head>tag, or setdefine: { global: "window" }in the Vite config fileModule "events" has been externalized for ...-- Separately install the "events" package.
Everything then works in development mode (although it would be nice if these were fixed at the function-plot level).
In production mode, I'm running into an unavoidable Attempting to define property on object that is not extensible. error. Digging into the Svelte output, the specific line it's complaining about is:
var out2 = Object.assign(relational, arithmetic, algebra, trigonometric);
since relational is defined (not sure in which dependency...) as:
const relational = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
...
}, Symbol.toStringTag, { value: "Module" }));
So the issue is the Object.freeze call on something that's later a target in Object.assign. (If I remove the Object.freeze call on relational in the built output, everything works fine.) Where is this coming from, and is there a way that this issue can be addressed?
Thanks for the report, the library that's doing:
var out2 = Object.assign(relational, arithmetic, algebra, trigonometric);
is https://github.com/mauriciopoppe/interval-arithmetic/blob/fce59e39f08a18bedbd7ff1d8a2ae2bf39ad9039/src/index.ts#L20-L22, I think I did it because of a limitation of Typescript with the number of args sent to Object.assign, I think I'll add ts-ignore and check that the docs are still generated correctly
Could you just spread the objects instead?
const out = { ..._Interval, ...constants, ...round, ... };
Thanks for the suggestion, I'll try that and see if the doc generator works with that
I've fixed the issue downstream in https://github.com/mauriciopoppe/interval-arithmetic/releases/tag/v1.0.7 and published [email protected], please try with that prerelease version and let me know how it goes
If this is still an issue feel free to reopen this bug, https://github.com/mauriciopoppe/function-plot/releases/tag/v1.23.0 is already released