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

chore: cleaning + major versions upgrade #147

Merged
merged 15 commits into from
Dec 31, 2024

Conversation

SRWieZ
Copy link
Contributor

@SRWieZ SRWieZ commented Dec 21, 2024

Summary of changes

  • Removed old vue dependencies
  • Removed stall files in dist/ from previous plugin builds (added rimraf before building plugin)
  • Fixed some type return in window.ts
  • Major version upgrade npm outdated:
    • vite v4 to v5
    • typescript v4 to v5
    • stylelint v14 to v16
    • prettier v2 to v3
    • eslint v8 to v9
    • electron-builder v24 to v25
    • electron-chromedriver v31 to v32
    • electron-context-menu v3 to v4
    • get-port v5 to v7
    • electron v31 to v32

Every commit is checked with (native:serveand native:build)

  • ✅ (typescript, vite, jest, eslint, electron-chromedriver, prettier) 1f38d64
  • ✅ ESLint upgraded, migrated but not applied 54b83e0
  • ✅ ESM migration: 825c342 245252f
  • ✅ Update of get-port, electron, electron-store and electron-context-menu 84f86e1 bb72311 df6fcbf

Upgrades to the last version of electron and vite blocked by

About the ESM upgrade:
More and more packages becomes ESM only. Electron supports ESM since v28. Here is some links to read for a better understanding:

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 21, 2024

WIP. Current state of npm outdated

Before & after
Capture d’écran 2024-12-21 à 20 15 07Capture d’écran 2024-12-21 à 20 06 01

@SRWieZ SRWieZ mentioned this pull request Dec 22, 2024
@SRWieZ SRWieZ marked this pull request as ready for review December 22, 2024 22:12
@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 22, 2024

Finished and ready to be tested ! 🎉

With this PR, we are up to date! We are only one version behind Electron and Vite.

I tested this PR with many of my apps without any problem.

There is one small irony:
The Jest tests I fixed here #148 are now broken.

I tried every other tutorial on the internet, and I don't understand why it doesn't mock electron. But to be fair, the tests haven't been working for a long time and are not testing the app fairly enough.

My suggestion is to migrate to vitest, which supports ESM modules out of the box and has a compatible syntax (it, test, describe, etc...). Maybe even make tests with electron rendered?

Post scriptum:
Intel Mac users, you may notice the following error in your console, which can be ignored:
EGL Driver message (Error) eglQueryDeviceAttribEXT: Bad attribute. electron/electron#43415
The solution is to either wait or disable GPU acceleration. So be patient.

Final result 😎
Capture d’écran 2024-12-22 à 23 04 17

Happy holidays to everyone! 🎊

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 25, 2024

Hold on to that, I found an error.

@SRWieZ SRWieZ marked this pull request as draft December 25, 2024 16:31
@SRWieZ SRWieZ marked this pull request as ready for review December 25, 2024 19:16
@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 25, 2024

Fixed!

I didn't pay enough attention to the Electron ESM documentation. preload.js wasn't preloading.

I'm developing all my apps with the "dev-main" requirement, so I noticed this issue in another app where I'm heavily using Livewire events.

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 25, 2024

I missed the build/notarize.js file, which my IDE completely hid from me. 🙄

I don't know why, but I cannot remove this directory from the excluded ones in PhpStorm. I also wonder if I'm the only one facing this issue. If not, we should probably rename this directory.

Anyway, I confirm that I can still build and use my app as before.

@simonhamp
Copy link
Member

simonhamp commented Dec 26, 2024

There are some conflicts here which need to be resolved since I've merged #149.

It seems to be mostly around file names.... do we need the .js extensions on the imports now for some reason?

Could you take a look when you get chance?

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 26, 2024

Yes, I can.

Can you merge #148 first? I will have a conflict with it as well.

This PR modifies all files, so the more pull requests you merge beforehand, the easier it will be to resolve conflicts at once.

@SRWieZ SRWieZ force-pushed the chore-update-major-deps branch from 0ab24c9 to e8fc6fa Compare December 26, 2024 19:31
@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 26, 2024

Rebased on main.

The minimum required node version is 20.

  • Bumped on GitHub Actions
  • Bumped on package.json

It seems to be mostly around file names.... do we need the .js extensions on the imports now for some reason?

Yes we have to. It's explained here and here

@simonhamp
Copy link
Member

That failing to run the plugin test suite concerns me...

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 29, 2024

I was planning to look into that after this one is merged.

I don't think I can make it work in jest. It's clearly a module resolution problem, and I have tried every other way before giving up.

I can explore the vitest approach if you want, here or in another PR.

@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 29, 2024

Obviously, I don't give up on the testing suite.

As you have seen with my previous PR, I think it's important to have a solid one.

It's just that with jest, I tried lots of different suggestions, and it's already hard to make it work well with TypeScript; it's worth it with ESM.

I really think we have a good chance with vitest if we believe the homepage (and some Stack Overflow users).

From https://vitest.dev:

  • Vite Powered: Reuse Vite's config and plugins - consistent across your app and tests. But it's not required to use Vitest!
  • Jest Compatible: Expect, snapshot, coverage, and more - migrating from Jest is straightforward.
  • Smart & instant watch mode: Only rerun the related changes, just like HMR for tests!
  • ESM, TypeScript, JSX: Out-of-the-box ESM, TypeScript, and JSX support powered by esbuild.

@simonhamp
Copy link
Member

I managed to make some progress on getting the test suite running...
Screenshot 2024-12-30 at 20 50 29

The failures seem to be related to the upgrades... maybe Vitest will handle all of this a little better, I don't know...

I'm going to approve this for now as I've been able to manually validate that things are still working (tho I suspect there may be some gremlins hidden away) and we can explore Vitest in a separate PR, and another one with my "fixes" for this test suite

@simonhamp simonhamp merged commit 9c9d369 into NativePHP:main Dec 31, 2024
21 of 22 checks passed
@SRWieZ
Copy link
Contributor Author

SRWieZ commented Dec 31, 2024

Cool! 🎉

We'll find the gremlins before tagging.

I'm going to pass all my apps to require "dev-main"


I tried the node --experimental-require-module node_modules/jest/bin/jest.js way too without success.

That would be included in node23 by the way.

Also this mode broke PHPStorm tests. I'm sure it's just a matter of configuring the experimental mode but it's better for contributors if it just work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants