GeezerVison is showing github.com — fix(vite): bundle the closures of dynamic imports in the HMR deps bundle by triniwiz · Pull Request #11584 · NativeScript/NativeScript
Conversation
PR Checklist
What is the current behavior?
Under HMR, deps-bundle discovery only follows static imports. Dynamic import() targets inside dependency code are externalized to their /ns/m/node_modules/... URL, and unless something else imports them statically, neither they nor anything they import end up in the bundle.
When a dependency lazily loads part of itself after boot (for example, when a screen is first opened), the device fetches that closure one module at a time. The dev server also transforms each of those modules on first request. In one app this blocked the JS thread for 3.8 s the first time a screen opened (~510 ms once the server's transforms were warm). The same screen opens in ~80 ms without HMR.
What is the new behavior?
- The import-routing plugin reports every node_modules
import() target it externalizes.
- After the main discovery pass, those targets and their closures are discovered too (repeating until no new targets turn up), and every file found is registered lazily like any other discovered input.
- The
import() call itself is unchanged: it still goes to the canonical /ns/m URL. That URL now serves a shim into the bundle, so evaluation stays lazy and module identity is preserved.
- This is best effort. A target whose closure fails to build (tried as a batch, then one by one) keeps per-module serving and does not fail the bundle. Probe builds run without
metafile, the same guard against esbuild 0.27 throwing outside the build promise that is used elsewhere.
In the app above, the first visit now takes 116 ms with a fresh dev server. Building the bundle took 9.4 s instead of 7.9 s.
Tests: deps-bundle.spec.ts covers a chained import() (target, its static import, and its own dynamic import are all registered), and a target with an unresolvable closure that stays per-module next to one that bundles. Two createDepsBundleService tests (opaque CJS / react-like shims) fail on main without this change too, on Windows.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Discovery only followed static imports, so a module a dependency loads
with import() after boot, and everything it imports, was fetched and
transformed one file at a time on first use. Those closures are now
discovered as well and registered lazily, so the import() URL serves a
shim into the bundle. A target whose closure does not build keeps
per-module serving.
nx-cloud
Bot
commented
Oct 23, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
🤖 Nx Cloud AI Fix Eligible
An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.
To disable these notifications, a workspace admin can disable them in workspace settings.
View your CI Pipeline Execution ↗ for commit 280566d
| Command |
Status |
Duration |
Result |
nx test apps-automated -c=ios |
❌ Failed |
9m 14s |
View ↗ |
nx run-many --target=test --configuration=ci --... |
✅ Succeeded |
<1s |
View ↗ |
💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.
☁️ Nx Cloud last updated this comment at 2026-10-23 23:09:33 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Open in StackBlitz
npm i https://pkg.pr.new/@nativescript/core@11584
npm i https://pkg.pr.new/@nativescript/vite@11584
npm i https://pkg.pr.new/@nativescript/webpack@11584
commit: 280566d
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# packages/vite/hmr/server/deps-bundle.ts
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|