-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat: http loaded es module realms + HMR DX enrichments #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…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.
…ght based on user choice
…l-esm-exception-improvements
…l-esm-consumption
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…l-esm-consumption
…mption' into feat/hmr-improvements
There was a problem hiding this 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.hotsupport - 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.
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:
HMRSupport.handHMRSupport.mmmodules 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]DevFlags.handDevFlags.mm(e.g.,IsScriptLoadingLogEnabled) to control verbose logging and other dev features viapackage.json. [1] [2]Module Resolution Improvements:
NormalizePathhelper to standardize file system paths for consistent lookups in the module registry, reducing path-related bugs during module loading.HTTP Module Import Handling:
require()for HTTP(S) modules, enforcing dynamicimport()for such cases and providing clear error messages.