Skip to content

Commit e654ca0

Browse files
shmuel hizmiclaude
andcommitted
Fix workspace:* not resolved in published packages
changeset publish uses npm publish which doesn't resolve workspace protocol. Add a pre-publish script that replaces workspace:* with real version numbers from the monorepo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e2c80d commit e654ca0

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

.changeset/fix-workspace-deps.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@playfast/wmux": patch
3+
"@playfast/echoform-bun-ws-client": patch
4+
"@playfast/echoform-bun-ws-server": patch
5+
"@playfast/echoform-socket-client": patch
6+
"@playfast/echoform-socket-server": patch
7+
---
8+
9+
Fix workspace:* dependencies not resolved in published packages.

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
with:
4545
version: bun run version
4646
publish: bun run release
47+
createGithubReleases: true
4748
env:
4849
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4950
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"knip:fix": "knip --fix",
2424
"changeset": "changeset",
2525
"version": "changeset version",
26-
"release": "changeset publish"
26+
"release": "node scripts/resolve-workspace-deps.js && changeset publish"
2727
},
2828
"devDependencies": {
2929
"@changesets/cli": "^2.25.2",

scripts/resolve-workspace-deps.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Resolves workspace:* dependencies to real version numbers in all publishable packages.
3+
* Run this before `changeset publish` since npm publish doesn't understand workspace protocol.
4+
*/
5+
const fs = require("fs");
6+
const path = require("path");
7+
8+
const packages = [
9+
"packages/fullstack",
10+
"packages/react-render-null",
11+
"packages/wmux",
12+
"plugins/fullstack/bun-ws-client",
13+
"plugins/fullstack/bun-ws-server",
14+
"plugins/fullstack/socket-client",
15+
"plugins/fullstack/socket-server",
16+
];
17+
18+
const versions = new Map();
19+
for (const pkgDir of packages) {
20+
const pkgJson = JSON.parse(fs.readFileSync(path.join(pkgDir, "package.json"), "utf8"));
21+
versions.set(pkgJson.name, pkgJson.version);
22+
}
23+
24+
for (const pkgDir of packages) {
25+
const pkgPath = path.join(pkgDir, "package.json");
26+
const pkgJson = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
27+
let changed = false;
28+
29+
for (const depField of ["dependencies", "devDependencies", "peerDependencies"]) {
30+
const deps = pkgJson[depField];
31+
if (!deps) continue;
32+
for (const [name, version] of Object.entries(deps)) {
33+
if (version === "workspace:*" && versions.has(name)) {
34+
deps[name] = "^" + versions.get(name);
35+
changed = true;
36+
}
37+
}
38+
}
39+
40+
if (changed) {
41+
fs.writeFileSync(pkgPath, JSON.stringify(pkgJson, null, 2) + "\n");
42+
console.log(` resolved workspace deps in ${pkgJson.name}`);
43+
}
44+
}

0 commit comments

Comments
 (0)