GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@triniwiz

@triniwiz triniwiz commented Oct 23, 2026

Copy link
Copy Markdown
Member

PR Checklist

  • The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages.
  • There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
  • You have signed the CLA.
  • All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#running-unit-tests-application.
  • Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md.

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.

All reactions
@triniwiz
fix(vite): bundle the closures of dynamic imports in the HMR deps bundle
280566d
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

nx-cloud Bot commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🤖 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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NathanWalker
Merge remote-tracking branch 'origin/main' into pr-11584
9f63b50
# Conflicts:
#	packages/vite/hmr/server/deps-bundle.ts
@NathanWalker
NathanWalker merged commit 57dc78e into main Nov 9, 2026
7 of 8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@NathanWalker
NathanWalker deleted the fix/vite-deps-bundle-dynamic-imports branch November 9, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@triniwiz @NathanWalker
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.