lerna icon indicating copy to clipboard operation
lerna copied to clipboard

publishConfig does not overrides after "lerna publish"

Open artechventure opened this issue 2 years ago • 4 comments

Current Behavior

publishConfig does not overrides package.json fields after "lerna publish".

original

{
  "main": "./src/index.ts",
  "publishConfig": {
    "main": "./dist/index.js"
  }
}

uploaded on npm

{
  "main": "./src/index.ts",
  "publishConfig": {
    "main": "./dist/index.js"
  }
}

Expected Behavior

package.json should be overwritten and publishConfig should be removed

{
  "main": "./dist/index.js",
}

Steps to Reproduce

  1. add "main" field in publishConfig different with original "main" field.
  2. run "lerna publish"
  3. install uploaded package on npm, and check its package.json

Failure Logs / Configuration

lerna.json

<!-- Please paste your `lerna.json` here -->
lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Environment

System: OS: macOS 12.1 CPU: (10) arm64 Apple M1 Max Binaries: Node: 16.14.0 - /private/var/folders/zr/3tkznhqs6sn26wsynpczk2pxz0g_by/T/xfs-a49a6c75/node Yarn: 3.2.1 - /private/var/folders/zr/3tkznhqs6sn26wsynpczk2pxz0g_by/T/xfs-a49a6c75/yarn Utilities: Git: 2.32.1 - /usr/bin/git

artechventure avatar Oct 31 '22 11:10 artechventure

https://github.com/lerna/lerna/blob/e33be4b043f4392311a1b12a1e3de4bdd5e0f42d/utils/pack-directory/lib/pack-directory.js#L55

Yarn, pnpm has its own packing logic, (via yarn pack, pnpm pack). And inside the pack command, I think there's a logic that overrides package.json's field by publishConfig. So creating tar like this might not work as expected in yarn, pnpm.

artechventure avatar Oct 31 '22 11:10 artechventure

@ghiscoding The mentioned issue talks about pnpm. The publishConfig replacement doesn't seem to work with yarn. It works if I do yarn npm publish to manually publish a package but not with lerna publish. Any other insight on this?

sahibjotsaggu avatar Sep 12 '23 04:09 sahibjotsaggu

@sahibjotsaggu yes it's been supported for a while now in Lerna-Lite with the help of @artechventure, see publishConfig overrides and the implementation is package manager agnostic, so it works the same on all of them (pnpm, yarn, npm).

However Lerna itself does not yet support this, hence why I'm guessing this issue is still open in here.

ghiscoding avatar Sep 12 '23 04:09 ghiscoding

For me this sound like an important feature, to make lerna usable with Typescript right? Can we expect any progress?

elixxx avatar Mar 05 '24 14:03 elixxx