sveltejs / sveltejs/kit

svelte-kit caching with yarn PNP

Open
#5,353 10 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contributions-welcome
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows 10 setup with Node 18.1.0, Yarn 3.2.1 PnP, the skeleton app, and the vite server.fs.allow setting in svelte.config.js. Compare the first and follow-up yarn dev runs while inspecting .svelte-kit cleanup; done means repeated runs no longer produce the p.replace error or require deleting .svelte-kit.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, vite
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.