Title: build: emit to dist/ and ship generated declarations by edusperoni · Pull Request #6092 · NativeScript/nativescript-cli · GitHub
Open Graph Title: build: emit to dist/ and ship generated declarations by edusperoni · Pull Request #6092 · NativeScript/nativescript-cli
X Title: build: emit to dist/ and ship generated declarations by edusperoni · Pull Request #6092 · NativeScript/nativescript-cli
Description: 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 (1513 passing, unchanged). Tests for the changes are included. (build change; verified by packing and installing the artifact — see below) What is the current behavior? tsc emits next to each source file, so lib/ holds both the TypeScript and its output. That has cost us repeatedly: A spec deleted in Sept 2025 left its compiled .js behind and kept running for ten months — 8 tests exercising code that no longer existed. prepack silently undid its own release compile, because ts:release_build and the test step both wrote to the same place. Shipped lib/*.js carried comments as a result. .gitignore needs a blanket *.js plus a growing list of negations to tell source from output apart, which is why new files under scripts/ and dev/ have twice been invisible to git. clean has to reconstruct "which .js are output" from a glob list. There is also no coherent published type surface: 60 hand-written .d.ts ship, but the package declares no types entry, so consumers get nothing. What is the new behavior? Build output goes to dist/, and dist/ is assembled as a complete package root rather than just compiled JS. That last part is the crux. lib/ resolves its siblings through __dirname — ../package.json, ../docs/helpers, ../../config, ../../vendor/gradle-plugin, ../../../vendor/aab-tool/bundletool.jar. Mirroring resources/, docs/, config/, vendor/, bin/ and setup/ alongside lib/ means all 46 of those paths keep working with no code changes, and the published tarball keeps exactly the internal layout it has today. Only where it is built from changed. tsconfig.json gains rootDir/outDir (rootDir is required, or tsc flattens the tree) tsconfig.release.json builds lib/ only, with declaration: true — this is what gets packed scripts/copy-assets.js mirrors assets, writes dist/package.json packing npm run pack → npm pack ./dist; prepack/postpack are gone 392 generated declarations now ship, replacing the hand-written set as the emitted API surface. Adding a types entry is a deliberate follow-up — worth doing on its own merits rather than smuggling a new public contract into a build change. Two behaviours improve as a side effect: The GA id no longer touches your working tree. It is set inside dist (set-ga-id.js live --dir dist), so a failed pack can no longer leave a checkout configured to report as production. That is the concern raised on #6088, resolved by the design rather than bolted on. A guard refuses to pack the repository root, which would otherwise nest everything one level deeper and silently break every __dirname path. Verified it blocks bare npm pack and does not fire for npm pack ./dist. Two bugs this caught while being built Worth recording, because both produce a successful build with a subtly wrong artifact and neither is visible to the test suite: The asset copy initially clobbered fresh output. lib/ still contained 375 stale compiled .js from the old in-place build (against 7 genuine source .js — vendored scripts, hooks, fixtures). The copy step now treats a .js with a sibling .ts as compiler output and skips it. README.md, LICENSE and CHANGELOG.md dropped out of the tarball. npm takes those from the directory being packed, which is now dist. Caught by diffing the packed file list against the published 9.1.0-alpha.15. Hand-written .d.ts are also copied through: tsc treats them as inputs and never emits them, and 115 generated declarations import from them — leaving them behind shipped types with dangling references. Verification 1513 passing, 9 pending — unchanged, now running from dist/ Packed file list vs published 9.1.0-alpha.15: the only absences are lib/.d.ts (the grunt-ts aggregator, removed in #6088) and the unused cross-client enum (removed in #6089) — both already gone from main Tarball installed into a clean consumer: CLI runs, --version reports, help renders 56 rows across 6 sections, sibling paths resolve, sample generated declaration has zero dangling imports Shipped config.json carries the live GA id while the working tree keeps dev npm run clean.build leaves zero compiler output in lib//test/ Note for reviewers .github/workflows/npm_release_cli.yml changes from npm pack to npm run pack. Without that the release would produce a tarball with everything nested under dist/. The publish job is unaffected — it publishes a tarball, so no lifecycle scripts run. Summary by CodeRabbit Build & Packaging Improved package creation for more reliable CLI distribution. Packages now publish only the built dist/ output and point the CLI entry to the built artifact. Added safeguards to prevent packing from the repository root. Improved asset copying for consistent runtime distribution. Testing Tests now run against the built distribution output (dist/). Maintenance Improved cleanup of generated build files. Added an option to select a configuration directory when setting or verifying analytics IDs.
Open Graph Description: 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 ...
X Description: 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 ...
Opengraph URL: https://github.com/NativeScript/nativescript-cli/pull/6092
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:5b5fe4ad-84ff-b741-0564-06b5310c8fa2 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AF8A:14F601:3407670:41FC35C:6B01C1B3 |
| html-safe-nonce | 44eb3da56d0aa948a1896aed9f33742257d1bece73d78483bdb82b72a47264c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjhBOjE0RjYwMTozNDA3NjcwOjQxRkMzNUM6NkIwMUMxQjMiLCJ2aXNpdG9yX2lkIjoiOTE3NDg4OTA3NzcxODIzNzYxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fc13d19aab89a780441d8acfabd0d69c1d55746ffb19aa43d2da574a2d066df3 |
| hovercard-subject-tag | pull_request:4154935371 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/nativescript-cli/pull/6092/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | 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 ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 21347346 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21347346 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-cli |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width