parcel-bundler / parcel

The zero configuration build tool for the web. πŸ“¦πŸš€

Home Page:https://parceljs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default Cache folder location is on root instead of workspace folder

Tri125 opened this issue Β· comments

πŸ› bug report

According to the documentation, by default the cache folder should be stored in the .parcel-cache folder inside your project.
When using parcel with npm workspaces I observed that the cache is stored on the root level but I would have expected it to be stored under the workspace folder.

πŸŽ› Configuration (.babelrc, package.json, cli command)

// root package.json - overly simplified sample
{
  "name": "@examples",
  "main": "index.js",
  "scripts": {
    "start:first": "npm run -w first start",
    "start:second": "npm run -w second start"
  },
  "workspaces": [
    "./apps/*"
  ],
  "engines": {
    "node": ">=14.21.3",
    "npm": ">=7.24.2"
  },
  "devDependencies": {
    "parcel": "^2.11.0"
  }
}
// workspace package.json for workspace 'first' - overly simplified sample
{
    "name": "first",
    "main": "index.js",
    "private": true,
    "scripts": {
        "start": "parcel *.html --no-cache"
    },
}

/myProject
β”œβ”€β”€ apps
β”‚ β”œβ”€β”€ first
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ second
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json

From the root directory I would execute the following command:

npm run start:first

I am aware that the sample that I'm sharing here does disable reading from the cache .

πŸ€” Expected Behavior

From reading the documentation, I was expecting the following structure with the cache being created under the project folder being currently executed :

/myProject
β”œβ”€β”€ apps
β”‚ β”œβ”€β”€ first
β”‚ β”‚ β”œβ”€β”€ .parcel-cache
β”‚ β”‚ β”‚ β”œβ”€β”€ data.mbd
β”‚ β”‚ β”‚ β”œβ”€β”€ lock.mbd
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ second
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json

😯 Current Behavior

The cache is created on the root level.

/myProject
β”œβ”€β”€ .parcel-cache
β”‚ β”œβ”€β”€ data.mbd
β”‚ β”œβ”€β”€ lock.mbd
β”œβ”€β”€ apps
β”‚ β”œβ”€β”€ first
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ second
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ script.js
β”‚ β”‚ β”œβ”€β”€ package.json
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json

πŸ’ Possible Solution

As a workaround /apps/first/package.json can specify the --cache-dir cli option and the cache will be correctly created under /apps/first.

πŸ”¦ Context

A slight confusion but with a rather straight forward workaround. No impact.

🌍 Your Environment

Software Version(s)
Parcel 2.11.0
Node 14.21.3
npm/Yarn npm 8.19.4
Operating System Windows 10