guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
138 stars 7 forks source link

Templates "fighting" to install dependencies #33

Closed canadaduane closed 2 years ago

canadaduane commented 2 years ago

I believe what I'm seeing is multiple templates starting pnpm simultaneously(?) and fighting to modify package.json.

My chompfile.toml:

version = 0.1

[default-template-opts.npm]
  auto-install = true
  pkg-manager = "pnpm"

[[task]]
  name = "build"
  deps = [":generate", ":css"]

[[task]]
  name = "generate"
  template = "jspm"
  target = "public/index.html"
  deps = ["src/index.html", "svelte", "swc"]
  [task.template-opts]
    env = ["browser", "production"]

[[task]]
  name = "svelte"
  template = "svelte"
  target = "public/build/#.js"
  deps = ["src/#.svelte"]

[[task]]
  name = "swc"
  template = "swc"
  target = "public/build/#.js"
  deps = ["src/#.ts"]

[[task]]
  name = "css"
  target = "public/#.css"
  deps = ["src/#.css"]
  run = "cp $DEP $TARGET"

[[task]]
  name = "clean"
  run = "rm -rf public/*"

My package.json (before chomp build):

{
  "name": "tendril-art",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build": "chomp",
    "dev": "chomp -s"
  },
  "devDependencies": {
    "@tsconfig/svelte": "^2.0.0"
  },
  "dependencies": {
    "@smui/form-field": "^5.0.0-beta.7",
    "@smui/select": "^5.0.0-beta.7",
    "@smui/switch": "^5.0.0-beta.7",
    "@smui/textfield": "^5.0.0-beta.7",
    "@types/three": "^0.133.0",
    "sirv-cli": "^1.0.0",
    "svelte-range-slider-pips": "^1.8.0",
    "three": "0.131.3",
    "troika-three-text": "0.43.0",
    "troika-three-utils": "0.43.0",
    "troika-worker-utils": "^0.43.0"
  }
}

During the package install phase, there are many references to my version of pnpm being out of date (which clued me into what was happening). Usually pnpm shows the out-of-date warning just once. In addition, many packages are being "reused", and seem to be installing the same thing over and over again:

Progress: resolved 46, reused 22, downloaded 19, added 086 MB, done
Progress: resolved 62, reused 28, downloaded 19, added 086 MB
Progress: resolved 63, reused 29, downloaded 20, added 0.2.128: 1.53 MB/13.8 MB
Downloading registry.npmjs.org/@swc/core-linux-x64-gnu/1.2.128: 13.8 MB/13.8 MB, donee
Downloading registry.npmjs.org/@swc/core-linux-x64-gnu/1.2.128: 13.8 MB/13.8 MB, done
DoDownloading registry.npmjs.org/@swc/core-linux-x64-musl/1.2.128: 8.39 MB/13.9 MB

(It's a bit hard to see, because pnpm likes to erase the line and write over top of the line to show the next package download).

Finally, the end state of my package.json looks like it only installed one of the templates' dependencies (swc in this case):

{
  "name": "tendril-art",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build": "chomp",
    "dev": "chomp -s"
  },
  "devDependencies": {
    "@swc/cli": "0.1",
    "@swc/core": "1",
    "@tsconfig/svelte": "^2.0.0"
  },
  "dependencies": {
    "@smui/form-field": "^5.0.0-beta.7",
    "@smui/select": "^5.0.0-beta.7",
    "@smui/switch": "^5.0.0-beta.7",
    "@smui/textfield": "^5.0.0-beta.7",
    "@types/three": "^0.133.0",
    "sirv-cli": "^1.0.0",
    "svelte-range-slider-pips": "^1.8.0",
    "three": "0.131.3",
    "troika-three-text": "0.43.0",
    "troika-three-utils": "0.43.0",
    "troika-worker-utils": "^0.43.0"
  }
}
guybedford commented 2 years ago

I've posted a proposal to fix this issue in https://github.com/guybedford/chomp/issues/34. It shouldn't be too hard. Let's track there.