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

[create-next-app, Yarn, linux/Darwin] Fresh Next projects can't be pushed to GitHub due to size of tracked @next/swc binary #65586

Open
bosconian-dynamics opened this issue May 9, 2024 · 3 comments · May be fixed by #65823
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@bosconian-dynamics
Copy link

bosconian-dynamics commented May 9, 2024

Link to the code that reproduces this issue

https://github.com/bosconian-dynamics/cna-repro-yarn-pnp-gh

Note: the issue is itself the inability to push repos which create-next-app produces to GitHub, and as such it prevents me from creating a minimal reproduction repository. The repo above is a dummy to satisfy the issue template requirements.

To Reproduce

In a WSL2 Ubuntu x64 environment (or likely other linux/unix environments):

  1. yarn create next-app foobar
  2. cd foobar
  3. git remote add origin https://github.com/xxx/foobar
  4. git push origin main

Current vs. Expected behavior

Observation

In linux/unix environments (or at the very least in WSL2 Ubuntu 20 x64, and evidently Darwin x64), Yarn PnP in combination with create-next-app's templates' .gitignore files result in create-next-app creating project repositories with an initial commit which cannot be pushed to free GitHub repositories due to the 100M file size limitation. The large file in question appears to be the Next compiler which resides at the following location in my Next repositories:

.yarn/unplugged/@next-swc-linux-x64-gnu-npm-14.2.3-635f7187f5/node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node

In my environment, the git push operation produces the following output:

$ git push origin main
Enumerating objects: 798, done.
Counting objects: 100% (798/798), done.
Delta compression using up to 12 threads
Compressing objects: 100% (782/782), done.
Writing objects: 100% (798/798), 203.24 MiB | 4.00 MiB/s, done.
Total 798 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (13/13), done.
remote: error: Trace: 196be7017bc6c58f3bfa0e53058cf07f500569efac1b596ff8524f176dd0a7b7
remote: error: See https://gh.io/lfs for more information.
remote: error: File .yarn/unplugged/@next-swc-linux-x64-gnu-npm-14.1.0-5a9ae6f5df/node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node is 114.62 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/xxx/foobar.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/xxx/foobar.git'

Resolving the issue necessitates a fair bit of research on the end-user's part, and ultimately the modification of the default .gitignore file provided by the templates as well as squashing or rewriting the repo's history to exclude the problematic files. Alternately - if users instead follow the advice suggested by the git error - they may end up down a different rabbit hole, setting up Git LFS (and likely engaging GitHub's LFS services which may incur costs in short order) just to handle the SWC binary.

The issue is compounded in downstream tools such as Cloudflare's create-cloudflare, which themselves may create additional commits on top of the one which create-next-app makes, further cementing the problematic file's inclusion in the fresh project repository's history.

Expectation

Project repositories created via create-next-app should be able to be pushed to a free GitHub repository immediately, without requiring the end-user to modify default files and squashing/rewriting repository history or set up Git LFS.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Wed Mar 2 00:30:59 UTC 2022
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 4.2.2
  pnpm: N/A
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

This issue has been discussed within the context of Darwin in April of 2023 - and other unknown environments in the time since - see #48956

@bosconian-dynamics bosconian-dynamics added the bug Issue was opened via the bug report template. label May 9, 2024
@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label May 9, 2024
@bosconian-dynamics bosconian-dynamics changed the title [create-next-app, Yarn, Ubuntu] Fresh repos can't be pushed to GitHub due to size of @next/swc [create-next-app, Yarn, Ubuntu] Fresh Next projects can't be pushed to GitHub due to size of @next/swc May 9, 2024
@bosconian-dynamics
Copy link
Author

Could the templates' default .gitignore files be updated for parity with Yarn's documented recommendations?

Yarn suggests that .yarn/unplugged contains machine-specific build artifacts and can usually be ignored - is there a reason for tracking that directory in fresh Next app repos?

@bosconian-dynamics bosconian-dynamics changed the title [create-next-app, Yarn, Ubuntu] Fresh Next projects can't be pushed to GitHub due to size of @next/swc [create-next-app, Yarn, linux/Darwin] Fresh Next projects can't be pushed to GitHub due to size of tracked @next/swc May 9, 2024
@bosconian-dynamics bosconian-dynamics changed the title [create-next-app, Yarn, linux/Darwin] Fresh Next projects can't be pushed to GitHub due to size of tracked @next/swc [create-next-app, Yarn, linux/Darwin] Fresh Next projects can't be pushed to GitHub due to size of tracked @next/swc binary May 9, 2024
@icyJoseph
Copy link
Contributor

Hi,

Would you mind opening a PR with these set of changes? No idea why these were not included, but most likely, because it is very much specific to that package manager, and it was just overlooked.

@bosconian-dynamics
Copy link
Author

@icyJoseph sounds good. I've created #65823

Do you suppose that this something that should be addressed in the Next.js examples as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
2 participants