Skip to content

fix(build): emit relative imports so lib/ is portable - #3

Merged
eumaninho54 merged 3 commits into
mainfrom
fix/portable-lib-imports
Aug 27, 2026
Merged

fix(build): emit relative imports so lib/ is portable#3
eumaninho54 merged 3 commits into
mainfrom
fix/portable-lib-imports

Conversation

@eumaninho54

@eumaninho54 eumaninho54 commented Aug 27, 2026

Copy link
Copy Markdown
Member

0.1.0 on npm is broken

babel-plugin-module-resolver emits the alias target verbatim. The root babel.config.js declared alias: { '@': path.resolve(__dirname, 'src') }, so the published build carries the path of whatever machine ran yarn prepare:

// @salve-software/react-native-cicerone@0.1.0 — lib/module/components/Spotlight/index.js
import { Sparkles } from "/Users/eumaninho54/Documents/Projects/react-native-cicerone/src/components/Spotlight/components/Sparkles";

22 files in the published tarball look like that. Anything importing past the entry point fails to resolve, so the package is unusable for any consumer. The .d.ts files are fine — tsc-alias always emitted relative paths.

Why the release guard missed it

The guard grepped for @/, and @/ genuinely was not there — babel had resolved the alias, just into an absolute path. The check tested the symptom instead of the invariant.

scripts/verify-lib.sh now tests the invariant: no specifier in lib/ may be absolute. Validated against both builds — 36 hits on the published 0.1.0, exit 1; clean on this branch, exit 0. It runs on every PR through build-library, not only at release time, so this class of break can no longer reach a tag.

Commits

998d8b0 alias: { '@': './src' } — the fix
22bdfc4 verify-lib.sh, wired into ci.yml and release.yml, exposed as yarn verify:lib
b8ae380 imports.md said the absolute paths were deliberate — that claim is what shipped the bug

On the rule that said absolute was intentional

imports.md justified absolute aliases by "the example's babel config also transforms library files". That is stale: example/babel.config.js carries no module-resolver and says so in a comment — Metro resolves @/ and ~/ from example/tsconfig.json. Nothing depended on the absolute form, so the fix costs nothing.

Verification

yarn typecheck clean · yarn test 99 passing · yarn lint zero · yarn format:check clean · rebuilt lib/ has zero absolute specifiers and zero @/.

After merge

This needs a 0.1.1, and 0.1.0 should be deprecated on npm so nobody installs the broken tarball.

🤖 Generated with Claude Code

eumaninho54 and others added 3 commits August 27, 2026 19:23
The release guard only grepped for '@/', so it passed on a build whose
alias had already been resolved — into the build machine's absolute path.
0.1.0 shipped 22 files importing from /Users/... and nothing caught it.

verify-lib.sh checks the real invariant, that no specifier in lib/ is
absolute, and now runs on every PR through build-library rather than only
at release time.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
imports.md said both aliases are declared with absolute paths on purpose,
which is what put the build machine's path into 0.1.0. The example carries
no module-resolver, so nothing depended on it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@eumaninho54
eumaninho54 merged commit 44ebdc6 into main Aug 27, 2026
6 checks passed
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