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

Node 20 -> 22 #5097

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Node 20 -> 22 #5097

merged 3 commits into from
Jan 12, 2025

Conversation

birkskyum
Copy link
Member

@birkskyum birkskyum commented Nov 22, 2024

22 has been the lts for 7 months now, so i think we're plenty safe to use it.

https://endoflife.date/nodejs

Requires canvas v3 and jsdom v26

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@HarelM
Copy link
Collaborator

HarelM commented Nov 22, 2024

I like it that there's a need to change only in one place! Having said that, CI need more tender love and care...

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.84%. Comparing base (dd054e3) to head (f5c6873).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5097   +/-   ##
=======================================
  Coverage   91.83%   91.84%           
=======================================
  Files         282      282           
  Lines       38908    38908           
  Branches     6820     6829    +9     
=======================================
+ Hits        35733    35735    +2     
+ Misses       3047     3046    -1     
+ Partials      128      127    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@birkskyum
Copy link
Member Author

birkskyum commented Nov 25, 2024

@HarelM , CI is a lot better now.

Basically, 2 things.

  1. The "canvas" package was causing trouble with installation. I see this a lot. They are solving it with their v3, of which I here use a pre-release, which doesn't require manual rebuilds of the package on isntallation. It's being used only for the Offscreen Canvas tests below:

describe('util readImageDataUsingOffscreenCanvas', () => {
test('reads pixels from image', async () => {
(window as any).OffscreenCanvas = Canvas;
const image = new Canvas(2, 2);
const context = image.getContext('2d');

test('normal operation does not mangle canvas', () => {
const OffscreenCanvas = (window as any).OffscreenCanvas = vi.fn((width:number, height: number) => {
return new Canvas(width, height);
});
expect(offscreenCanvasSupported()).toBeTruthy();
OffscreenCanvas.mockClear();
expect(isOffscreenCanvasDistorted()).toBeFalsy();
expect(OffscreenCanvas).toHaveBeenCalledTimes(1);
});

  1. npm began complaining a lot here, leaving me only two options; add the --legacy-peer-deps flags, or move to a more modern package manager like pnpm that wouldn't have a problem in the first place.

@birkskyum birkskyum requested a review from HarelM November 25, 2024 12:42
@HarelM
Copy link
Collaborator

HarelM commented Nov 25, 2024

Can we replace the canvas package with a vitest package somehow? I don't like using non-official packages...

Also, what's the error you get that needs legacy peer deps flag?

@birkskyum
Copy link
Member Author

birkskyum commented Nov 25, 2024

The error is that JSDOM has a peer dependency on "canvas": 2.x, and this upgrades to canvas 3.x. Canvas 3.x is breaking in the sense that it dropped support for Node 16, but JSDOM will still work perfectly fine with it.

.nvmrc Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Nov 25, 2024

Is there a JSDom version that "is compatible" with canvas 3? Maybe a pre-release of JSDom?
Otherwise I would consider waiting for official releases of these packages...

.npmrc Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Dec 12, 2024

@birkskyum what's the status for this PR? Can we push it to finalization?

@birkskyum
Copy link
Member Author

birkskyum commented Dec 12, 2024

Status is that the JSDOM team prefer to move forward only when a stable v3 of node-canvas is out.

The 3.0.0-rc2 came out in june, so it appeared to progress quite slowly, but interestingly the rc3 came out only 5 days ago.

And there are indications it could move forward any day now.

(maintainer) I've got some time carved out this weekend to try to get 3.0 released, though.

@HarelM
Copy link
Collaborator

HarelM commented Dec 24, 2024

Looks like canvas 3.0 was released.
The PR is failing (due to jsdom dependency I guess), but maybe there a way forward now with this PR:

@birkskyum
Copy link
Member Author

The Peer deps are being updated in Jsdom

@birkskyum
Copy link
Member Author

Jsdom 26 is out now. It should unblock this

@HarelM
Copy link
Collaborator

HarelM commented Jan 9, 2025

Ahh, great! I was waiting for that.

@HarelM
Copy link
Collaborator

HarelM commented Jan 12, 2025

I've updated jsdom and canvas, let's see if this passes now.

@HarelM HarelM enabled auto-merge (squash) January 12, 2025 07:31
@HarelM HarelM merged commit 9c4f03b into maplibre:main Jan 12, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants