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

Migrate from CRA to Vite #170

Merged
merged 12 commits into from
Jul 20, 2023
Merged

Migrate from CRA to Vite #170

merged 12 commits into from
Jul 20, 2023

Conversation

franknoirot
Copy link
Collaborator

@franknoirot franknoirot commented Jul 12, 2023

I want to be able to add React Router to the app so that we can get normal browser routing behavior. All the examples in the getting started page use Vite, so I decided it might be good to nip this in the bud while I'm at it. Really not as crazy as I thought it would be, but I may need a little bit more context on how testing is set up in the project to finish this.

I followed this tutorial for the basic migration, then followed this one to add back TS support and this one to add back ESLint.

@franknoirot franknoirot self-assigned this Jul 12, 2023
@vercel
Copy link

vercel bot commented Jul 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
untitled-lang ✅ Ready (Inspect) Visit Preview Jul 20, 2023 11:16pm

@franknoirot
Copy link
Collaborator Author

Getting this error after following this tutorial for migrating from CRA testing tool to Vitest. It seems like another "you can't use wrtc on ARM-powered Macs" thing to me @Irev-Dev:

Error: dlopen(/Users/frankjohnson/code/untitled-lang/node_modules/wrtc/build/Release/wrtc.node, 0x0001): tried: '/Users/frankjohnson/code/untitled-lang/node_modules/wrtc/build/Release/wrtc.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/frankjohnson/code/untitled-lang/node_modules/wrtc/build/Release/wrtc.node' (no such file), '/Users/frankjohnson/code/untitled-lang/node_modules/wrtc/build/Release/wrtc.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

@Irev-Dev
Copy link
Collaborator

@franknoirot maybe try the following in src/setupTests.ts

class MockRTCPeerConnection {
  constructor() {
  }
  createDataChannel() {
    return
  }
  setRemoteDescription() {
    return Promise.resolve()
  }
  setConfiguration() {
    return Promise.resolve()
  }
  addEventListener() {
    return Promise.resolve()
  }
  get localDescription() {
    return Promise.resolve()
  }
  addTransceiver() {
    return Promise.resolve()
  }
  createOffer() {
    return Promise.resolve()
  }
  setLocalDescription() {
    return Promise.resolve()
  }
  close() {
    return Promise.resolve()
  }
}

// @ts-ignore
global.RTCPeerConnection = MockRTCPeerConnection

And remove wrtc as a dependency, If later we need to test the wrtc connection in node we can figure it out then. I am a little confused, is this a m2 thing? works okay on my m1?

I actually don't think we'll have many tests around wrtc, so I'd be open to having a couple of those tests only run in CI and are skipped locally.

@Irev-Dev
Copy link
Collaborator

This is looking really good so far, don't let yourself get in too much strife with the tests, I'm happy to take a stab or it, or we can do it together.
I call this part of FE dev "config hell", it sucks.

@franknoirot
Copy link
Collaborator Author

Huh that's super weird that it's working on your M1 just fine. Is that the case even with my Vite branch? Here are my environment versions too, are these wrong at all?

  • shell: zsh running latest OhMyZsh
  • node: v18.16.0 via NVM

@Irev-Dev
Copy link
Collaborator

Irev-Dev commented Jul 13, 2023

Oh right, maybe it's node, I've got v14.21.3, there was a reason I'm running 14, but I can't remember why I changed it.
Using zsh as well.

@Irev-Dev
Copy link
Collaborator

Irev-Dev commented Jul 13, 2023

Some progress but still got some issue, up to you if you want to merge or not.
#175

But got rid of wrtc and solved a couple of other test issues. The one I'm stuck on though is this annoying issue with code-mirror

I was focused on the tests, before I put the PR up I tried yarn start and the page never properly loads because of an error, I'm not sure If I introduced it or not.

@franknoirot
Copy link
Collaborator Author

Oh interesting, I think it is something about Apple Silicon because I can't even install Node 14 using NVM. This answer is suggesting I open ZSH with Rosetta and mimic the Intel process when I use the command line basically, but I really only want to do that when I'm about to work with Node 14 or lower. Do you have Rosetta enabled for your terminal then?

@Irev-Dev
Copy link
Collaborator

Irev-Dev commented Jul 13, 2023

Oh I was able to install 14 with n 🤷
And no I needed to up to 16 to use vite anyway, so I've already updated, and once I did that I started having the wrtc issues, but I also removed wrtc in #175, but with new issues :/

@Irev-Dev
Copy link
Collaborator

Okay I've definitely hit a roadblock with #175

I think there's just an incompatibility with vitest and codemirror, or at least our version of it. I was tempted to get jest working again instead since that's what was running with CRA, but I felt like that was maybe taking the migration away from your direction.
Maybe we should touch base on this.

topic change, when I run yarn start on this branch, it boots up but I get a process not defined error immediately in the browser, do you get that as well?

@franknoirot
Copy link
Collaborator Author

I think there's just an incompatibility with vitest and codemirror, or at least our version of it. I was tempted to get jest working again instead since that's what was running with CRA, but I felt like that was maybe taking the migration away from your direction.
Maybe we should touch base on this.
Yeah I agree let's regroup! I'm not tied to vitest though.

topic change, when I run yarn start on this branch, it boots up but I get a process not defined error immediately in the browser, do you get that as well?
Yes I get this too. However if I run yarn build first and then run yarn start it works as expected, fully loading including a working stream.

@Irev-Dev
Copy link
Collaborator

Going to rebase to fix conflicts

@Irev-Dev
Copy link
Collaborator

fwiw, when I was trying to use Vitest, everything went smoothly, it was only the one dependency that seemed to have an incompatibility, getting jest to work was a slog, and nothing was a show stopper, just one thing after the other. Would be happy to migrate to Vitest later if we're able to.

@Irev-Dev
Copy link
Collaborator

I think this is probably ready to be merged, I think I'll sleep on it first and do a self-review in the morning as well though.

@Irev-Dev Irev-Dev marked this pull request as ready for review July 20, 2023 21:38
@Irev-Dev
Copy link
Collaborator

Found a few lingering deps that were not needed. Will merge after vercel and tests ✅

@Irev-Dev
Copy link
Collaborator

Okay dope, finally got vercel to be happy again.

Copy link
Collaborator

@Irev-Dev Irev-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go!

@Irev-Dev Irev-Dev merged commit b89faa4 into main Jul 20, 2023
@Irev-Dev Irev-Dev deleted the vite branch July 20, 2023 23:25
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