augments

hello, when augmenting the @sapphire/pieces to edit the container, when i use pnpm i am required to install '@sapphire/pieces' package or augments for @sapphire/pieces do not work
30 Replies
Solution
Favna
Favna12mo ago
See other posts regarding pnpm: https://discord.com/channels/737141877803057244/1172360505386614946/1173039629067370506 https://discord.com/channels/737141877803057244/1168008762049712128/1168964583860486154
shamefully-hoist=true
public-hoist-pattern[]=@sapphire/*
shamefully-hoist=true
public-hoist-pattern[]=@sapphire/*
iaqi
iaqiOP12mo ago
ah, i used pnpm cause it was fast but i think im just gonna switch back to normal npm, yarns features have no use for me
Favna
Favna12mo ago
yarn is also fast <:rolling_eyes:796067273961504820> especially if you use Yarn v4 instead of Yarn v1 (which you should, yarn v1 is very very deprecated)
iaqi
iaqiOP12mo ago
is yarn the best to use? i just feel like i dont use any features of yarn
Favna
Favna12mo ago
That's a subjective question but at least Sapphire uses Yarn
iaqi
iaqiOP12mo ago
except yarn upgrade-interactive that is very useful
Favna
Favna12mo ago
yarn is/has: - ensures consistent package manager versions as the version is per-repo as opposed to npm where other contributors can fuck up your package-lock.json because they have an older version - Or if you're on windows and their on linux it can also fuck up, joy! - better support for symlinking packages - a clearer lockfile, one that is also human readable unlike package-lock.json - better support for workspaces - supports more protocols for installing packages - easier to configure and documentation for configuration options is easier to access - supports local cache OOTB for consistent cache / no internal installation - and if pnp mode is enabled you can even achieve zero installs
iaqi
iaqiOP12mo ago
what are zero installs
Favna
Favna12mo ago
literally what the name implies. Other people not having to install packages. https://yarnpkg.com/features/caching#zero-installs
Cache strategies | Yarn
How to ensure your installs perform the absolute minimal amount of work.
Spinel
Spinel12mo ago
Yarn v4 is new version of Yarn that we recommend switching to as Yarn v1 has long since been deprecated.
"But I don't see any update on [source]?"
That is correct. Yarn v4 is installed through Yarn itself. You configure Yarn v4 on a per-project basis. How you installed Yarn globally is largely irrelevant to this (corepack, volta, something else). How to install Yarn v4 for your project? Simply write:
yarn set version berry
yarn set version berry
This will download the new Yarn v4 binary and put in .yarn/releases, you should push this to your Git repository. It will also create a .yarnrc.yml file which configures the path which you should also commit. Next you probably also want to run the following 2 commands:
yarn config set enableGlobalCache true
yarn config set nodeLinker node-modules
yarn config set enableGlobalCache true
yarn config set nodeLinker node-modules
This will add to your .yarnrc file:
enableGlobalCache: true
nodeLinker: node-modules
enableGlobalCache: true
nodeLinker: node-modules
This ensures you have a more traditional experience with node_modules and a global cache. The next step is to nuke your node_modules and yarn.lock and run yarn install Then some final adjustments. Put this in you .gitignore:
# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml
# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml
And anywhere in your scripts in package.json where you use * you should wrap it in extra " For example:
{
"format": "prettier --write \"src/**/*.ts\""
}
{
"format": "prettier --write \"src/**/*.ts\""
}
Mind you this last thing is a good thing to add regardless of script runner / package bundler because it ensures the glob is performed by the library and not by your shell, which may differ when people develop on different operating systems. In short, the command to set everything up you can run:
yarn set version berry && yarn config set enableGlobalCache true && yarn config set nodeLinker node-modules && echo "" >> .gitignore && echo "# Yarn files" >> .gitignore && echo ".yarn/install-state.gz" >> .gitignore && echo ".yarn/build-state.yml" >> .gitignore
yarn set version berry && yarn config set enableGlobalCache true && yarn config set nodeLinker node-modules && echo "" >> .gitignore && echo "# Yarn files" >> .gitignore && echo ".yarn/install-state.gz" >> .gitignore && echo ".yarn/build-state.yml" >> .gitignore
Favna
Favna12mo ago
Granted that and local cache are mostly useful in larger teams with diverse experience and/or advanced CI/CD environments, but the fact that it exists at all is still cool
iaqi
iaqiOP12mo ago
what yarn options do you use like for every project
Favna
Favna12mo ago
what the bot lists, though yarn v4 added compressionLevel: mixed as well. Haven't delved into what that exactly is.
iaqi
iaqiOP12mo ago
The value mixed is a variant of 9 where files are stored uncompressed if the gzip overhead would exceed the size gain. so pretty much just 9
Favna
Favna12mo ago
ah apparently 9 is equal to Yarn v3
iaqi
iaqiOP12mo ago
yarn looks really nice the actual logs and whatnot
Favna
Favna12mo ago
To avoid making the upgrade too disruptive, Yarn will check whether Zero-Installs are enabled the first time you run yarn install after migrating from 3.6 to 4.0. If you do, it will automatically set the old default (compressionLevel: mixed) in your .yarnrc.yml file. You can then remove it whenever you feel ready to actually change the compression settings.
I guess compression level is only relevant if you 1. use local cache 2. check that into Git
iaqi
iaqiOP12mo ago
wait so what is the equivelant of npx in yarn
Favna
Favna12mo ago
yarn dlx
iaqi
iaqiOP12mo ago
i need to use npx for my prisma ah ok
Favna
Favna12mo ago
or just yarn prisma if you have it in devdeps
iaqi
iaqiOP12mo ago
yeah i do okay
Favna
Favna12mo ago
it automatically matches first against scripts and then in CLI tools in node_modules/.bin I should've added that to the list above it's stupid that npm doesn't match automatically
iaqi
iaqiOP12mo ago
tysm favna, btw do you use linux? you seem like the type of person to use it lol
Favna
Favna12mo ago
Nah Windows and Mac.
iaqi
iaqiOP12mo ago
nice i love macos also if possible i know this is a big favour but could you at any time just check my bots source and tell me what to improve on i would appreciate it a lot
Favna
Favna12mo ago
I suppose I could but be warned that with such requests I am quite critical
iaqi
iaqiOP12mo ago
thats what i need haha
Favna
Favna12mo ago
(and nitpicky)
iaqi
iaqiOP12mo ago
ive made sure ive used the best practices for everything ive done so im excited to see what you could tell me to improve on hey, tysm again here is the repo: https://github.com/nicklvh/joewy its still wip
Want results from more Discord servers?
Add your server