question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

svelte-kit caching with yarn PNP

See original GitHub issue

Describe the bug

Overview

Previously there was some discussion over the use of yarn PNP / berry here

The main advantage of PNP is that it allows you to reference packages from a global cache on the disk (similar to pnpm except without the disk hard links). So it saves on disk space with the global cache setting enabled.

With yarn 3.2.1 PNP this sort of half works. If you install and set everything up then it works fine on the first run, but then fails on the follow up run due to something related to the .svelte-kit caching

Reproduction

Example

First setup a new svelte kit app (skeleton)

yarn create svelte myapp
cd myapp

Switch to yarn berry with PNP

yarn set version berry

Add the following to the config under the kit section of svelte.config.js

kit: {
    vite: {server: {fs: {allow: ['.yarn']}}},
}

Try yarn dev

yarn dev

At this point things work on the first run On follow up runs this error shows up

> p.replace is not a function
    at Object.toPortablePath (C:\SourceCode\project-docs\example\.pnp.cjs:2808:9)
    at PosixFS.mapToBase (C:\SourceCode\project-docs\example\.pnp.cjs:5313:18)
    at PosixFS.rmdirSync (C:\SourceCode\project-docs\example\.pnp.cjs:5230:39)
    at URLFS.rmdirSync (C:\SourceCode\project-docs\example\.pnp.cjs:5230:24)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)

If I delete the .svelte-kit directory then it works fine again for a first run.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 5.34 GB / 15.68 GB
  Binaries:
    Node: 18.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.2.1 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.44)
    Internet Explorer: 11.0.19041.1566

Severity

annoyance

Additional Information

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tyhicommented, Jul 22, 2022

Using yarn 3.2.2 which included the pr I had mentioned above the issue still persists.

0reactions
dominikgcommented, Jul 20, 2022

is there anything kit can/should do here? Looks like yarn pnp still has issues to solve on their end.

The fs.allow setting can be provided by pnp users in config. Automatic detection would be something either for vite or a supporting vite-plugin-yarn-pnp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ • SvelteKit
The Plug'n'Play feature, aka 'pnp', is broken (it deviates from the Node module ... of Yarn Berry is the ability to have a...
Read more >
Added the husky with yarn 2 · 0a413eceef - sveltekit-starter - Teknik Git
sveltekit -starter - Sveltekit boilerplate. ... .pnp.cjs generated ... .yarn/cache/husky-npm-6.0.0-384872ea98-61e1f7f53f.zip vendored.
Read more >
JavaScript package managers compared: npm, Yarn, or pnpm?
yarn /cache/ (PnP). It is important to understand that Yarn Berry only allows us to execute binaries we've specified in our package.
Read more >
https://www.toptal.com/developers/gitignore/api/no...
... .yarn/build-state.yml .yarn/install-state.gz .pnp.* ### Node Patch ### # Serverless Webpack directories .webpack/ # Optional stylelint cache # SvelteKit ...
Read more >
[AskJS] Is someone using Yarn v2 in business? - Reddit
PnP being the default in Yarn 2 has caused some controversies (see ... Zero-Installs represents committing the .yarn/cache folder to a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found