Skip to content

fix: resolve compiled output from dist in bin and postinstall - #6095

Merged
NathanWalker merged 1 commit into
mainfrom
fix/dist-entrypoints
Jul 29, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/dist-entrypoints

Conversation

@edusperoni

@edusperoni edusperoni commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

PR Checklist

  • The PR title follows our guidelines.
  • There is an issue for the bug/feature this PR is for. (no tracking issue — happy to open one)
  • You have signed the CLA.
  • All existing tests are passing (1514 passing, unchanged).
  • Tests for the changes are included. (the failure is not reachable from the unit suite — verification below)

A regression from #6092. The release-script half of this went straight to main as cb3fb8db5, since it was blocking publishing; this is the remainder.

What is the current behavior?

bin/tns and postinstall.js resolve into lib/ relative to their own location:

pathToLib = path.join(__dirname, "..", "lib");          // bin/tns
require(path.join(__dirname, "lib", "constants"));      // postinstall.js

Since the build moved output to dist/, lib/ holds only TypeScript, so from a checkout:

$ ./bin/tns --version
Error: Cannot find module '.../lib/common/verify-node-version'

The published package is unaffected — dist/ is its root there, so lib/ already sits next to bin/. Only the source tree broke, which is exactly why the packaging verification on #6092 did not catch it.

npm install in a checkout runs postinstall and hits the same failure. That is masked today only because npm run setup passes --ignore-scripts.

What is the new behavior?

Both prefer dist/lib when it exists and fall back otherwise, so neither needs to know which layout it is in. The remaining bin/ entries (nativescript, ns, nsc, …) all require("./tns"), so they are fixed with it.

Verification

Not reachable from the unit suite, so both layouts were exercised directly:

  • Checkout: ./bin/tns --version reports, ./bin/tns renders 56 help rows, the nativescript/ns/nsc aliases work, node postinstall.js resolves
  • Installed package: packed, installed into a clean consumer, confirmed the fallback is the branch taken (no dist/lib present) — --version reports, help renders 56 rows, postinstall.js resolves
  • 1514 passing, unchanged

Worth noting for follow-up: nothing in the suite executes bin/tns in either layout, which is why this class of bug is invisible to CI. A smoke test covering both would close that.

Summary by CodeRabbit

  • Bug Fixes
    • Improved CLI startup across both published package installations and source checkouts.
    • Improved post-install setup by correctly locating required files in different package layouts.
    • Prevented installation and command-loading issues caused by incorrect library paths.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI bootstrap and postinstall script now detect dist/lib and fall back to lib, allowing module resolution in both published packages and source checkouts.

Changes

Runtime library resolution

Layer / File(s) Summary
Published and source library resolution
bin/tns, postinstall.js
Both entry points select dist/lib when it exists and otherwise resolve required modules from lib.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A bunny checked the paths with care,
Found dist/lib waiting there.
If that burrow wasn’t found,
lib kept modules safe and sound.
Hops now work from every ground.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preferring compiled output from dist in bin and postinstall.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@edusperoni edusperoni closed this Jul 29, 2026
@edusperoni
edusperoni force-pushed the fix/dist-entrypoints branch from d26d893 to cb3fb8d Compare July 29, 2026 16:08
Both resolve into lib/ relative to their own location, which stopped working
when the build moved output to dist/: lib/ now holds only TypeScript, so
running ./bin/tns or postinstall.js from a checkout fails with
MODULE_NOT_FOUND. The published package is unaffected, since dist/ is its
root and lib/ already sits next to bin/ there.

Both now prefer dist/lib when it exists and fall back otherwise, which covers
the checkout and the package without either needing to know which it is. The
other bin entries delegate to ./tns, so they are fixed with it.

npm install in a checkout runs postinstall and would hit the same failure -
masked only because npm run setup passes --ignore-scripts.
@edusperoni edusperoni reopened this Jul 29, 2026
@edusperoni edusperoni changed the title fix: repair the entry points and release script broken by the dist build Jul 29, 2026
@NathanWalker
NathanWalker merged commit 77fed31 into main Jul 29, 2026
6 checks passed
@NathanWalker
NathanWalker deleted the fix/dist-entrypoints branch July 29, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants