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!: enable minification #7650

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Feb 13, 2024

The PR enables the modification of the pnpm.cjs file and the worker.js file.


I use pnpm through the corepack. When a requested version of pnpm is not available locally, corepack automatically downloads and caches pnpm locally. Currently, I have 20 copies of pnpm on my disk, each taking up about 15-20 MiB:

image

By enabling minification, the size of the pnpm.cjs file can be reduced from 8.1 MiB to 3.7 MiB, achieving a 53% reduction.

Yarn also ships a minified version of a single yarn.js bundle, which has a size of 2.7 MiB (https://repo.yarnpkg.com/4.0.0/packages/yarnpkg-cli/bin/yarn.js).

There are a few downsides though:

  • Patching pnpm itself becomes impossible (hence the breaking change)
  • The stack of the crash error might be messed up, so it could be hard to debug

@SukkaW SukkaW requested a review from zkochan as a code owner February 13, 2024 13:32
@zkochan
Copy link
Member

zkochan commented Feb 13, 2024

The broken stacktrace is a big issue

@SukkaW
Copy link
Contributor Author

SukkaW commented Feb 14, 2024

The broken stacktrace is a big issue

Yeah, that's what I am also concerned about. But I am wondering how Yarn get a workaround about this as Yarn has been shipping a minified version of the bundle since Yarn 3. They are not using sourcemap either.

@zkochan
Copy link
Member

zkochan commented Feb 14, 2024

Do they obfuscate function names?

@SukkaW
Copy link
Contributor Author

SukkaW commented Feb 14, 2024

Do they obfuscate function names?

Yes they do. Both Yarn 3 and Yarn 4 have mangled function names:

https://repo.yarnpkg.com/3.0.0/packages/yarnpkg-cli/bin/yarn.js
https://repo.yarnpkg.com/4.0.0/packages/yarnpkg-cli/bin/yarn.js

@zkochan zkochan requested a review from a team February 16, 2024 10:00
@zkochan
Copy link
Member

zkochan commented Feb 16, 2024

I don't have objections, I guess. @pnpm/collaborators what do you think?

@stevenpetryk
Copy link
Contributor

I don't think it's worth the downsides (patching pnpm is already something useful that we do).

@Jack-Works
Copy link
Member

About the stack trace, I tried to feed it over HTTP and found it does not work. I opened an issue at Node.js site. nodejs/node#51781

@jakebailey
Copy link
Member

I've noticed this storage problem too, but I also have found stack traces to be valuable in diagnosing previous crashes on DT.

It'd be nice if corepack had some sort of automatic cache clearing; since it's the one running each package manager via its shims, it should know when each download was last used and could drop ones that haven't been used in a while. It'll transparently download them again later if needed.

@stevenpetryk
Copy link
Contributor

So yeah, I think this issue should be raised with corepack (likely already has?). I think losing stacktraces in prod builds of pnpm will seriously hinder the project's ability to be debugged in the future.

If you're accumulating corepack package managers and don't like it, you can always clean them periodically.

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.

None yet

5 participants