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 — feat: ES modules (ESM) support with conditional esm or commonjs consumption by NathanWalker · Pull Request #1836 · NativeScript/android

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Aug 27, 2025

Copy link
Copy Markdown
Contributor
  • Conditionally detects .mjs (esm) or .js bundled code
  • Loads and executes ES modules

Backwards compatible.

Sorry, something went wrong.

Uh oh!

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

adrian-niculescu and vallemar reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
edusperoni and others added 17 commits August 18, 2025 23:26
@edusperoni
feat: update Gradle and Android build tools versions to 8.14.3 and 8.…
278178f
…12.1
@NathanWalker
chore: 9.0.0-alpha.0
6b76cad
@NathanWalker
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
6ab9f01
…l-esm-consumption
@NathanWalker
feat: es module support
00529a8
@NathanWalker
feat: es module support
48d5939
@NathanWalker
feat: es module support
fbfb74e
@NathanWalker
feat: sbg support for es modules
2067b0b
@NathanWalker
fix: application path to use absolute path instead of relative, more …
bd24b43
…robust
@NathanWalker
feat: handle .js and .mjs extensions when loading main
66eff21
@NathanWalker
chore: es module tests
25ff64e
@NathanWalker
chore: 9.0.0-alpha.1
74e4097
@NathanWalker
feat: provide node:url polyfill
9275d5b
@NathanWalker
chore: 9.0.0-alpha.2
1d7e32b
@NathanWalker
feat: use terminal reporter and fix tests
bd900f7
@NathanWalker
fix: unique filename handling with static binding generator
d25130f
Cases where the same java classname would result causing a name collision.
@NathanWalker
feat: es module dynamic import support
e66a428
@NathanWalker
feat: logScriptLoading - this may be unnecessary really, added for al…
ce03b17
…pha testing largely
@NathanWalker
NathanWalker marked this pull request as draft September 7, 2025 18:11
NathanWalker added 3 commits September 8, 2025 17:05
@NathanWalker
chore: 9.0.0-alpha.3
ccef166
@NathanWalker
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
bee756c
…l-esm-consumption
@NathanWalker
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
116a45d
…l-esm-consumption
@NathanWalker
NathanWalker marked this pull request as ready for review October 23, 2025 17:08
@NathanWalker
NathanWalker requested a review from Copilot October 23, 2025 17:09
Copilot AI reviewed Oct 23, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

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 ES module (ESM) support to the NativeScript Android runtime, enabling the use of .mjs files alongside traditional CommonJS .js files. The implementation includes conditional detection of ES modules, dynamic import support, import.meta functionality, and enhanced Worker constructor capabilities.

Key Changes:

  • Native C++ implementation for ES module loading, resolution, and callbacks (import.meta, dynamic imports)
  • Java-side module resolution updated to handle .mjs file extensions
  • Test infrastructure modernized to verify results via console output instead of XML files
  • Build tools updated to recognize and process .mjs files

Reviewed Changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test-app/runtime/src/main/cpp/ModuleInternalCallbacks.cpp Implements ES module resolution callback, import.meta initialization, dynamic import support, and Node.js built-in polyfills
test-app/runtime/src/main/cpp/ModuleInternal.cpp Adds LoadESModule function to compile and evaluate .mjs files with proper registry management
test-app/runtime/src/main/java/com/tns/Module.java Updates file resolution to check for .mjs extensions alongside .js files
test-app/runtime/src/main/cpp/Runtime.cpp Registers V8 callbacks for import.meta and dynamic import()
test-app/tools/check_console_test_results.js New script to verify test results from console output instead of XML files
test-app/runtime/src/main/java/com/tns/AppConfig.java Adds logScriptLoading configuration option
test-app/build-tools/static-binding-generator/src/main/java/org/nativescript/staticbindinggenerator/Generator.java Updates binding generator to create unique identifiers for .mjs files
test-app/app/src/main/assets/app/tests/testESModules.js Test suite validating ES module loading, import.meta, and Worker enhancements
Comments suppressed due to low confidence (2)

test-app/runtime/src/main/cpp/ModuleInternalCallbacks.cpp:1

  • The regex pattern /\/+/g uses JavaScript literal syntax but this is C++ code generating a JavaScript polyfill string. The backslashes need to be escaped for the C++ string literal to produce the correct JavaScript regex. Should be \\/+ to properly escape the forward slash.
#include "ModuleInternal.h"

test-app/runtime/src/main/cpp/ModuleInternalCallbacks.cpp:1

  • Incorrect comment: usleep(100) provides a 100 microsecond (0.1ms) delay, but the comment says '0.1ms delay' which is correct. However, note that usleep() is deprecated in POSIX.1-2008 and removed in POSIX.1-2001; consider using nanosleep() instead.
#include "ModuleInternal.h"

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread test-app/tools/check_console_test_results.js Resolved

Uh oh!

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

Comment thread test-app/tools/check_console_test_results.js Resolved

Uh oh!

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

Comment thread test-app/tools/check_console_test_results.js Resolved

Uh oh!

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

Comment thread test-app/runtime/src/main/java/com/tns/Runtime.java Resolved

Uh oh!

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

NathanWalker and others added 6 commits October 23, 2025 10:11
@NathanWalker
chore: test-app/tools/check_console_test_results.js
2006895
Co-authored-by: Copilot <[email protected]>
@NathanWalker
chore: test-app/tools/check_console_test_results.js
4ce886a
Co-authored-by: Copilot <[email protected]>
@NathanWalker
chore: test-app/tools/check_console_test_results.js
ed5fad9
Co-authored-by: Copilot <[email protected]>
@NathanWalker
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
dd5c2ca
…l-esm-consumption
@NathanWalker
chore: cleanup
7fc7277
@NathanWalker
chore: cleanup
282ded6
@NathanWalker
NathanWalker requested a review from triniwiz November 5, 2025 03:44
triniwiz
triniwiz reviewed Nov 5, 2025
View reviewed changes
Comment thread test-app/runtime/src/main/cpp/Version.h Resolved

Uh oh!

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

NathanWalker
NathanWalker commented Nov 5, 2025
View reviewed changes
Comment thread test-app/runtime/src/main/cpp/Version.h Resolved

Uh oh!

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

NathanWalker
NathanWalker commented Nov 5, 2025
View reviewed changes
Comment thread test-app/runtime/src/main/cpp/Version.h Resolved

Uh oh!

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

@NathanWalker
chore: revert version.h change
abaaad8
@NathanWalker
NathanWalker merged commit 052cb21 into main Nov 5, 2025
5 checks passed

Uh oh!

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

@NathanWalker
NathanWalker deleted the feat/allow-conditional-esm-consumption branch November 5, 2025 06:25
@gustavotrott gustavotrott mentioned this pull request Aug 24, 2026
Static binding names never match at runtime since 9.0.0 — every extend() falls back to runtime dex generation #2024
Open
@edusperoni edusperoni mentioned this pull request Nov 11, 2026
fix: load prebuilt classes for anonymous extends #2101
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@triniwiz triniwiz triniwiz left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

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.

4 participants

@NathanWalker @triniwiz @edusperoni
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.