Skip to content

Conversation

@NathanWalker
Copy link
Contributor

@NathanWalker NathanWalker commented Nov 6, 2025

This pull request introduces significant improvements to the NativeScript runtime, focusing on better support for ES modules, Hot Module Replacement (HMR), and developer ergonomics. The key changes include the addition of a new HMR support module, centralized development flags, enhanced path normalization for module resolution, and stricter handling of HTTP-based module imports. These updates help improve module loading reliability, enable minimal HMR features, and provide more consistent developer experience.

ESM/HMR Support Enhancements:

  • Added new HMRSupport.h and HMRSupport.mm modules providing minimal HMR (import.meta.hot) support, including per-module hot data, accept/dispose callback registration, and helpers for dev HTTP ESM loaders. [1] [2]
  • Introduced centralized development/runtime flags in DevFlags.h and DevFlags.mm (e.g., IsScriptLoadingLogEnabled) to control verbose logging and other dev features via package.json. [1] [2]

Module Resolution Improvements:

  • Implemented NormalizePath helper to standardize file system paths for consistent lookups in the module registry, reducing path-related bugs during module loading.
  • Updated module loading logic to use canonical paths and improved handling of ES module loading errors in debug mode to prevent unnecessary app termination. [1] [2]

HTTP Module Import Handling:

  • Added guards to prevent usage of require() for HTTP(S) modules, enforcing dynamic import() for such cases and providing clear error messages.
  • Improved canonicalization of HTTP URLs for module registry keys, ensuring stable and predictable module resolution during development and HMR.

…k to allow continued development during debug
With Vite, we just include inspector_modules in the bundle when running in debug mode so no need to load separate file. Other bundlers can do the same now.
@NathanWalker NathanWalker changed the title feat: http loaded es module realms and HMR DX enrichments feat: http loaded es module realms + HMR DX enrichments Nov 6, 2025
@NathanWalker NathanWalker marked this pull request as ready for review November 6, 2025 07:19
@NathanWalker NathanWalker requested a review from Copilot November 6, 2025 07:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds HTTP ESM (ECMAScript Module) loader functionality with Hot Module Replacement (HMR) support to the NativeScript iOS runtime. This enables the runtime to fetch and compile ES modules from a development server over HTTP during development, supporting features like live reload and hot module replacement.

Key Changes

  • HTTP-based ES module loading for development builds
  • HMR infrastructure with import.meta.hot support
  • Module registry enhancements for cache management and fallback handling
  • Comprehensive test suite for HTTP ESM loader functionality
  • App Transport Security configuration updates for HTTP requests

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
package.json Version bump to 9.0.0-alpha.9
TestRunner/app/tests/index.js Added HttpEsmLoaderTests to test suite
TestRunner/app/tests/HttpEsmLoaderTests.js New test suite for HTTP ESM loader features
TestRunner/app/tests/esm/*.mjs Test fixtures for ESM loading scenarios
TestRunner/Info.plist Added NSAppTransportSecurity to allow HTTP requests
NativeScript/runtime/Runtime.mm Integrated HMR support headers and import.meta.hot initialization
NativeScript/runtime/ModuleInternalCallbacks.mm Core HTTP ESM loader implementation with module resolution
NativeScript/runtime/ModuleInternal.mm Path normalization and ESM loading enhancements
NativeScript/runtime/HMRSupport.{h,mm} New HMR support module with HTTP fetching utilities
NativeScript/runtime/DevFlags.{h,mm} New development flags module for logging control
NativeScript/NativeScript-Prefix.pch Version update to match package.json

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants