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

[🐛 Bug]: Re-fetch the Vercel package from the network every time when update in --watch mode #240

Closed
1 task done
noobnooc opened this issue May 13, 2023 · 4 comments · Fixed by #247
Closed
1 task done
Labels
bug Something isn't working in progress This issue is currently being worked on and show be solved soon.

Comments

@noobnooc
Copy link
Contributor

next-on-pages environment related information

System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
CPU: (10) arm64 Apple M1 Max
Memory: 32 GB
Shell: /bin/zsh
Binaries:
Node: 19.6.1
Yarn: 3.3.0
npm: 9.4.0
pnpm: N/A
Package Manager Used: yarn (berry)
Relevant Packages:
@cloudflare/next-on-pages: 0.10.1
vercel: N/A
next: N/A

Description

I have installed @cloudflare/next-on-pages, vercel and wrangler to the dependencies of my project. I added "cf:watch": "yarn next-on-pages --watch" to the scripts of package.json.

Then when I run yarn cf:watch in terminal, every time I update my code, @cloudflare/next-on-pages will refetch the vercel package from network, so the action is soooo slow.

After checked the source code in this repo, I found you are using yarn dlx to execute the vercel building in yarn (berry) environment. The code in next-on-pages/src/buildApplication/buildVercelOutput.ts#84 is following:

const vercelBuild = spawn(pkgMngCMD, [
	...(pkgMng === 'yarn (berry)' ? ['dlx'] : []),
	'vercel',
	'build',
]);

Since the yarn dlx will refetch the package from npm registry every time, so it do in --watch mode. And I tested with to delete the line ...(pkgMng === 'yarn (berry)' ? ['dlx'] : []), in above code, and it's to do things correctly without refetching.

Maybe you guys could consider run vercel building with yarn vercel directly when the vercel package is added to the project dependencies?

Reproduction

No response

Pages Deployment Method

None

Pages Deployment ID

No response

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
@noobnooc noobnooc added the bug Something isn't working label May 13, 2023
@dario-piotrowicz
Copy link
Member

@noobnooc thank you so very much for the issue, I must admit that I haven't used yarn for a while so I didn't know it would refetch the vercel package every single time 😓 (I am pretty sure this does not happen with npm and pnpm)


Maybe you guys could consider run vercel building with yarn vercel directly when the vercel package is added to the project dependencies?

this seems a valid proposed solution, I'd be totally on board 🙂
(I think the best approach would be to check if the vercel package is present locally with something like npm list or similar? maybe yarn offers a command that could provide that info for you? I can leave it up to you (or who will work on this) to experiment what the best and most reliable approach would be)


Since you ticked that you would like to help with the bug, would you like to have a go at it? 😃

@noobnooc
Copy link
Contributor Author

I found that there is a yarn info <package-name> command to check if a package has been installed. I will trying to fix it and submit a pull request :)

@dario-piotrowicz
Copy link
Member

Awesome! thank you so very much! 🙂

If you need anything or want to discuss possible approaches please just ask 😄

@noobnooc
Copy link
Contributor Author

Hello there. I opened a PR #247 to fix this issue. I have tested it separately in environments with and without Vercel installed, and there are no issues. Please take a look when you have time, and let me know if you encounter any problems.

@dario-piotrowicz dario-piotrowicz added the in progress This issue is currently being worked on and show be solved soon. label May 16, 2023
dario-piotrowicz pushed a commit that referenced this issue May 18, 2023
… using yarn berry. (#247)

* fix: refetch vercel package with yarn (#240)

* make the code more readable (#240)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress This issue is currently being worked on and show be solved soon.
Projects
None yet
2 participants