Skip to content

Fix publish workflow + switch internal alias to subpath imports#197

Merged
0x80 merged 2 commits into
mainfrom
0521-publish-fails
May 21, 2026
Merged

Fix publish workflow + switch internal alias to subpath imports#197
0x80 merged 2 commits into
mainfrom
0521-publish-fails

Conversation

@0x80

@0x80 0x80 commented May 21, 2026

Copy link
Copy Markdown
Owner

Two independent changes on this branch.

Publish workflow fix

The publish workflow (.github/workflows/publish.yml) was failing at the Bump version step with:

npm error Git working directory not clean.

Root cause: tsdown.config.ts had exports: true, which makes tsdown rewrite package.json's bin and exports fields from the entry config on every build. With the entries named index and isolate-bin, tsdown strips the isolate bin alias that PR #188 explicitly restored alongside isolate-package for backwards compatibility. Locally that just leaves a dirty diff after pnpm build; in CI, pnpm build dirties the tree and the subsequent npm version aborts.

Fix: remove exports: true so the manually maintained bin/exports in package.json is the source of truth, and pnpm build no longer mutates the working tree.

Internal alias: ~/* -> #/* via subpath imports

Replace the TypeScript-only ~/* path alias with Node subpath imports. The mapping now lives in package.json as "imports": { "#/*": "./src/*" }, which is understood natively by Node, bundlers, and TypeScript — not only by tsc via tsconfig paths.

A matching paths entry remains in tsconfig.json because TS's bundler resolution of the imports field does not do directory-index fallback (so barrel imports like #/lib/utils -> src/lib/utils/index.ts would otherwise fail in tsc). The package.json imports field is the source of truth at runtime.

Engines is already >=22.22.1, well above the 14.6 cutoff for stable subpath imports.

Scope: packages (isolate-package), infra (publish workflow)
Visibility: internal

0x80 added 2 commits May 21, 2026 20:20
`tsdown`'s `exports: true` overwrites `package.json`'s `bin` and
`exports` fields from the entry config on every build. With the entries
named `index` and `isolate-bin`, it strips the `isolate` bin alias that
PR #188 explicitly restored alongside `isolate-package` for backwards
compatibility. Locally that just leaves a dirty diff after `pnpm build`,
but in the publish workflow the dirty tree makes the subsequent
`npm version` step abort with "Git working directory not clean".

Disable `exports: true` so the manually maintained `bin`/`exports` in
`package.json` is the source of truth, and `pnpm build` no longer
mutates the working tree.
Use the `imports` field in package.json instead of TypeScript-only
`paths` for the internal `#/*` alias (previously `~/*`). This makes the
mapping understood natively by Node, bundlers, and TS, rather than only
by tsc/bundlers via tsconfig paths.

TypeScript's bundler resolution of the `imports` field doesn't do
directory-index fallback, so a matching `paths` entry in tsconfig.json
is kept solely to make typecheck resolve barrel imports like
`#/lib/utils` (which resolves to `src/lib/utils/index.ts`). The
package.json `imports` field is the source of truth at runtime.

Engines is already `>=22.22.1`, well above the 14.6 cutoff for stable
subpath imports.
@0x80 0x80 merged commit 39eb039 into main May 21, 2026
4 checks passed
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR migrates the project's module import alias system from the ~ prefix to the # prefix. The tsconfig.json and package.json are updated to map the new #/* prefix to ./src/*. All source and test files throughout the codebase are then updated to import from the new #/ paths instead of the old ~/ paths. Test files also update their Vitest vi.mock() setup to intercept the new alias paths. The build configuration (tsdown.config.ts) removes an unused exports option.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly identifies the two main changes: fixing the publish workflow and switching from the internal ~/* alias to subpath imports (#/*).
Description check ✅ Passed The PR description comprehensively explains both independent changes with clear rationale, implementation details, and scope information aligned with the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 0521-publish-fails

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66a1c811-ab4a-4cb7-af9a-b8678010186b

📥 Commits

Reviewing files that changed from the base of the PR and between 673508a and 862b546.

📒 Files selected for processing (34)
  • package.json
  • src/get-internal-package-names.test.ts
  • src/lib/config.test.ts
  • src/lib/lockfile/helpers/generate-bun-lockfile.test.ts
  • src/lib/lockfile/helpers/generate-bun-lockfile.ts
  • src/lib/lockfile/helpers/generate-npm-lockfile.ts
  • src/lib/lockfile/helpers/generate-pnpm-lockfile.test.ts
  • src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
  • src/lib/lockfile/helpers/generate-yarn-lockfile.ts
  • src/lib/lockfile/process-lockfile.test.ts
  • src/lib/manifest/helpers/adapt-internal-package-manifests.test.ts
  • src/lib/manifest/helpers/adapt-internal-package-manifests.ts
  • src/lib/manifest/helpers/adapt-manifest-internal-deps.ts
  • src/lib/manifest/helpers/adopt-pnpm-fields-from-root.test.ts
  • src/lib/manifest/helpers/adopt-pnpm-fields-from-root.ts
  • src/lib/manifest/helpers/resolve-catalog-dependencies.test.ts
  • src/lib/manifest/helpers/resolve-catalog-dependencies.ts
  • src/lib/package-manager/helpers/infer-from-files.ts
  • src/lib/package-manager/helpers/infer-from-manifest.ts
  • src/lib/patches/collect-installed-names-bun.test.ts
  • src/lib/patches/collect-installed-names-bun.ts
  • src/lib/patches/collect-installed-names-pnpm.test.ts
  • src/lib/patches/collect-installed-names-pnpm.ts
  • src/lib/patches/copy-patches.test.ts
  • src/lib/patches/copy-patches.ts
  • src/lib/patches/write-isolate-pnpm-workspace.test.ts
  • src/lib/patches/write-isolate-pnpm-workspace.ts
  • src/lib/registry/collect-reachable-package-names.test.ts
  • src/lib/registry/list-internal-packages.test.ts
  • src/lib/utils/filter-patched-dependencies.test.ts
  • src/lib/utils/filter-patched-dependencies.ts
  • src/testing/setup.ts
  • tsconfig.json
  • tsdown.config.ts
💤 Files with no reviewable changes (1)
  • tsdown.config.ts

Comment thread tsconfig.json
/** tsgo doesn't inherit paths from base config */
"paths": {
"~/*": ["./src/*"]
"#/*": ["./src/*"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add the required ~/* path alias mapping.

Line 5 introduces only #/*; the required ~/* mapping is missing from tsconfig.json.

Suggested patch
   "compilerOptions": {
     "paths": {
+      "~/*": ["./src/*"],
       "`#/`*": ["./src/*"]
     }
   }

As per coding guidelines: tsconfig.json: Use path aliases with ~ mapping to src/ directory.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"#/*": ["./src/*"]
"~/*": ["./src/*"],
"`#/`*": ["./src/*"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant