Fix publish workflow + switch internal alias to subpath imports#197
Conversation
`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.
WalkthroughThis PR migrates the project's module import alias system from the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (34)
package.jsonsrc/get-internal-package-names.test.tssrc/lib/config.test.tssrc/lib/lockfile/helpers/generate-bun-lockfile.test.tssrc/lib/lockfile/helpers/generate-bun-lockfile.tssrc/lib/lockfile/helpers/generate-npm-lockfile.tssrc/lib/lockfile/helpers/generate-pnpm-lockfile.test.tssrc/lib/lockfile/helpers/generate-pnpm-lockfile.tssrc/lib/lockfile/helpers/generate-yarn-lockfile.tssrc/lib/lockfile/process-lockfile.test.tssrc/lib/manifest/helpers/adapt-internal-package-manifests.test.tssrc/lib/manifest/helpers/adapt-internal-package-manifests.tssrc/lib/manifest/helpers/adapt-manifest-internal-deps.tssrc/lib/manifest/helpers/adopt-pnpm-fields-from-root.test.tssrc/lib/manifest/helpers/adopt-pnpm-fields-from-root.tssrc/lib/manifest/helpers/resolve-catalog-dependencies.test.tssrc/lib/manifest/helpers/resolve-catalog-dependencies.tssrc/lib/package-manager/helpers/infer-from-files.tssrc/lib/package-manager/helpers/infer-from-manifest.tssrc/lib/patches/collect-installed-names-bun.test.tssrc/lib/patches/collect-installed-names-bun.tssrc/lib/patches/collect-installed-names-pnpm.test.tssrc/lib/patches/collect-installed-names-pnpm.tssrc/lib/patches/copy-patches.test.tssrc/lib/patches/copy-patches.tssrc/lib/patches/write-isolate-pnpm-workspace.test.tssrc/lib/patches/write-isolate-pnpm-workspace.tssrc/lib/registry/collect-reachable-package-names.test.tssrc/lib/registry/list-internal-packages.test.tssrc/lib/utils/filter-patched-dependencies.test.tssrc/lib/utils/filter-patched-dependencies.tssrc/testing/setup.tstsconfig.jsontsdown.config.ts
💤 Files with no reviewable changes (1)
- tsdown.config.ts
| /** tsgo doesn't inherit paths from base config */ | ||
| "paths": { | ||
| "~/*": ["./src/*"] | ||
| "#/*": ["./src/*"] |
There was a problem hiding this comment.
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.
| "#/*": ["./src/*"] | |
| "~/*": ["./src/*"], | |
| "`#/`*": ["./src/*"] |
Two independent changes on this branch.
Publish workflow fix
The publish workflow (
.github/workflows/publish.yml) was failing at theBump versionstep with:Root cause:
tsdown.config.tshadexports: true, which makes tsdown rewritepackage.json'sbinandexportsfields from the entry config on every build. With the entries namedindexandisolate-bin, tsdown strips theisolatebin alias that PR #188 explicitly restored alongsideisolate-packagefor backwards compatibility. Locally that just leaves a dirty diff afterpnpm build; in CI,pnpm builddirties the tree and the subsequentnpm versionaborts.Fix: remove
exports: trueso the manually maintainedbin/exportsinpackage.jsonis the source of truth, andpnpm buildno longer mutates the working tree.Internal alias:
~/*->#/*via subpath importsReplace the TypeScript-only
~/*path alias with Node subpath imports. The mapping now lives inpackage.jsonas"imports": { "#/*": "./src/*" }, which is understood natively by Node, bundlers, and TypeScript — not only by tsc via tsconfig paths.A matching
pathsentry remains intsconfig.jsonbecause TS's bundler resolution of theimportsfield does not do directory-index fallback (so barrel imports like#/lib/utils->src/lib/utils/index.tswould otherwise fail in tsc). The package.jsonimportsfield 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