Skip to content

fix(vite): rebuild the cached core bundle when a patch-package core patch changes - #11408

Merged
NathanWalker merged 1 commit into
mainfrom
fix/vite-core-bundle-cache-patches
Sep 2, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/vite-core-bundle-cache-patches

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

The dev server's esbuild core bundle is persisted under node_modules/.ns-vite/core-bundle-<platform>-<key>.mjs and reused while its cache key matches. The key includes core's package.json mtime to detect reinstalls, but patch-package rewrites files inside node_modules/@nativescript/core and never touches package.json. So after adding, changing or removing patches/@nativescript+core+<version>.patch, the device keeps booting the previously cached, unpatched core until the cache is deleted by hand or the run is started with NS_CORE_BUNDLE_NO_DISK_CACHE=1.

This is easy to hit and hard to notice: /ns/m/node_modules/@nativescript/core/... serves the patched file (so curl looks right), while the running app evaluates the stale single-eval bundle.

Fix

readCorePatchesSignature(projectRoot) lists patches/@nativescript+core*.patch (patch-package's file naming) and folds each file's name, size and mtime into the core bundle cache key as corePatches. A missing patches/ directory contributes an empty signature, so projects without patches keep the same behavior as before.

…atch changes

The persisted esbuild core bundle is keyed on core's package.json mtime,
which patch-package leaves untouched when it rewrites files inside
node_modules/@nativescript/core — so a patched core kept serving the
cached, unpatched bundle until the cache was deleted by hand. The names,
sizes and mtimes of patches/@NativeScript+core*.patch now join the key.
@nx-cloud

nx-cloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 818a06e

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 32s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-02 13:41:21 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11408
npm i https://pkg.pr.new/@nativescript/vite@11408
npm i https://pkg.pr.new/@nativescript/webpack@11408

commit: 818a06e

@NathanWalker
NathanWalker merged commit 49c3235 into main Sep 2, 2026
10 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-core-bundle-cache-patches branch September 2, 2026 17:59
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