Skip to content
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

Function conflict using bun build together with Chart.JS #14110

Open
sajoku opened this issue Sep 23, 2024 · 3 comments
Open

Function conflict using bun build together with Chart.JS #14110

sajoku opened this issue Sep 23, 2024 · 3 comments
Assignees
Labels
bug Something isn't working bundler Something to do with the bundler

Comments

@sajoku
Copy link

sajoku commented Sep 23, 2024

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

When creating a Chart from Chart.js it will get into a recursive error.
Uncaught RangeError: Maximum call stack size exceeded

index.js:2120 Uncaught RangeError: Maximum call stack size exceeded
    at getComputedStyle (index.js:2120:45)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)
    at getComputedStyle (index.js:2120:71)

It looks like the getComputedStyle is the culprit.
A workaround is using --minify-syntax to "alias" the functions.
I am not sure if this is something Bun should fix or if I should knock on Chart.js' door 🙂

What is the expected behavior?

I would expect no clashes on function names when running Bun build. Or getting warned when there are clashes.

What do you see instead?

Uncaught RangeError: Maximum call stack size exceeded

Additional information

I created a reproducible project over here https://github.com/sajoku/chartjs-bun/tree/main.

@sajoku sajoku added bug Something isn't working needs triage labels Sep 23, 2024
@Jarred-Sumner Jarred-Sumner added the bundler Something to do with the bundler label Sep 26, 2024
@paperdave
Copy link
Member

paperdave commented Sep 26, 2024

this reminds me of an issue that renamed a function incorrectly, causing infinite recursion. could not find it. i suspect that is happening here.

note that my assignment currently means it is my responsibility to fix it, but i am spending most of my time on #14025 (afterwards, i'll do a small pass and get some bundler bugs fixed)

@sajoku
Copy link
Author

sajoku commented Oct 8, 2024

this reminds me of an issue that renamed a function incorrectly, causing infinite recursion. could not find it. i suspect that is happening here.

note that my assignment currently means it is my responsibility to fix it, but i am spending most of my time on #14025 (afterwards, i'll do a small pass and get some bundler bugs fixed)

The workaround is good enough for me at the moment.

That renaming happens from bun's internals I take it? Could I try to pin point that myself to help in with finding the exact problem?

@sirenkovladd
Copy link
Contributor

yes, this is a problem with the function name being the same as the global value

this patch helps to fix that as well

diff --git a/dist/chunks/helpers.segment.js b/dist/chunks/helpers.segment.js
index f38b565a20f3e4c27fb91bde2daec9155754ee43..3543790f84f55bda90f7f0ba0e1037af06a30ea1 100644
--- a/dist/chunks/helpers.segment.js
+++ b/dist/chunks/helpers.segment.js
@@ -2164,3 +2164,3 @@
 }
-const getComputedStyle = (element)=>element.ownerDocument.defaultView.getComputedStyle(element, null);
+const _remove = ()=>{};
 function getStyle(el, property) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler
Projects
None yet
Development

No branches or pull requests

4 participants