desktop / dugite

Elegant bindings for working with Git in your Node applications
MIT License
460 stars 149 forks source link

Git exec takeup 500MB when installed with pnpm #550

Closed linonetwo closed 1 year ago

linonetwo commented 1 year ago
截屏2023-07-17 13 55 51

I think these files used to be soft link, maybe pnpm break this? Or is this a breaking change in 2.5.1?

I try download from https://github.com/desktop/dugite-native/releases and it is really soft link 截屏2023-07-17 14 04 52

So when I pack dugite into electron, it takeup 500MB of size.

Is libexec really necessary? If I use await GitProcess.exec(['fetch', remoteName, defaultBranchName], dir);, will you call git-fetch in it? Or will you fallback to bin/git if I delete the libexec folder?

linonetwo commented 1 year ago

Anyway, manually pnpm run postinstall in node_modules/.pnpm/dugite@2.5.1/node_modules/dugite/package.json to redownload and extract git binary fixes this.

截屏2023-07-17 14 10 18

I'm copying dugite to electron bundled app's Resources/node_modules to fix module resolution in worker_thread. Maybe at sometime I break this by using dereference: true?

截屏2023-07-17 14 12 22

exports.default = async (buildPath, electronVersion, platform, arch, callback) => {
  const cwd = path.resolve(buildPath, '..');
  const projectRoot = path.resolve(__dirname, '..');
    // it has things like `git/bin/libexec/git-core/git-add` link to `git/bin/libexec/git-core/git`, to reduce size, so can't use `dereference: true` here.
    // And pnpm will have node_modules/dugite to be a shortcut, can't just copy it with `dereference: false`, have to copy from .pnpm folder
    await fs.copy(path.join(projectRoot, 'node_modules', '.pnpm', `dugite@${packageJSON.dependencies.dugite}`, 'node_modules', 'dugite'), path.join(cwd, 'node_modules', 'dugite'), { dereference: false });