Why yarn creates a .pnp.loader.mjs and .pnp.cjs files
Asked Answered
V

3

17

I use vite on react, and when i use yarn to "live server" my project two new files are created, .pnp.loader.mjs and .pnp.cjs. What is the purpose of this files? I never see those files, always use npm or yarn and is the first time that they appear.

files

Ventriloquism answered 30/12, 2022 at 4:12 Comment(3)
Any update on this one?Cecilia
yarnpkg.com/features/pnpDeanery
The doc doesn't mention the .pnp.loader.mjs.Indictable
M
10

The .pnp.cjs is part of the Yarn Plug'n'Play process, which makes our install and runtime much faster. It makes the node_modules obsolete.

Yarn also creates an experimental ESM loader which is called .pnp.loader.mjs.

Mestas answered 30/1, 2023 at 7:55 Comment(3)
The doc doesn't mention the .pnp.loader.mjs.Indictable
So I assume that we also commit .php.loader.mjs to git along with .pnp.cjs right?Gromyko
I included both the .pnp.cjs and .pnp.loader.mjs script in my Git repo. You can think of the .pnp.loader.mjs as the core Yarn plug'n'play worker script. The .pnp.cjs script gets updated with package updates. Whether or not the hosting service that is used with the repo rebuilds those files from scratch when loading the app or not is hard to tell. My guess is that it uses the files available.Protuberate
L
2

If you do not want the .pnp.cjs to be created, create a .yarnrc.yml file in the root directory, add : nodeLinker: node-modules

Lavallee answered 8/7 at 6:37 Comment(0)
H
0
npx create-next-app@latest
npx next dev

The issue is from Yarn @Jan Willems says

Heteronomy answered 7/4, 2023 at 9:22 Comment(2)
any links for the disucssion?Engross
I use the official documentation and instead to follow the Yarn setup, I’m following the NPM setupHeteronomy

© 2022 - 2024 — McMap. All rights reserved.