-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
[ChartJs] Replace chart.js/auto
import with Chart.register
calls
#1263
Conversation
src/Chartjs/assets/package.json
Outdated
} | ||
}, | ||
"peerDependencies": { | ||
"@hotwired/stimulus": "^3.0.0", | ||
"chart.js": "^3.4.1 <3.9" | ||
"chart.js": "^3.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For others looking at this, we can absolutely allow v4 right now. But we should do it in a minor release, not a patch release.
Background info: Chart.js changed some things starting in 3.9, which is why we previously restricted that version (they were arguably BC breaks). In chart.js 2.13.0, we changed the JS package shipped to Anyway, here is the breakdown of the fix: A) For Encore users, you will need to upgrade |
DefinitelyTyped/DefinitelyTyped#63641 (comment) Just removed the file... let's see |
I'm checking into this failure. What's being imported in the tests is different than what's imported in Encore... which is why our original tests didn't catch the bug. |
So we could release this fix, and check all this module/ES/node/2015/6/beta/tango/charlie later ? Or is there a risk ? |
This PR was merged into the 2.x branch. Discussion ---------- [Chart.js] Reverting chart.js type: module | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | Fix #1262 | License | MIT This is complex, and relates to some hard/weird/broken changes that chart.js made in 3.9. Facts: * Changing `type: module` and making no other changes breaks `chart.js` v3 (but v4 works fine) * Changing the import from `chart.js/auto'` to `chart.js` - like #1263 fixes things. However, it breaks the tests in 3.9... because chart.js doesn't have an `exports` key in that version, so our tests / node environment continue to load the `main` key instead of the `module` key. So, this will "put thing back" and get chart.js working again. After this, we should: 1) Re-add `type: module` to chart.js 2) Upgrade `chart.js` to v4 By doing that, other than actually migrating any custom chart.js code from 3 -> 4 (https://www.chartjs.org/docs/latest/migration/v4-migration.html), users won't need to make any other changes. The question about 3 -> 4 is if we can do that in a minor UX version of it needs to be a major. Technically, nothing in `symfony/ux-chart.js` changes... except that it will force you to change a JS dep up a major version. It's a gray area. Cheers! Commits ------- 3fca0ca [Chart.js] Reverting chart.js type: module
Fixed in #1264. However, we can make this PR the proper PR for the NEXT version, which would include:
|
I did not realize Chart.js 4.0 was released 12 months ago. That could itself be a good argument to push gently users towards an upgrade :) |
63c757d
to
fd99323
Compare
chart.js/auto
import with Chart.register
calls
I rebased and tried to clean this PR i opened a long time ago, but i always end with test failures somewhere... Could you guys @evertharmeling @simondaigre maybe help me there ? (cc issue #1695 ) |
|
||
Chart.register(...registerables); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chart.register(...registerables); | |
registerables.forEach(registerable => Chart.register(registerable)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came across this one too, however we still need to verfify registerables != undefined
as with this code we would still get the following error on 3.x
:
TypeError: Cannot read properties of undefined (reading 'forEach')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And i still think it should not be "undefined" :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/evertharmeling/ux-1263
This seems to backup that it is our testsuite that's messing with us. I've added a console log on the registerables
(symfony/ux). And when using [email protected]
the registerables
variable is NOT undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so its a « module » thing we need to force on the tests… that narrows the problem !
thanks a lot for taking this time it really helps a lot :)
@smnandre Do you need some help to finish the PR ? |
That'd be really nice, yes :) |
I also checked and :
So there is two solutions:
|
@simondaigre thank you so much for taking this time, really 🙇 Let's say we take the solution 2, is there any way to still check 3.x on the CI with no "false failures" ? |
I have no failures on CI with 2/ (for both 3.x and 4.x). |
0f94046
to
09135eb
Compare
7131c0a
to
addc1f8
Compare
So you'd merge the PR ? (i updated to take the @evertharmeling suggestion) |
I checked on a real project with both chart.js 3.x and 4.x, it's OK for me: no breaks and it fixes my issue. |
Well let's merge it and test one last time on the dev branch before the next release ! :) (@kbond if you can ?) A massive thank to you guys @simondaigre @evertharmeling !! 🙇 |
Thanks all! |
Ongoing attempt to fix ChartJS problems